aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Select.spec.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Select.spec.jsx')
-rw-r--r--tests/Select.spec.jsx71
1 files changed, 44 insertions, 27 deletions
diff --git a/tests/Select.spec.jsx b/tests/Select.spec.jsx
index 6dd7796..f7717c7 100644
--- a/tests/Select.spec.jsx
+++ b/tests/Select.spec.jsx
@@ -29,7 +29,7 @@ describe('Select', () => {
29 formatter={formatter} 29 formatter={formatter}
30 locale={TimePickerLocale} 30 locale={TimePickerLocale}
31 showSecond={showSecond} 31 showSecond={showSecond}
32 defaultValue={formatTime('01:02:03', formatter)} 32 defaultValue={formatTime('01:02:04', formatter)}
33 {...props} 33 {...props}
34 />, container); 34 />, container);
35 } 35 }
@@ -90,8 +90,8 @@ describe('Select', () => {
90 expect(picker.state.open).to.be(true); 90 expect(picker.state.open).to.be(true);
91 header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0]; 91 header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
92 expect(header).to.be.ok(); 92 expect(header).to.be.ok();
93 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); 93 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:04');
94 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); 94 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:04');
95 95
96 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[0]; 96 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[0];
97 const option = selector.getElementsByTagName('li')[19]; 97 const option = selector.getElementsByTagName('li')[19];
@@ -100,8 +100,8 @@ describe('Select', () => {
100 }, (next) => { 100 }, (next) => {
101 expect(change).to.be.ok(); 101 expect(change).to.be.ok();
102 expect(change.getHourOfDay()).to.be(19); 102 expect(change.getHourOfDay()).to.be(19);
103 expect(ReactDOM.findDOMNode(header).value).to.be('19:02:03'); 103 expect(ReactDOM.findDOMNode(header).value).to.be('19:02:04');
104 expect(ReactDOM.findDOMNode(input).value).to.be('19:02:03'); 104 expect(ReactDOM.findDOMNode(input).value).to.be('19:02:04');
105 expect(picker.state.open).to.be.ok(); 105 expect(picker.state.open).to.be.ok();
106 106
107 next(); 107 next();
@@ -129,8 +129,8 @@ describe('Select', () => {
129 expect(picker.state.open).to.be(true); 129 expect(picker.state.open).to.be(true);
130 header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0]; 130 header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
131 expect(header).to.be.ok(); 131 expect(header).to.be.ok();
132 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); 132 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:04');
133 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); 133 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:04');
134 134
135 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[1]; 135 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[1];
136 const option = selector.getElementsByTagName('li')[19]; 136 const option = selector.getElementsByTagName('li')[19];
@@ -139,8 +139,8 @@ describe('Select', () => {
139 }, (next) => { 139 }, (next) => {
140 expect(change).to.be.ok(); 140 expect(change).to.be.ok();
141 expect(change.getMinutes()).to.be(19); 141 expect(change.getMinutes()).to.be(19);
142 expect(ReactDOM.findDOMNode(header).value).to.be('01:19:03'); 142 expect(ReactDOM.findDOMNode(header).value).to.be('01:19:04');
143 expect(ReactDOM.findDOMNode(input).value).to.be('01:19:03'); 143 expect(ReactDOM.findDOMNode(input).value).to.be('01:19:04');
144 expect(picker.state.open).to.be.ok(); 144 expect(picker.state.open).to.be.ok();
145 145
146 next(); 146 next();
@@ -168,8 +168,8 @@ describe('Select', () => {
168 expect(picker.state.open).to.be(true); 168 expect(picker.state.open).to.be(true);
169 header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0]; 169 header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
170 expect(header).to.be.ok(); 170 expect(header).to.be.ok();
171 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); 171 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:04');
172 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); 172 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:04');
173 173
174 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[2]; 174 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[2];
175 const option = selector.getElementsByTagName('li')[19]; 175 const option = selector.getElementsByTagName('li')[19];
@@ -194,7 +194,12 @@ describe('Select', () => {
194 onChange(v) { 194 onChange(v) {
195 change = v; 195 change = v;
196 }, 196 },
197 disabledMinutes: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22] 197 disabledMinutes(h) {
198 return [h];
199 },
200 disabledSeconds(h, m) {
201 return [h + m % 60];
202 },
198 }); 203 });
199 expect(picker.state.open).not.to.be.ok(); 204 expect(picker.state.open).not.to.be.ok();
200 const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0]; 205 const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
@@ -208,17 +213,27 @@ describe('Select', () => {
208 expect(picker.state.open).to.be(true); 213 expect(picker.state.open).to.be(true);
209 header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0]; 214 header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
210 expect(header).to.be.ok(); 215 expect(header).to.be.ok();
211 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); 216 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:04');
212 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); 217 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:04');
213 218
214 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[1]; 219 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[1];
215 const option = selector.getElementsByTagName('li')[6]; 220 const option = selector.getElementsByTagName('li')[1];
216 Simulate.click(option); 221 Simulate.click(option);
217 setTimeout(next, 100); 222 setTimeout(next, 100);
218 }, (next) => { 223 }, (next) => {
219 expect(change).not.to.be.ok(); 224 expect(change).not.to.be.ok();
220 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); 225 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:04');
221 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); 226 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:04');
227 expect(picker.state.open).to.be.ok();
228
229 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[2];
230 const option = selector.getElementsByTagName('li')[3];
231 Simulate.click(option);
232 setTimeout(next, 100);
233 }, (next) => {
234 expect(change).not.to.be.ok();
235 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:04');
236 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:04');
222 expect(picker.state.open).to.be.ok(); 237 expect(picker.state.open).to.be.ok();
223 238
224 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[1]; 239 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[1];
@@ -228,8 +243,8 @@ describe('Select', () => {
228 }, (next) => { 243 }, (next) => {
229 expect(change).to.be.ok(); 244 expect(change).to.be.ok();
230 expect(change.getMinutes()).to.be(7); 245 expect(change.getMinutes()).to.be(7);
231 expect(ReactDOM.findDOMNode(header).value).to.be('01:07:03'); 246 expect(ReactDOM.findDOMNode(header).value).to.be('01:07:04');
232 expect(ReactDOM.findDOMNode(input).value).to.be('01:07:03'); 247 expect(ReactDOM.findDOMNode(input).value).to.be('01:07:04');
233 expect(picker.state.open).to.be.ok(); 248 expect(picker.state.open).to.be.ok();
234 249
235 next(); 250 next();
@@ -244,8 +259,10 @@ describe('Select', () => {
244 onChange(v) { 259 onChange(v) {
245 change = v; 260 change = v;
246 }, 261 },
247 disabledHours: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23], 262 disabledHours() {
248 hideDisabledOptions: true 263 return [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23];
264 },
265 hideDisabledOptions: true,
249 }); 266 });
250 expect(picker.state.open).not.to.be.ok(); 267 expect(picker.state.open).not.to.be.ok();
251 const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0]; 268 const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
@@ -259,8 +276,8 @@ describe('Select', () => {
259 expect(picker.state.open).to.be(true); 276 expect(picker.state.open).to.be(true);
260 header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0]; 277 header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
261 expect(header).to.be.ok(); 278 expect(header).to.be.ok();
262 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); 279 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:04');
263 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); 280 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:04');
264 281
265 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[0]; 282 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[0];
266 const option = selector.getElementsByTagName('li')[3]; 283 const option = selector.getElementsByTagName('li')[3];
@@ -269,8 +286,8 @@ describe('Select', () => {
269 }, (next) => { 286 }, (next) => {
270 expect(change).to.be.ok(); 287 expect(change).to.be.ok();
271 expect(change.getHourOfDay()).to.be(6); 288 expect(change.getHourOfDay()).to.be(6);
272 expect(ReactDOM.findDOMNode(header).value).to.be('06:02:03'); 289 expect(ReactDOM.findDOMNode(header).value).to.be('06:02:04');
273 expect(ReactDOM.findDOMNode(input).value).to.be('06:02:03'); 290 expect(ReactDOM.findDOMNode(input).value).to.be('06:02:04');
274 expect(picker.state.open).to.be.ok(); 291 expect(picker.state.open).to.be.ok();
275 292
276 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[0]; 293 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[0];
@@ -280,8 +297,8 @@ describe('Select', () => {
280 }, (next) => { 297 }, (next) => {
281 expect(change).to.be.ok(); 298 expect(change).to.be.ok();
282 expect(change.getHourOfDay()).to.be(8); 299 expect(change.getHourOfDay()).to.be(8);
283 expect(ReactDOM.findDOMNode(header).value).to.be('08:02:03'); 300 expect(ReactDOM.findDOMNode(header).value).to.be('08:02:04');
284 expect(ReactDOM.findDOMNode(input).value).to.be('08:02:03'); 301 expect(ReactDOM.findDOMNode(input).value).to.be('08:02:04');
285 expect(picker.state.open).to.be.ok(); 302 expect(picker.state.open).to.be.ok();
286 303
287 next(); 304 next();