From 4984ed85e54f442998a335db70618d6184fa397e Mon Sep 17 00:00:00 2001
From: yiminghe <yiminghe@gmail.com>
Date: Thu, 4 Aug 2016 19:53:55 +0800
Subject: 2.x :boom:

---
 tests/Header.spec.jsx | 208 +++++++++++++++++++++++++-------------------------
 1 file changed, 106 insertions(+), 102 deletions(-)

(limited to 'tests/Header.spec.jsx')

diff --git a/tests/Header.spec.jsx b/tests/Header.spec.jsx
index e992279..d5e570d 100644
--- a/tests/Header.spec.jsx
+++ b/tests/Header.spec.jsx
@@ -6,32 +6,21 @@ import TestUtils from 'react-addons-test-utils';
 const Simulate = TestUtils.Simulate;
 import expect from 'expect.js';
 import async from 'async';
-import {KeyCode} from 'rc-util';
-
-import DateTimeFormat from 'gregorian-calendar-format';
-import zhCn from 'gregorian-calendar/lib/locale/zh_CN';
-import TimePickerLocale from '../src/locale/zh_CN';
-
-function formatTime(time, formatter) {
-  return formatter.parse(time, {
-    locale: zhCn,
-    obeyCount: true,
-  });
-}
+import { KeyCode } from 'rc-util';
+import moment from 'moment';
 
 describe('Header', () => {
   let container;
 
   function renderPicker(props) {
     const showSecond = true;
-    const formatter = new DateTimeFormat('HH:mm:ss');
+    const format = 'HH:mm:ss';
 
     return ReactDOM.render(
       <TimePicker
-        formatter={formatter}
-        locale={TimePickerLocale}
+        format={format}
         showSecond={showSecond}
-        defaultValue={formatTime('01:02:03', formatter)}
+        defaultValue={moment('01:02:03', format)}
         {...props}
       />, container);
   }
@@ -50,25 +39,27 @@ describe('Header', () => {
     it('input correctly', (done) => {
       const picker = renderPicker();
       expect(picker.state.open).not.to.be.ok();
-      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
+      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker,
+        'rc-time-picker-input')[0];
       let header;
       async.series([(next) => {
         Simulate.click(input);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
+        header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance,
+          'rc-time-picker-panel-input')[0];
         expect(header).to.be.ok();
-        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
+        expect((header).value).to.be('01:02:03');
+        expect((input).value).to.be('01:02:03');
 
-        ReactDOM.findDOMNode(header).value = '12:34:56';
+        (header).value = '12:34:56';
         Simulate.change(header);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        expect(ReactDOM.findDOMNode(header).value).to.be('12:34:56');
-        expect(ReactDOM.findDOMNode(input).value).to.be('12:34:56');
+        expect((header).value).to.be('12:34:56');
+        expect((input).value).to.be('12:34:56');
 
         next();
       }], () => {
@@ -79,41 +70,43 @@ describe('Header', () => {
     it('carry correctly', (done) => {
       const picker = renderPicker();
       expect(picker.state.open).not.to.be.ok();
-      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
+      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker,
+        'rc-time-picker-input')[0];
       let header;
       async.series([(next) => {
         Simulate.click(input);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
+        header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance,
+          'rc-time-picker-panel-input')[0];
         expect(header).to.be.ok();
-        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
+        expect((header).value).to.be('01:02:03');
+        expect((input).value).to.be('01:02:03');
 
-        ReactDOM.findDOMNode(header).value = '33:44:55';
+        (header).value = '33:44:55';
         Simulate.change(header);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        expect(ReactDOM.findDOMNode(header).value).to.be('09:44:55');
-        expect(ReactDOM.findDOMNode(input).value).to.be('09:44:55');
+        expect((header).value).to.be('33:44:55');
+        expect((input).value).to.be('01:02:03');
 
-        ReactDOM.findDOMNode(header).value = '10:90:30';
+        (header).value = '10:90:30';
         Simulate.change(header);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        expect(ReactDOM.findDOMNode(header).value).to.be('11:30:30');
-        expect(ReactDOM.findDOMNode(input).value).to.be('11:30:30');
+        expect((header).value).to.be('10:90:30');
+        expect((input).value).to.be('01:02:03');
 
-        ReactDOM.findDOMNode(header).value = '34:56:78';
+        (header).value = '34:56:78';
         Simulate.change(header);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        expect(ReactDOM.findDOMNode(header).value).to.be('10:57:18');
-        expect(ReactDOM.findDOMNode(input).value).to.be('10:57:18');
+        expect((header).value).to.be('34:56:78');
+        expect((input).value).to.be('01:02:03');
 
         next();
       }], () => {
@@ -131,51 +124,53 @@ describe('Header', () => {
         },
       });
       expect(picker.state.open).not.to.be.ok();
-      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
+      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker,
+        'rc-time-picker-input')[0];
       let header;
       async.series([(next) => {
         Simulate.click(input);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
+        header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance,
+          'rc-time-picker-panel-input')[0];
         expect(header).to.be.ok();
-        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
+        expect((header).value).to.be('01:02:03');
+        expect((input).value).to.be('01:02:03');
 
-        ReactDOM.findDOMNode(header).value = '10:09:78';
+        (header).value = '10:09:78';
         Simulate.change(header);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid');
-        expect(ReactDOM.findDOMNode(header).value).to.be('10:09:78');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
+        expect((header).className).to.contain('rc-time-picker-panel-input-invalid');
+        expect((header).value).to.be('10:09:78');
+        expect((input).value).to.be('01:02:03');
 
-        ReactDOM.findDOMNode(header).value = '10:10:78';
+        (header).value = '10:10:78';
         Simulate.change(header);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        expect(ReactDOM.findDOMNode(header).value).to.be('10:11:18');
-        expect(ReactDOM.findDOMNode(input).value).to.be('10:11:18');
+        expect((header).value).to.be('10:10:78');
+        expect((input).value).to.be('01:02:03');
 
-        ReactDOM.findDOMNode(header).value = '10:09:19';
+        (header).value = '10:09:19';
         Simulate.change(header);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid');
-        expect(ReactDOM.findDOMNode(header).value).to.be('10:09:19');
-        expect(ReactDOM.findDOMNode(input).value).to.be('10:11:18');
+        expect((header).className).to.contain('rc-time-picker-panel-input-invalid');
+        expect((header).value).to.be('10:09:19');
+        expect((input).value).to.be('01:02:03');
 
-        ReactDOM.findDOMNode(header).value = '10:09:20';
+        (header).value = '10:09:20';
         Simulate.change(header);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        expect(ReactDOM.findDOMNode(header).value).to.be('10:09:20');
-        expect(ReactDOM.findDOMNode(input).value).to.be('10:09:20');
+        expect((header).value).to.be('10:09:20');
+        expect((input).value).to.be('10:09:20');
 
         next();
       }], () => {
@@ -194,51 +189,53 @@ describe('Header', () => {
         hideDisabledOptions: true,
       });
       expect(picker.state.open).not.to.be.ok();
-      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
+      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker,
+        'rc-time-picker-input')[0];
       let header;
       async.series([(next) => {
         Simulate.click(input);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
+        header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance,
+          'rc-time-picker-panel-input')[0];
         expect(header).to.be.ok();
-        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
+        expect((header).value).to.be('01:02:03');
+        expect((input).value).to.be('01:02:03');
 
-        ReactDOM.findDOMNode(header).value = '10:09:78';
+        (header).value = '10:09:78';
         Simulate.change(header);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid');
-        expect(ReactDOM.findDOMNode(header).value).to.be('10:09:78');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
+        expect((header).className).to.contain('rc-time-picker-panel-input-invalid');
+        expect((header).value).to.be('10:09:78');
+        expect((input).value).to.be('01:02:03');
 
-        ReactDOM.findDOMNode(header).value = '10:10:78';
+        (header).value = '10:10:78';
         Simulate.change(header);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        expect(ReactDOM.findDOMNode(header).value).to.be('10:11:18');
-        expect(ReactDOM.findDOMNode(input).value).to.be('10:11:18');
+        expect((header).value).to.be('10:10:78');
+        expect((input).value).to.be('01:02:03');
 
-        ReactDOM.findDOMNode(header).value = '10:09:19';
+        (header).value = '10:09:19';
         Simulate.change(header);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid');
-        expect(ReactDOM.findDOMNode(header).value).to.be('10:09:19');
-        expect(ReactDOM.findDOMNode(input).value).to.be('10:11:18');
+        expect((header).className).to.contain('rc-time-picker-panel-input-invalid');
+        expect((header).value).to.be('10:09:19');
+        expect((input).value).to.be('01:02:03');
 
-        ReactDOM.findDOMNode(header).value = '10:09:20';
+        (header).value = '10:09:20';
         Simulate.change(header);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        expect(ReactDOM.findDOMNode(header).value).to.be('10:09:20');
-        expect(ReactDOM.findDOMNode(input).value).to.be('10:09:20');
+        expect((header).value).to.be('10:09:20');
+        expect((input).value).to.be('10:09:20');
 
         next();
       }], () => {
@@ -249,44 +246,46 @@ describe('Header', () => {
     it('check correctly', (done) => {
       const picker = renderPicker();
       expect(picker.state.open).not.to.be.ok();
-      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
+      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker,
+        'rc-time-picker-input')[0];
       let header;
       async.series([(next) => {
         Simulate.click(input);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
+        header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance,
+          'rc-time-picker-panel-input')[0];
         expect(header).to.be.ok();
-        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
+        expect((header).value).to.be('01:02:03');
+        expect((input).value).to.be('01:02:03');
 
-        ReactDOM.findDOMNode(header).value = '3:34:56';
+        (header).value = '3:34:56';
         Simulate.change(header);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        expect(ReactDOM.findDOMNode(header).value).to.be('3:34:56');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
-        expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid');
+        expect((header).value).to.be('3:34:56');
+        expect((input).value).to.be('01:02:03');
+        expect((header).className).to.contain('rc-time-picker-panel-input-invalid');
 
-        ReactDOM.findDOMNode(header).value = '13:3:56';
+        (header).value = '13:3:56';
         Simulate.change(header);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        expect(ReactDOM.findDOMNode(header).value).to.be('13:3:56');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
-        expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid');
+        expect((header).value).to.be('13:3:56');
+        expect((input).value).to.be('01:02:03');
+        expect((header).className).to.contain('rc-time-picker-panel-input-invalid');
 
-        ReactDOM.findDOMNode(header).value = '13:34:5';
+        (header).value = '13:34:5';
         Simulate.change(header);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        expect(ReactDOM.findDOMNode(header).value).to.be('13:34:5');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
-        expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid');
+        expect((header).value).to.be('13:34:5');
+        expect((input).value).to.be('01:02:03');
+        expect((header).className).to.contain('rc-time-picker-panel-input-invalid');
         next();
       }], () => {
         done();
@@ -303,7 +302,8 @@ describe('Header', () => {
         },
       });
       expect(picker.state.open).not.to.be.ok();
-      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
+      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker,
+        'rc-time-picker-input')[0];
       let header;
       async.series([(next) => {
         expect(picker.state.open).to.be(false);
@@ -312,20 +312,22 @@ describe('Header', () => {
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
-        const clearButton = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-clear-btn')[0];
+        header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance,
+          'rc-time-picker-panel-input')[0];
+        const clearButton = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance,
+          'rc-time-picker-panel-clear-btn')[0];
         expect(header).to.be.ok();
         expect(clearButton).to.be.ok();
-        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
+        expect((header).value).to.be('01:02:03');
+        expect((input).value).to.be('01:02:03');
 
         Simulate.mouseDown(clearButton);
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(false);
         expect(change).to.be(null);
-        expect(ReactDOM.findDOMNode(header).value).to.be('');
-        expect(ReactDOM.findDOMNode(input).value).to.be('');
+        expect((header).value).to.be('');
+        expect((input).value).to.be('');
 
         next();
       }], () => {
@@ -336,7 +338,8 @@ describe('Header', () => {
     it('exit correctly', (done) => {
       const picker = renderPicker();
       expect(picker.state.open).not.to.be.ok();
-      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
+      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker,
+        'rc-time-picker-input')[0];
       let header;
       async.series([(next) => {
         expect(picker.state.open).to.be(false);
@@ -345,19 +348,20 @@ describe('Header', () => {
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(true);
-        header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
+        header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance,
+          'rc-time-picker-panel-input')[0];
         expect(header).to.be.ok();
-        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
+        expect((header).value).to.be('01:02:03');
+        expect((input).value).to.be('01:02:03');
 
-        Simulate.keyDown(ReactDOM.findDOMNode(header), {
+        Simulate.keyDown((header), {
           keyCode: KeyCode.ESC,
         });
         setTimeout(next, 100);
       }, (next) => {
         expect(picker.state.open).to.be(false);
-        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
+        expect((header).value).to.be('01:02:03');
+        expect((input).value).to.be('01:02:03');
 
         next();
       }], () => {
-- 
cgit v1.2.3

