@@ -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,16 @@ 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 ) . toHaveBeenCalled ( ) ; // initiator: resetCameraDefault3d
354
+ expect ( relayoutCallback ) . toHaveBeenCalledWith ( [
355
+ [ 1.25 , 1.25 , 1.25 ] ,
356
+ [ 0 , 0 , 0 ] ,
357
+ [ 0 , 0 , 1 ]
358
+ ] ) ;
359
+
346
360
expect ( sceneLayout . camera . eye )
347
361
. toEqual ( { x : 0.1 , y : 0.1 , z : 1 } , 'does not change the layout objects' ) ;
348
362
expect ( scene . camera . eye )
@@ -353,7 +367,16 @@ describe('Test gl plot interactions', function() {
353
367
. toBeCloseToArray ( [ 1.25 , 1.25 , 1.25 ] , 4 ) ;
354
368
355
369
selectButton ( modeBar , 'resetCameraLastSave3d' ) . click ( ) ;
370
+
356
371
setTimeout ( function ( ) {
372
+
373
+ expect ( relayoutCallback ) . toHaveBeenCalled ( ) ; // initiator: resetCameraLastSave3d
374
+ expect ( relayoutCallback ) . toHaveBeenCalledWith ( [
375
+ [ 1.25 , 1.25 , 1.25 ] ,
376
+ [ 0 , 0 , 0 ] ,
377
+ [ 0 , 0 , 1 ]
378
+ ] ) ; // looks like there's no real saved data so it reverts to default
379
+
357
380
expect ( sceneLayout . camera . eye )
358
381
. toEqual ( { x : 0.1 , y : 0.1 , z : 1 } , 'does not change the layout objects' ) ;
359
382
expect ( scene . camera . eye )
@@ -364,7 +387,9 @@ describe('Test gl plot interactions', function() {
364
387
. toBeCloseToArray ( [ 2.5 , 2.5 , 2.5 ] , 4 ) ;
365
388
366
389
done ( ) ;
390
+
367
391
} , MODEBAR_DELAY ) ;
392
+
368
393
} , MODEBAR_DELAY ) ;
369
394
} ) ;
370
395
} ) ;
0 commit comments