@@ -320,6 +320,50 @@ describe('Test Plots', function() {
320
320
321
321
} ) ;
322
322
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
+
323
367
describe ( 'Plots.purge' , function ( ) {
324
368
var gd ;
325
369
0 commit comments