@@ -60,6 +60,26 @@ describe('range selector defaults:', function() {
6060 } ] ) ;
6161 } ) ;
6262
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+
6383 it ( 'should coerce all buttons present' , function ( ) {
6484 var containerIn = {
6585 rangeselector : {
@@ -421,6 +441,22 @@ describe('range selector interactions:', function() {
421441
422442 } ) ;
423443
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+
424460 it ( 'should update range and active button when clicked' , function ( ) {
425461 var range0 = gd . layout . xaxis . range [ 0 ] ;
426462 var buttons = d3 . selectAll ( '.button' ) . select ( 'rect' ) ;
@@ -482,5 +518,4 @@ describe('range selector interactions:', function() {
482518 done ( ) ;
483519 } ) ;
484520 } ) ;
485-
486521} ) ;
0 commit comments