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

Skip to content

Commit fe43f21

Browse files
committed
Tests: Add test for Plots.resize
1 parent d55e767 commit fe43f21

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

test/jasmine/tests/plots_test.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,50 @@ describe('Test Plots', function() {
320320

321321
});
322322

323+
describe('Plots.resize', function() {
324+
var gd;
325+
326+
beforeEach(function(done) {
327+
gd = createGraphDiv();
328+
329+
Plotly.plot(gd, [{ x: [1,2,3], y: [2,3,4] }], {})
330+
.then(function() {
331+
gd.style.width = '400px';
332+
gd.style.height = '400px';
333+
334+
return Plotly.Plots.resize(gd);
335+
})
336+
.then(done);
337+
});
338+
339+
afterEach(destroyGraphDiv);
340+
341+
it('should resize the plot clip', function() {
342+
var uid = gd._fullLayout._uid;
343+
344+
var plotClip = document.getElementById('clip' + uid + 'xyplot'),
345+
clipRect = plotClip.children[0],
346+
clipWidth = +clipRect.getAttribute('width'),
347+
clipHeight = +clipRect.getAttribute('height');
348+
349+
expect(clipWidth).toBe(240);
350+
expect(clipHeight).toBe(220);
351+
});
352+
353+
it('should resize the main svgs', function() {
354+
var mainSvgs = document.getElementsByClassName('main-svg');
355+
356+
for(var i = 0; i < mainSvgs.length; i++) {
357+
var svg = mainSvgs[i],
358+
svgWidth = +svg.getAttribute('width'),
359+
svgHeight = +svg.getAttribute('height');
360+
361+
expect(svgWidth).toBe(400);
362+
expect(svgHeight).toBe(400);
363+
}
364+
});
365+
});
366+
323367
describe('Plots.purge', function() {
324368
var gd;
325369

0 commit comments

Comments
 (0)