Skip to content

Commit d55e767

Browse files
committed
Tests: Add test for plot clip after relayout
1 parent 04bf7b5 commit d55e767

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/jasmine/tests/plot_api_test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,36 @@ describe('Test plot api', function() {
2020
});
2121
});
2222

23+
describe('Plotly.relayout', function() {
24+
var gd;
25+
26+
beforeEach(function() {
27+
gd = createGraphDiv();
28+
});
29+
30+
afterEach(destroyGraphDiv);
31+
32+
it('should update the plot clipPath if the plot is resized', function(done) {
33+
34+
Plotly.plot(gd, [{ x: [1,2,3], y: [1,2,3] }], { width: 500, height: 500 })
35+
.then(function() {
36+
return Plotly.relayout(gd, { width: 400, height: 400 });
37+
})
38+
.then(function() {
39+
var uid = gd._fullLayout._uid;
40+
41+
var plotClip = document.getElementById('clip' + uid + 'xyplot'),
42+
clipRect = plotClip.children[0],
43+
clipWidth = +clipRect.getAttribute('width'),
44+
clipHeight = +clipRect.getAttribute('height');
45+
46+
expect(clipWidth).toBe(240);
47+
expect(clipHeight).toBe(220);
48+
})
49+
.then(done);
50+
});
51+
});
52+
2353
describe('Plotly.restyle', function() {
2454
beforeEach(function() {
2555
spyOn(Plotly, 'plot');

0 commit comments

Comments
 (0)