diff options
Diffstat (limited to 'tests/Select.spec.jsx')
-rw-r--r-- | tests/Select.spec.jsx | 176 |
1 files changed, 176 insertions, 0 deletions
diff --git a/tests/Select.spec.jsx b/tests/Select.spec.jsx index e6d32dd..fd2ec32 100644 --- a/tests/Select.spec.jsx +++ b/tests/Select.spec.jsx | |||
@@ -315,4 +315,180 @@ describe('Select', () => { | |||
315 | }); | 315 | }); |
316 | }); | 316 | }); |
317 | }); | 317 | }); |
318 | |||
319 | |||
320 | describe('select in 12 hours mode', () => { | ||
321 | it('renders correctly', (done) => { | ||
322 | const picker = renderPicker({ | ||
323 | use12Hours: true, | ||
324 | defaultValue: moment().hour(14).minute(0).second(0), | ||
325 | showSecond: false, | ||
326 | format: undefined, | ||
327 | }); | ||
328 | expect(picker.state.open).not.to.be.ok(); | ||
329 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, | ||
330 | 'rc-time-picker-input')[0]; | ||
331 | let selector; | ||
332 | async.series([(next) => { | ||
333 | expect(picker.state.open).to.be(false); | ||
334 | |||
335 | Simulate.click(input); | ||
336 | setTimeout(next, 100); | ||
337 | }, (next) => { | ||
338 | expect(picker.state.open).to.be(true); | ||
339 | selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, | ||
340 | 'rc-time-picker-panel-select'); | ||
341 | expect((input).value).to.be('2:00 pm'); | ||
342 | |||
343 | setTimeout(next, 100); | ||
344 | }, (next) => { | ||
345 | expect(selector.length).to.be(3); | ||
346 | |||
347 | next(); | ||
348 | }], () => { | ||
349 | done(); | ||
350 | }); | ||
351 | }); | ||
352 | |||
353 | |||
354 | it('renders 12am correctly', (done) => { | ||
355 | const picker = renderPicker({ | ||
356 | use12Hours: true, | ||
357 | defaultValue: moment().hour(0).minute(0).second(0), | ||
358 | showSecond: false, | ||
359 | format: undefined, | ||
360 | }); | ||
361 | expect(picker.state.open).not.to.be.ok(); | ||
362 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, | ||
363 | 'rc-time-picker-input')[0]; | ||
364 | let selector; | ||
365 | async.series([(next) => { | ||
366 | expect(picker.state.open).to.be(false); | ||
367 | |||
368 | Simulate.click(input); | ||
369 | setTimeout(next, 100); | ||
370 | }, (next) => { | ||
371 | expect(picker.state.open).to.be(true); | ||
372 | selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, | ||
373 | 'rc-time-picker-panel-select'); | ||
374 | setTimeout(next, 100); | ||
375 | }, (next) => { | ||
376 | expect(selector.length).to.be(3); | ||
377 | |||
378 | next(); | ||
379 | }], () => { | ||
380 | done(); | ||
381 | }); | ||
382 | }); | ||
383 | |||
384 | |||
385 | it('renders 5am correctly', (done) => { | ||
386 | const picker = renderPicker({ | ||
387 | use12Hours: true, | ||
388 | defaultValue: moment().hour(0).minute(0).second(0), | ||
389 | showSecond: false, | ||
390 | format: undefined, | ||
391 | }); | ||
392 | expect(picker.state.open).not.to.be.ok(); | ||
393 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, | ||
394 | 'rc-time-picker-input')[0]; | ||
395 | let selector; | ||
396 | async.series([(next) => { | ||
397 | expect(picker.state.open).to.be(false); | ||
398 | |||
399 | Simulate.click(input); | ||
400 | setTimeout(next, 100); | ||
401 | }, (next) => { | ||
402 | expect(picker.state.open).to.be(true); | ||
403 | selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, | ||
404 | 'rc-time-picker-panel-select')[0]; | ||
405 | expect((input).value).to.be('12:00 am'); | ||
406 | const option = selector.getElementsByTagName('li')[3]; | ||
407 | Simulate.click(option); | ||
408 | setTimeout(next, 100); | ||
409 | }, (next) => { | ||
410 | expect((input).value).to.be('3:00 am'); | ||
411 | next(); | ||
412 | }], () => { | ||
413 | done(); | ||
414 | }); | ||
415 | }); | ||
416 | |||
417 | |||
418 | it('renders 12am/pm correctly', (done) => { | ||
419 | const picker = renderPicker({ | ||
420 | use12Hours: true, | ||
421 | defaultValue: moment().hour(0).minute(0).second(0), | ||
422 | showSecond: false, | ||
423 | format: undefined, | ||
424 | }); | ||
425 | expect(picker.state.open).not.to.be.ok(); | ||
426 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, | ||
427 | 'rc-time-picker-input')[0]; | ||
428 | let selector; | ||
429 | async.series([(next) => { | ||
430 | expect(picker.state.open).to.be(false); | ||
431 | |||
432 | Simulate.click(input); | ||
433 | setTimeout(next, 100); | ||
434 | }, (next) => { | ||
435 | expect(picker.state.open).to.be(true); | ||
436 | selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, | ||
437 | 'rc-time-picker-panel-select')[2]; | ||
438 | expect((input).value).to.be('12:00 am'); | ||
439 | const option = selector.getElementsByTagName('li')[1]; | ||
440 | Simulate.click(option); | ||
441 | setTimeout(next, 200); | ||
442 | }, (next) => { | ||
443 | expect((input).value).to.be('12:00 pm'); | ||
444 | next(); | ||
445 | }, (next) => { | ||
446 | Simulate.click(selector.getElementsByTagName('li')[0]); | ||
447 | setTimeout(next, 200); | ||
448 | }, (next) => { | ||
449 | expect((input).value).to.be('12:00 am'); | ||
450 | next(); | ||
451 | }], () => { | ||
452 | done(); | ||
453 | }); | ||
454 | }); | ||
455 | |||
456 | it('renders uppercase AM correctly', (done) => { | ||
457 | const picker = renderPicker({ | ||
458 | use12Hours: true, | ||
459 | defaultValue: moment().hour(0).minute(0).second(0), | ||
460 | showSecond: false, | ||
461 | format: 'h:mm A', | ||
462 | }); | ||
463 | expect(picker.state.open).not.to.be.ok(); | ||
464 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, | ||
465 | 'rc-time-picker-input')[0]; | ||
466 | let selector; | ||
467 | async.series([(next) => { | ||
468 | expect(picker.state.open).to.be(false); | ||
469 | |||
470 | Simulate.click(input); | ||
471 | setTimeout(next, 100); | ||
472 | }, (next) => { | ||
473 | expect(picker.state.open).to.be(true); | ||
474 | selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, | ||
475 | 'rc-time-picker-panel-select')[2]; | ||
476 | expect((input).value).to.be('12:00 AM'); | ||
477 | const option = selector.getElementsByTagName('li')[1]; | ||
478 | Simulate.click(option); | ||
479 | setTimeout(next, 200); | ||
480 | }, (next) => { | ||
481 | expect((input).value).to.be('12:00 PM'); | ||
482 | next(); | ||
483 | }, (next) => { | ||
484 | Simulate.click(selector.getElementsByTagName('li')[0]); | ||
485 | setTimeout(next, 200); | ||
486 | }, (next) => { | ||
487 | expect((input).value).to.be('12:00 AM'); | ||
488 | next(); | ||
489 | }], () => { | ||
490 | done(); | ||
491 | }); | ||
492 | }); | ||
493 | }); | ||
318 | }); | 494 | }); |