@@ -2,10 +2,11 @@ var RangeSelector = require('@src/components/rangeselector');
22var getUpdateObject = require ( '@src/components/rangeselector/get_update_object' ) ;
33
44
5- describe ( 'range selector' , function ( ) {
5+
6+ describe ( '[range selector suite]' , function ( ) {
67 'use strict' ;
78
8- describe ( 'defaults' , function ( ) {
9+ describe ( 'defaults: ' , function ( ) {
910 var supplyLayoutDefaults = RangeSelector . supplyLayoutDefaults ;
1011
1112 it ( 'should set \'visible\' to false when no buttons are present' , function ( ) {
@@ -21,6 +22,24 @@ describe('range selector', function() {
2122 } ) ;
2223 } ) ;
2324
25+ it ( 'should coerce an empty button object' , function ( ) {
26+ var containerIn = {
27+ rangeselector : {
28+ buttons : [ { } ]
29+ }
30+ } ;
31+ var containerOut = { } ;
32+
33+ supplyLayoutDefaults ( containerIn , containerOut , { } ) ;
34+
35+ expect ( containerIn . rangeselector . buttons ) . toEqual ( [ { } ] ) ;
36+ expect ( containerOut . rangeselector . buttons ) . toEqual ( [ {
37+ step : 'month' ,
38+ stepmode : 'backward' ,
39+ count : 1
40+ } ] ) ;
41+ } ) ;
42+
2443 it ( 'should coerce all buttons present' , function ( ) {
2544 var containerIn = {
2645 rangeselector : {
@@ -43,6 +62,25 @@ describe('range selector', function() {
4362 ] ) ;
4463 } ) ;
4564
65+ it ( 'should not coerce \'stepmode\' and \'count\', for \'step\' all buttons' , function ( ) {
66+ var containerIn = {
67+ rangeselector : {
68+ buttons : [ {
69+ step : 'all' ,
70+ label : 'full range'
71+ } ]
72+ }
73+ } ;
74+ var containerOut = { } ;
75+
76+ supplyLayoutDefaults ( containerIn , containerOut , { } ) ;
77+
78+ expect ( containerOut . rangeselector . buttons ) . toEqual ( [ {
79+ step : 'all' ,
80+ label : 'full range'
81+ } ] ) ;
82+ } ) ;
83+
4684 } ) ;
4785
4886 describe ( 'getUpdateObject' , function ( ) {
0 commit comments