@@ -111,6 +111,7 @@ describe('update menus defaults', function() {
111
111
expect ( layoutOut . updatemenus [ 0 ] . buttons [ 0 ] ) . toEqual ( {
112
112
method : 'relayout' ,
113
113
args : [ 'title' , 'Hello World' ] ,
114
+ execute : true ,
114
115
label : '' ,
115
116
_index : 1
116
117
} ) ;
@@ -135,6 +136,7 @@ describe('update menus defaults', function() {
135
136
expect ( layoutOut . updatemenus [ 0 ] . buttons [ 0 ] ) . toEqual ( {
136
137
method : 'relayout' ,
137
138
args : [ 'title' , 'Hello World' ] ,
139
+ execute : true ,
138
140
label : '' ,
139
141
_index : 1
140
142
} ) ;
@@ -156,11 +158,13 @@ describe('update menus defaults', function() {
156
158
expect ( layoutOut . updatemenus [ 0 ] . buttons [ 0 ] ) . toEqual ( {
157
159
method : 'skip' ,
158
160
label : '' ,
161
+ execute : true ,
159
162
_index : 0
160
163
} , {
161
164
method : 'skip' ,
162
165
args : [ 'title' , 'Hello World' ] ,
163
166
label : '' ,
167
+ execute : true ,
164
168
_index : 1
165
169
} ) ;
166
170
} ) ;
@@ -444,6 +448,32 @@ describe('update menus interactions', function() {
444
448
} ) ;
445
449
} ) ;
446
450
451
+ it ( 'should execute the API command when execute = true' , function ( done ) {
452
+ expect ( gd . data [ 0 ] . line . color ) . toEqual ( 'blue' ) ;
453
+
454
+ click ( selectHeader ( 0 ) ) . then ( function ( ) {
455
+ return click ( selectButton ( 2 ) ) ;
456
+ } ) . then ( function ( ) {
457
+ // Has been changed:
458
+ expect ( gd . data [ 0 ] . line . color ) . toEqual ( 'green' ) ;
459
+ } ) . catch ( fail ) . then ( done ) ;
460
+ } ) ;
461
+
462
+ it ( 'should not execute the API command when execute = false' , function ( done ) {
463
+ // This test is identical to the one above, except that it disables
464
+ // the command by setting execute = false first:
465
+ expect ( gd . data [ 0 ] . line . color ) . toEqual ( 'blue' ) ;
466
+
467
+ Plotly . relayout ( gd , 'updatemenus[0].buttons[2].execute' , false ) . then ( function ( ) {
468
+ return click ( selectHeader ( 0 ) ) ;
469
+ } ) . then ( function ( ) {
470
+ return click ( selectButton ( 2 ) ) ;
471
+ } ) . then ( function ( ) {
472
+ // Is unchanged:
473
+ expect ( gd . data [ 0 ] . line . color ) . toEqual ( 'blue' ) ;
474
+ } ) . catch ( fail ) . then ( done ) ;
475
+ } ) ;
476
+
447
477
it ( 'should emit an event on button click' , function ( done ) {
448
478
var clickCnt = 0 ;
449
479
var data = [ ] ;
0 commit comments