@@ -60,6 +60,26 @@ describe('range selector defaults:', function() {
60
60
} ] ) ;
61
61
} ) ;
62
62
63
+ it ( 'should skip over non-object buttons' , function ( ) {
64
+ var containerIn = {
65
+ rangeselector : {
66
+ buttons : [ {
67
+ label : 'button 0'
68
+ } , null , {
69
+ label : 'button 2'
70
+ } , 'remove' , {
71
+ label : 'button 4'
72
+ } ]
73
+ }
74
+ } ;
75
+ var containerOut = { } ;
76
+
77
+ supply ( containerIn , containerOut ) ;
78
+
79
+ expect ( containerIn . rangeselector . buttons . length ) . toEqual ( 5 ) ;
80
+ expect ( containerOut . rangeselector . buttons . length ) . toEqual ( 3 ) ;
81
+ } ) ;
82
+
63
83
it ( 'should coerce all buttons present' , function ( ) {
64
84
var containerIn = {
65
85
rangeselector : {
@@ -421,6 +441,22 @@ describe('range selector interactions:', function() {
421
441
422
442
} ) ;
423
443
444
+ it ( 'should be able to remove button(s) on `relayout`' , function ( done ) {
445
+ var len = mockCopy . layout . xaxis . rangeselector . buttons . length ;
446
+
447
+ assertNodeCount ( '.button' , len ) ;
448
+
449
+ Plotly . relayout ( gd , 'xaxis.rangeselector.buttons[0]' , null ) . then ( function ( ) {
450
+ assertNodeCount ( '.button' , len - 1 ) ;
451
+
452
+ return Plotly . relayout ( gd , 'xaxis.rangeselector.buttons[1]' , 'remove' ) ;
453
+ } ) . then ( function ( ) {
454
+ assertNodeCount ( '.button' , len - 2 ) ;
455
+
456
+ done ( ) ;
457
+ } ) ;
458
+ } ) ;
459
+
424
460
it ( 'should update range and active button when clicked' , function ( ) {
425
461
var range0 = gd . layout . xaxis . range [ 0 ] ;
426
462
var buttons = d3 . selectAll ( '.button' ) . select ( 'rect' ) ;
@@ -482,5 +518,4 @@ describe('range selector interactions:', function() {
482
518
done ( ) ;
483
519
} ) ;
484
520
} ) ;
485
-
486
521
} ) ;
0 commit comments