@@ -358,27 +358,38 @@ describe('@gl Test gl2d plots', function() {
358
358
var _mock = Lib . extendDeep ( { } , mock ) ;
359
359
_mock . data [ 0 ] . line . width = 5 ;
360
360
361
+ function assertDrawCall ( msg , exp ) {
362
+ var draw = gd . _fullLayout . _plots . xy . _scene . scatter2d . draw ;
363
+ expect ( draw ) . toHaveBeenCalledTimes ( exp , msg ) ;
364
+ draw . calls . reset ( ) ;
365
+ }
366
+
361
367
Plotly . plot ( gd , _mock )
362
368
. then ( delay ( 30 ) )
363
369
. then ( function ( ) {
370
+ spyOn ( gd . _fullLayout . _plots . xy . _scene . scatter2d , 'draw' ) ;
364
371
return Plotly . restyle ( gd , 'visible' , 'legendonly' ) ;
365
372
} )
366
373
. then ( function ( ) {
367
- expect ( gd . querySelector ( '.gl-canvas-context' ) ) . toBe ( null ) ;
374
+ expect ( readPixel ( gd . querySelector ( '.gl-canvas-context' ) , 108 , 100 ) [ 0 ] ) . toBe ( 0 ) ;
375
+ assertDrawCall ( 'legendonly' , 0 ) ;
368
376
369
377
return Plotly . restyle ( gd , 'visible' , true ) ;
370
378
} )
371
379
. then ( function ( ) {
372
380
expect ( readPixel ( gd . querySelector ( '.gl-canvas-context' ) , 108 , 100 ) [ 0 ] ) . not . toBe ( 0 ) ;
381
+ assertDrawCall ( 'back to visible' , 1 ) ;
373
382
374
383
return Plotly . restyle ( gd , 'visible' , false ) ;
375
384
} )
376
385
. then ( function ( ) {
377
- expect ( gd . querySelector ( '.gl-canvas-context' ) ) . toBe ( null ) ;
386
+ expect ( readPixel ( gd . querySelector ( '.gl-canvas-context' ) , 108 , 100 ) [ 0 ] ) . toBe ( 0 ) ;
387
+ assertDrawCall ( 'visible false' , 0 ) ;
378
388
379
389
return Plotly . restyle ( gd , 'visible' , true ) ;
380
390
} )
381
391
. then ( function ( ) {
392
+ assertDrawCall ( 'back up' , 1 ) ;
382
393
expect ( readPixel ( gd . querySelector ( '.gl-canvas-context' ) , 108 , 100 ) [ 0 ] ) . not . toBe ( 0 ) ;
383
394
} )
384
395
. catch ( failTest )
0 commit comments