Skip to content

Commit 8b4340e

Browse files
committed
don't coerce 'stepmode' and 'count' when 'step' is set to 'all'
1 parent f11aef9 commit 8b4340e

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

src/components/rangeselector/defaults.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@ function buttonsDefaults(containerIn, containerOut) {
5555
buttonIn = buttonsIn[i];
5656
buttonOut = {};
5757

58-
coerce('step');
59-
coerce('stepmode');
60-
coerce('count');
58+
var step = coerce('step');
59+
if(step !== 'all') {
60+
coerce('stepmode');
61+
coerce('count');
62+
}
63+
6164
coerce('label');
6265

6366
buttonsOut.push(buttonOut);

test/jasmine/tests/range_selector_test.js

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ var RangeSelector = require('@src/components/rangeselector');
22
var 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

Comments
 (0)