aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Select.spec.jsx
diff options
context:
space:
mode:
author偏右 <afc163@gmail.com>2017-10-22 16:53:32 +0800
committerGitHub <noreply@github.com>2017-10-22 16:53:32 +0800
commit81cdb7024e669b0c2c8cc1911776d47683e3500d (patch)
treeeb9bf3c0b111087cbf868ec434baba96b539be5d /tests/Select.spec.jsx
parent8c22015207c1927b27c90b4bf0f40dc9c56d2fe5 (diff)
parentf0ac29c61df164ab3e867ef86137faa13d85a87f (diff)
downloadtime-picker-81cdb7024e669b0c2c8cc1911776d47683e3500d.tar.gz
time-picker-81cdb7024e669b0c2c8cc1911776d47683e3500d.tar.zst
time-picker-81cdb7024e669b0c2c8cc1911776d47683e3500d.zip
Merge pull request #72 from marekpiechut/picker-step
Add hourStep, minuteStep and secondStep props to control intervals in picker
Diffstat (limited to 'tests/Select.spec.jsx')
-rw-r--r--tests/Select.spec.jsx34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/Select.spec.jsx b/tests/Select.spec.jsx
index b2c111d..2a15e7c 100644
--- a/tests/Select.spec.jsx
+++ b/tests/Select.spec.jsx
@@ -7,6 +7,8 @@ import expect from 'expect.js';
7import async from 'async'; 7import async from 'async';
8import moment from 'moment'; 8import moment from 'moment';
9 9
10const map = (arr, fn) => Array.prototype.map.call(arr, fn);
11
10describe('Select', () => { 12describe('Select', () => {
11 let container; 13 let container;
12 14
@@ -59,6 +61,38 @@ describe('Select', () => {
59 done(); 61 done();
60 }); 62 });
61 }); 63 });
64
65 it('shows only numbers according to step props', (done) => {
66 const picker = renderPicker({
67 hourStep: 5,
68 minuteStep: 15,
69 secondStep: 21,
70 });
71 const input = TestUtils.scryRenderedDOMComponentsWithClass(picker,
72 'rc-time-picker-input')[0];
73 async.series([(next) => {
74 Simulate.click(input);
75 setTimeout(next, 100);
76 }, (next) => {
77 const selectors = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance,
78 'rc-time-picker-panel-select');
79
80 const hourSelector = selectors[0];
81 const minuteSelector = selectors[1];
82 const secondSelector = selectors[2];
83
84 const hours = map(hourSelector.getElementsByTagName('li'), (li) => li.innerHTML);
85 expect(hours).to.eql(['00', '05', '10', '15', '20']);
86
87 const minutes = map(minuteSelector.getElementsByTagName('li'), (li) => li.innerHTML);
88 expect(minutes).to.eql(['00', '15', '30', '45']);
89
90 const seconds = map(secondSelector.getElementsByTagName('li'), (li) => li.innerHTML);
91 expect(seconds).to.eql(['00', '21', '42']);
92
93 next();
94 }], done);
95 });
62 }); 96 });
63 97
64 describe('select number', () => { 98 describe('select number', () => {