Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fee3de6

Browse files
committed
Merge pull request #389 from n-riesco/shapes-test
Add shapes tests
2 parents f382f46 + 0d213b7 commit fee3de6

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

test/jasmine/tests/shapes_test.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
var d3 = require('d3');
2+
3+
var Plotly = require('@lib/index');
4+
var Lib = require('@src/lib');
5+
6+
var createGraphDiv = require('../assets/create_graph_div');
7+
var destroyGraphDiv = require('../assets/destroy_graph_div');
8+
9+
10+
describe('Test shapes nodes', function() {
11+
'use strict';
12+
13+
var mock = require('@mocks/shapes.json');
14+
var gd;
15+
16+
beforeEach(function(done) {
17+
gd = createGraphDiv();
18+
19+
var mockData = Lib.extendDeep([], mock.data),
20+
mockLayout = Lib.extendDeep({}, mock.layout);
21+
22+
Plotly.plot(gd, mockData, mockLayout).then(done);
23+
});
24+
25+
afterEach(destroyGraphDiv);
26+
27+
function countShapeLayers() {
28+
return d3.selectAll('.shapelayer').size();
29+
}
30+
31+
function countPaths() {
32+
return d3.selectAll('.shapelayer > path').size();
33+
}
34+
35+
it('has one *shapelayer* node', function() {
36+
expect(countShapeLayers()).toEqual(1);
37+
});
38+
39+
it('has as many *path* nodes as there are shapes', function() {
40+
expect(countPaths()).toEqual(mock.layout.shapes.length);
41+
});
42+
43+
it('should be able to get relayout', function(done) {
44+
expect(countShapeLayers()).toEqual(1);
45+
expect(countPaths()).toEqual(mock.layout.shapes.length);
46+
47+
Plotly.relayout(gd, {height: 200, width: 400}).then(function() {
48+
expect(countShapeLayers()).toEqual(1);
49+
expect(countPaths()).toEqual(mock.layout.shapes.length);
50+
done();
51+
});
52+
});
53+
});

0 commit comments

Comments
 (0)