@@ -229,7 +229,7 @@ describe('Test gl plot interactions', function() {
229229 } ) ;
230230
231231 describe ( 'gl3d modebar click handlers' , function ( ) {
232- var modeBar ;
232+ var modeBar , relayoutCallback ;
233233
234234 beforeEach ( function ( done ) {
235235 var mockData = [ {
@@ -245,8 +245,13 @@ describe('Test gl plot interactions', function() {
245245
246246 gd = createGraphDiv ( ) ;
247247 Plotly . plot ( gd , mockData , mockLayout ) . then ( function ( ) {
248+
248249 modeBar = gd . _fullLayout . _modeBar ;
249250
251+ relayoutCallback = jasmine . createSpy ( 'relayoutCallback' ) ;
252+
253+ gd . on ( 'plotly_relayout' , relayoutCallback ) ;
254+
250255 delay ( done ) ;
251256 } ) ;
252257 } ) ;
@@ -342,7 +347,26 @@ describe('Test gl plot interactions', function() {
342347 . toEqual ( { x : 2.5 , y : 2.5 , z : 2.5 } ) ;
343348
344349 selectButton ( modeBar , 'resetCameraDefault3d' ) . click ( ) ;
350+
345351 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+
346370 expect ( sceneLayout . camera . eye )
347371 . toEqual ( { x : 0.1 , y : 0.1 , z : 1 } , 'does not change the layout objects' ) ;
348372 expect ( scene . camera . eye )
@@ -353,7 +377,25 @@ describe('Test gl plot interactions', function() {
353377 . toBeCloseToArray ( [ 1.25 , 1.25 , 1.25 ] , 4 ) ;
354378
355379 selectButton ( modeBar , 'resetCameraLastSave3d' ) . click ( ) ;
380+
356381 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+
357399 expect ( sceneLayout . camera . eye )
358400 . toEqual ( { x : 0.1 , y : 0.1 , z : 1 } , 'does not change the layout objects' ) ;
359401 expect ( scene . camera . eye )
@@ -364,7 +406,9 @@ describe('Test gl plot interactions', function() {
364406 . toBeCloseToArray ( [ 2.5 , 2.5 , 2.5 ] , 4 ) ;
365407
366408 done ( ) ;
409+
367410 } , MODEBAR_DELAY ) ;
411+
368412 } , MODEBAR_DELAY ) ;
369413 } ) ;
370414 } ) ;
0 commit comments