@@ -229,7 +229,7 @@ describe('Test gl plot interactions', function() {
229
229
} ) ;
230
230
231
231
describe ( 'gl3d modebar click handlers' , function ( ) {
232
- var modeBar ;
232
+ var modeBar , relayoutCallback ;
233
233
234
234
beforeEach ( function ( done ) {
235
235
var mockData = [ {
@@ -245,8 +245,13 @@ describe('Test gl plot interactions', function() {
245
245
246
246
gd = createGraphDiv ( ) ;
247
247
Plotly . plot ( gd , mockData , mockLayout ) . then ( function ( ) {
248
+
248
249
modeBar = gd . _fullLayout . _modeBar ;
249
250
251
+ relayoutCallback = jasmine . createSpy ( 'relayoutCallback' ) ;
252
+
253
+ gd . on ( 'plotly_relayout' , relayoutCallback ) ;
254
+
250
255
delay ( done ) ;
251
256
} ) ;
252
257
} ) ;
@@ -342,7 +347,26 @@ describe('Test gl plot interactions', function() {
342
347
. toEqual ( { x : 2.5 , y : 2.5 , z : 2.5 } ) ;
343
348
344
349
selectButton ( modeBar , 'resetCameraDefault3d' ) . click ( ) ;
350
+
345
351
setTimeout ( function ( ) {
352
+
353
+ expect ( relayoutCallback ) . toHaveBeenCalledTimes ( 2 ) ; // initiator: resetCameraDefault3d; 2 scenes
354
+ expect ( relayoutCallback ) . toHaveBeenCalledWith ( {
355
+ scene : {
356
+ eye : { x : 1.25 , y : 1.25 , z : 1.25 } ,
357
+ center : { x : 0 , y : 0 , z : 0 } ,
358
+ up : { x : 0 , y : 0 , z : 1 }
359
+ }
360
+ } ) ;
361
+ expect ( relayoutCallback ) . toHaveBeenCalledWith ( {
362
+ scene2 : {
363
+ center : { x : 0 , y : 0 , z : 0 } ,
364
+ eye : { x : 1.25 , y : 1.25 , z : 1.25 } ,
365
+ up : { x : 0 , y : 0 , z : 1 }
366
+ }
367
+ } ) ;
368
+ relayoutCallback . calls . reset ( ) ;
369
+
346
370
expect ( sceneLayout . camera . eye )
347
371
. toEqual ( { x : 0.1 , y : 0.1 , z : 1 } , 'does not change the layout objects' ) ;
348
372
expect ( scene . camera . eye )
@@ -353,7 +377,25 @@ describe('Test gl plot interactions', function() {
353
377
. toBeCloseToArray ( [ 1.25 , 1.25 , 1.25 ] , 4 ) ;
354
378
355
379
selectButton ( modeBar , 'resetCameraLastSave3d' ) . click ( ) ;
380
+
356
381
setTimeout ( function ( ) {
382
+
383
+ expect ( relayoutCallback ) . toHaveBeenCalledTimes ( 2 ) ; // initiator: resetCameraLastSave3d; 2 scenes
384
+ expect ( relayoutCallback ) . toHaveBeenCalledWith ( {
385
+ scene : {
386
+ center : { x : 0 , y : 0 , z : 0 } ,
387
+ eye : { x : 0.1 , y : 0.1 , z : 1 } ,
388
+ up : { x : 0 , y : 0 , z : 1 }
389
+ }
390
+ } ) ;
391
+ expect ( relayoutCallback ) . toHaveBeenCalledWith ( {
392
+ scene2 : {
393
+ center : { x : 0 , y : 0 , z : 0 } ,
394
+ eye : { x : 2.5 , y : 2.5 , z : 2.5 } ,
395
+ up : { x : 0 , y : 0 , z : 1 }
396
+ }
397
+ } ) ;
398
+
357
399
expect ( sceneLayout . camera . eye )
358
400
. toEqual ( { x : 0.1 , y : 0.1 , z : 1 } , 'does not change the layout objects' ) ;
359
401
expect ( scene . camera . eye )
@@ -364,7 +406,9 @@ describe('Test gl plot interactions', function() {
364
406
. toBeCloseToArray ( [ 2.5 , 2.5 , 2.5 ] , 4 ) ;
365
407
366
408
done ( ) ;
409
+
367
410
} , MODEBAR_DELAY ) ;
411
+
368
412
} , MODEBAR_DELAY ) ;
369
413
} ) ;
370
414
} ) ;
0 commit comments