11var RangeSelector = require ( '@src/components/rangeselector' ) ;
22var getUpdateObject = require ( '@src/components/rangeselector/get_update_object' ) ;
3- var constants = require ( '@src/components/rangeselector/constants' ) ;
43
54var d3 = require ( 'd3' ) ;
65var Plotly = require ( '@lib' ) ;
@@ -427,6 +426,16 @@ describe('range selector interactions:', function() {
427426 } ) ;
428427 }
429428
429+ function checkButtonColor ( bgColor , activeColor ) {
430+ d3 . selectAll ( '.button' ) . each ( function ( d ) {
431+ var rect = d3 . select ( this ) . select ( 'rect' ) ;
432+
433+ expect ( rect . style ( 'fill' ) ) . toEqual (
434+ d . isActive ? activeColor : bgColor
435+ ) ;
436+ } ) ;
437+ }
438+
430439 it ( 'should display the correct nodes' , function ( ) {
431440 assertNodeCount ( '.rangeselector' , 1 ) ;
432441 assertNodeCount ( '.button' , mockCopy . layout . xaxis . rangeselector . buttons . length ) ;
@@ -457,6 +466,22 @@ describe('range selector interactions:', function() {
457466 } ) ;
458467 } ) ;
459468
469+ it ( 'should be able to change its style on `relayout`' , function ( done ) {
470+ var prefix = 'xaxis.rangeselector.' ;
471+
472+ checkButtonColor ( 'rgb(238, 238, 238)' , 'rgb(212, 212, 212)' ) ;
473+
474+ Plotly . relayout ( gd , prefix + 'bgcolor' , 'red' ) . then ( function ( ) {
475+ checkButtonColor ( 'rgb(255, 0, 0)' , 'rgb(255, 128, 128)' ) ;
476+
477+ return Plotly . relayout ( gd , prefix + 'activecolor' , 'blue' ) ;
478+ } ) . then ( function ( ) {
479+ checkButtonColor ( 'rgb(255, 0, 0)' , 'rgb(0, 0, 255)' ) ;
480+
481+ done ( ) ;
482+ } ) ;
483+ } ) ;
484+
460485 it ( 'should update range and active button when clicked' , function ( ) {
461486 var range0 = gd . layout . xaxis . range [ 0 ] ;
462487 var buttons = d3 . selectAll ( '.button' ) . select ( 'rect' ) ;
@@ -482,7 +507,7 @@ describe('range selector interactions:', function() {
482507 var pos = getRectCenter ( button . node ( ) ) ;
483508
484509 var fillColor = Color . rgb ( gd . _fullLayout . xaxis . rangeselector . bgcolor ) ;
485- var activeColor = Color . rgb ( constants . activeColor ) ;
510+ var activeColor = ' rgb(212, 212, 212)' ;
486511
487512 expect ( button . style ( 'fill' ) ) . toEqual ( fillColor ) ;
488513
0 commit comments