diff options
Diffstat (limited to 'tests/Header.spec.jsx')
-rw-r--r-- | tests/Header.spec.jsx | 208 |
1 files changed, 106 insertions, 102 deletions
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'; | |||
6 | const Simulate = TestUtils.Simulate; | 6 | const Simulate = TestUtils.Simulate; |
7 | import expect from 'expect.js'; | 7 | import expect from 'expect.js'; |
8 | import async from 'async'; | 8 | import async from 'async'; |
9 | import {KeyCode} from 'rc-util'; | 9 | import { KeyCode } from 'rc-util'; |
10 | 10 | import moment from 'moment'; | |
11 | import DateTimeFormat from 'gregorian-calendar-format'; | ||
12 | import zhCn from 'gregorian-calendar/lib/locale/zh_CN'; | ||
13 | import TimePickerLocale from '../src/locale/zh_CN'; | ||
14 | |||
15 | function formatTime(time, formatter) { | ||
16 | return formatter.parse(time, { | ||
17 | locale: zhCn, | ||
18 | obeyCount: true, | ||
19 | }); | ||
20 | } | ||
21 | 11 | ||
22 | describe('Header', () => { | 12 | describe('Header', () => { |
23 | let container; | 13 | let container; |
24 | 14 | ||
25 | function renderPicker(props) { | 15 | function renderPicker(props) { |
26 | const showSecond = true; | 16 | const showSecond = true; |
27 | const formatter = new DateTimeFormat('HH:mm:ss'); | 17 | const format = 'HH:mm:ss'; |
28 | 18 | ||
29 | return ReactDOM.render( | 19 | return ReactDOM.render( |
30 | <TimePicker | 20 | <TimePicker |
31 | formatter={formatter} | 21 | format={format} |
32 | locale={TimePickerLocale} | ||
33 | showSecond={showSecond} | 22 | showSecond={showSecond} |
34 | defaultValue={formatTime('01:02:03', formatter)} | 23 | defaultValue={moment('01:02:03', format)} |
35 | {...props} | 24 | {...props} |
36 | />, container); | 25 | />, container); |
37 | } | 26 | } |
@@ -50,25 +39,27 @@ describe('Header', () => { | |||
50 | it('input correctly', (done) => { | 39 | it('input correctly', (done) => { |
51 | const picker = renderPicker(); | 40 | const picker = renderPicker(); |
52 | expect(picker.state.open).not.to.be.ok(); | 41 | expect(picker.state.open).not.to.be.ok(); |
53 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0]; | 42 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, |
43 | 'rc-time-picker-input')[0]; | ||
54 | let header; | 44 | let header; |
55 | async.series([(next) => { | 45 | async.series([(next) => { |
56 | Simulate.click(input); | 46 | Simulate.click(input); |
57 | setTimeout(next, 100); | 47 | setTimeout(next, 100); |
58 | }, (next) => { | 48 | }, (next) => { |
59 | expect(picker.state.open).to.be(true); | 49 | expect(picker.state.open).to.be(true); |
60 | header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0]; | 50 | header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, |
51 | 'rc-time-picker-panel-input')[0]; | ||
61 | expect(header).to.be.ok(); | 52 | expect(header).to.be.ok(); |
62 | expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); | 53 | expect((header).value).to.be('01:02:03'); |
63 | expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); | 54 | expect((input).value).to.be('01:02:03'); |
64 | 55 | ||
65 | ReactDOM.findDOMNode(header).value = '12:34:56'; | 56 | (header).value = '12:34:56'; |
66 | Simulate.change(header); | 57 | Simulate.change(header); |
67 | setTimeout(next, 100); | 58 | setTimeout(next, 100); |
68 | }, (next) => { | 59 | }, (next) => { |
69 | expect(picker.state.open).to.be(true); | 60 | expect(picker.state.open).to.be(true); |
70 | expect(ReactDOM.findDOMNode(header).value).to.be('12:34:56'); | 61 | expect((header).value).to.be('12:34:56'); |
71 | expect(ReactDOM.findDOMNode(input).value).to.be('12:34:56'); | 62 | expect((input).value).to.be('12:34:56'); |
72 | 63 | ||
73 | next(); | 64 | next(); |
74 | }], () => { | 65 | }], () => { |
@@ -79,41 +70,43 @@ describe('Header', () => { | |||
79 | it('carry correctly', (done) => { | 70 | it('carry correctly', (done) => { |
80 | const picker = renderPicker(); | 71 | const picker = renderPicker(); |
81 | expect(picker.state.open).not.to.be.ok(); | 72 | expect(picker.state.open).not.to.be.ok(); |
82 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0]; | 73 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, |
74 | 'rc-time-picker-input')[0]; | ||
83 | let header; | 75 | let header; |
84 | async.series([(next) => { | 76 | async.series([(next) => { |
85 | Simulate.click(input); | 77 | Simulate.click(input); |
86 | setTimeout(next, 100); | 78 | setTimeout(next, 100); |
87 | }, (next) => { | 79 | }, (next) => { |
88 | expect(picker.state.open).to.be(true); | 80 | expect(picker.state.open).to.be(true); |
89 | header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0]; | 81 | header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, |
82 | 'rc-time-picker-panel-input')[0]; | ||
90 | expect(header).to.be.ok(); | 83 | expect(header).to.be.ok(); |
91 | expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); | 84 | expect((header).value).to.be('01:02:03'); |
92 | expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); | 85 | expect((input).value).to.be('01:02:03'); |
93 | 86 | ||
94 | ReactDOM.findDOMNode(header).value = '33:44:55'; | 87 | (header).value = '33:44:55'; |
95 | Simulate.change(header); | 88 | Simulate.change(header); |
96 | setTimeout(next, 100); | 89 | setTimeout(next, 100); |
97 | }, (next) => { | 90 | }, (next) => { |
98 | expect(picker.state.open).to.be(true); | 91 | expect(picker.state.open).to.be(true); |
99 | expect(ReactDOM.findDOMNode(header).value).to.be('09:44:55'); | 92 | expect((header).value).to.be('33:44:55'); |
100 | expect(ReactDOM.findDOMNode(input).value).to.be('09:44:55'); | 93 | expect((input).value).to.be('01:02:03'); |
101 | 94 | ||
102 | ReactDOM.findDOMNode(header).value = '10:90:30'; | 95 | (header).value = '10:90:30'; |
103 | Simulate.change(header); | 96 | Simulate.change(header); |
104 | setTimeout(next, 100); | 97 | setTimeout(next, 100); |
105 | }, (next) => { | 98 | }, (next) => { |
106 | expect(picker.state.open).to.be(true); | 99 | expect(picker.state.open).to.be(true); |
107 | expect(ReactDOM.findDOMNode(header).value).to.be('11:30:30'); | 100 | expect((header).value).to.be('10:90:30'); |
108 | expect(ReactDOM.findDOMNode(input).value).to.be('11:30:30'); | 101 | expect((input).value).to.be('01:02:03'); |
109 | 102 | ||
110 | ReactDOM.findDOMNode(header).value = '34:56:78'; | 103 | (header).value = '34:56:78'; |
111 | Simulate.change(header); | 104 | Simulate.change(header); |
112 | setTimeout(next, 100); | 105 | setTimeout(next, 100); |
113 | }, (next) => { | 106 | }, (next) => { |
114 | expect(picker.state.open).to.be(true); | 107 | expect(picker.state.open).to.be(true); |
115 | expect(ReactDOM.findDOMNode(header).value).to.be('10:57:18'); | 108 | expect((header).value).to.be('34:56:78'); |
116 | expect(ReactDOM.findDOMNode(input).value).to.be('10:57:18'); | 109 | expect((input).value).to.be('01:02:03'); |
117 | 110 | ||
118 | next(); | 111 | next(); |
119 | }], () => { | 112 | }], () => { |
@@ -131,51 +124,53 @@ describe('Header', () => { | |||
131 | }, | 124 | }, |
132 | }); | 125 | }); |
133 | expect(picker.state.open).not.to.be.ok(); | 126 | expect(picker.state.open).not.to.be.ok(); |
134 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0]; | 127 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, |
128 | 'rc-time-picker-input')[0]; | ||
135 | let header; | 129 | let header; |
136 | async.series([(next) => { | 130 | async.series([(next) => { |
137 | Simulate.click(input); | 131 | Simulate.click(input); |
138 | setTimeout(next, 100); | 132 | setTimeout(next, 100); |
139 | }, (next) => { | 133 | }, (next) => { |
140 | expect(picker.state.open).to.be(true); | 134 | expect(picker.state.open).to.be(true); |
141 | header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0]; | 135 | header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, |
136 | 'rc-time-picker-panel-input')[0]; | ||
142 | expect(header).to.be.ok(); | 137 | expect(header).to.be.ok(); |
143 | expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); | 138 | expect((header).value).to.be('01:02:03'); |
144 | expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); | 139 | expect((input).value).to.be('01:02:03'); |
145 | 140 | ||
146 | ReactDOM.findDOMNode(header).value = '10:09:78'; | 141 | (header).value = '10:09:78'; |
147 | Simulate.change(header); | 142 | Simulate.change(header); |
148 | setTimeout(next, 100); | 143 | setTimeout(next, 100); |
149 | }, (next) => { | 144 | }, (next) => { |
150 | expect(picker.state.open).to.be(true); | 145 | expect(picker.state.open).to.be(true); |
151 | expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid'); | 146 | expect((header).className).to.contain('rc-time-picker-panel-input-invalid'); |
152 | expect(ReactDOM.findDOMNode(header).value).to.be('10:09:78'); | 147 | expect((header).value).to.be('10:09:78'); |
153 | expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); | 148 | expect((input).value).to.be('01:02:03'); |
154 | 149 | ||
155 | ReactDOM.findDOMNode(header).value = '10:10:78'; | 150 | (header).value = '10:10:78'; |
156 | Simulate.change(header); | 151 | Simulate.change(header); |
157 | setTimeout(next, 100); | 152 | setTimeout(next, 100); |
158 | }, (next) => { | 153 | }, (next) => { |
159 | expect(picker.state.open).to.be(true); | 154 | expect(picker.state.open).to.be(true); |
160 | expect(ReactDOM.findDOMNode(header).value).to.be('10:11:18'); | 155 | expect((header).value).to.be('10:10:78'); |
161 | expect(ReactDOM.findDOMNode(input).value).to.be('10:11:18'); | 156 | expect((input).value).to.be('01:02:03'); |
162 | 157 | ||
163 | ReactDOM.findDOMNode(header).value = '10:09:19'; | 158 | (header).value = '10:09:19'; |
164 | Simulate.change(header); | 159 | Simulate.change(header); |
165 | setTimeout(next, 100); | 160 | setTimeout(next, 100); |
166 | }, (next) => { | 161 | }, (next) => { |
167 | expect(picker.state.open).to.be(true); | 162 | expect(picker.state.open).to.be(true); |
168 | expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid'); | 163 | expect((header).className).to.contain('rc-time-picker-panel-input-invalid'); |
169 | expect(ReactDOM.findDOMNode(header).value).to.be('10:09:19'); | 164 | expect((header).value).to.be('10:09:19'); |
170 | expect(ReactDOM.findDOMNode(input).value).to.be('10:11:18'); | 165 | expect((input).value).to.be('01:02:03'); |
171 | 166 | ||
172 | ReactDOM.findDOMNode(header).value = '10:09:20'; | 167 | (header).value = '10:09:20'; |
173 | Simulate.change(header); | 168 | Simulate.change(header); |
174 | setTimeout(next, 100); | 169 | setTimeout(next, 100); |
175 | }, (next) => { | 170 | }, (next) => { |
176 | expect(picker.state.open).to.be(true); | 171 | expect(picker.state.open).to.be(true); |
177 | expect(ReactDOM.findDOMNode(header).value).to.be('10:09:20'); | 172 | expect((header).value).to.be('10:09:20'); |
178 | expect(ReactDOM.findDOMNode(input).value).to.be('10:09:20'); | 173 | expect((input).value).to.be('10:09:20'); |
179 | 174 | ||
180 | next(); | 175 | next(); |
181 | }], () => { | 176 | }], () => { |
@@ -194,51 +189,53 @@ describe('Header', () => { | |||
194 | hideDisabledOptions: true, | 189 | hideDisabledOptions: true, |
195 | }); | 190 | }); |
196 | expect(picker.state.open).not.to.be.ok(); | 191 | expect(picker.state.open).not.to.be.ok(); |
197 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0]; | 192 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, |
193 | 'rc-time-picker-input')[0]; | ||
198 | let header; | 194 | let header; |
199 | async.series([(next) => { | 195 | async.series([(next) => { |
200 | Simulate.click(input); | 196 | Simulate.click(input); |
201 | setTimeout(next, 100); | 197 | setTimeout(next, 100); |
202 | }, (next) => { | 198 | }, (next) => { |
203 | expect(picker.state.open).to.be(true); | 199 | expect(picker.state.open).to.be(true); |
204 | header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0]; | 200 | header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, |
201 | 'rc-time-picker-panel-input')[0]; | ||
205 | expect(header).to.be.ok(); | 202 | expect(header).to.be.ok(); |
206 | expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); | 203 | expect((header).value).to.be('01:02:03'); |
207 | expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); | 204 | expect((input).value).to.be('01:02:03'); |
208 | 205 | ||
209 | ReactDOM.findDOMNode(header).value = '10:09:78'; | 206 | (header).value = '10:09:78'; |
210 | Simulate.change(header); | 207 | Simulate.change(header); |
211 | setTimeout(next, 100); | 208 | setTimeout(next, 100); |
212 | }, (next) => { | 209 | }, (next) => { |
213 | expect(picker.state.open).to.be(true); | 210 | expect(picker.state.open).to.be(true); |
214 | expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid'); | 211 | expect((header).className).to.contain('rc-time-picker-panel-input-invalid'); |
215 | expect(ReactDOM.findDOMNode(header).value).to.be('10:09:78'); | 212 | expect((header).value).to.be('10:09:78'); |
216 | expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); | 213 | expect((input).value).to.be('01:02:03'); |
217 | 214 | ||
218 | ReactDOM.findDOMNode(header).value = '10:10:78'; | 215 | (header).value = '10:10:78'; |
219 | Simulate.change(header); | 216 | Simulate.change(header); |
220 | setTimeout(next, 100); | 217 | setTimeout(next, 100); |
221 | }, (next) => { | 218 | }, (next) => { |
222 | expect(picker.state.open).to.be(true); | 219 | expect(picker.state.open).to.be(true); |
223 | expect(ReactDOM.findDOMNode(header).value).to.be('10:11:18'); | 220 | expect((header).value).to.be('10:10:78'); |
224 | expect(ReactDOM.findDOMNode(input).value).to.be('10:11:18'); | 221 | expect((input).value).to.be('01:02:03'); |
225 | 222 | ||
226 | ReactDOM.findDOMNode(header).value = '10:09:19'; | 223 | (header).value = '10:09:19'; |
227 | Simulate.change(header); | 224 | Simulate.change(header); |
228 | setTimeout(next, 100); | 225 | setTimeout(next, 100); |
229 | }, (next) => { | 226 | }, (next) => { |
230 | expect(picker.state.open).to.be(true); | 227 | expect(picker.state.open).to.be(true); |
231 | expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid'); | 228 | expect((header).className).to.contain('rc-time-picker-panel-input-invalid'); |
232 | expect(ReactDOM.findDOMNode(header).value).to.be('10:09:19'); | 229 | expect((header).value).to.be('10:09:19'); |
233 | expect(ReactDOM.findDOMNode(input).value).to.be('10:11:18'); | 230 | expect((input).value).to.be('01:02:03'); |
234 | 231 | ||
235 | ReactDOM.findDOMNode(header).value = '10:09:20'; | 232 | (header).value = '10:09:20'; |
236 | Simulate.change(header); | 233 | Simulate.change(header); |
237 | setTimeout(next, 100); | 234 | setTimeout(next, 100); |
238 | }, (next) => { | 235 | }, (next) => { |
239 | expect(picker.state.open).to.be(true); | 236 | expect(picker.state.open).to.be(true); |
240 | expect(ReactDOM.findDOMNode(header).value).to.be('10:09:20'); | 237 | expect((header).value).to.be('10:09:20'); |
241 | expect(ReactDOM.findDOMNode(input).value).to.be('10:09:20'); | 238 | expect((input).value).to.be('10:09:20'); |
242 | 239 | ||
243 | next(); | 240 | next(); |
244 | }], () => { | 241 | }], () => { |
@@ -249,44 +246,46 @@ describe('Header', () => { | |||
249 | it('check correctly', (done) => { | 246 | it('check correctly', (done) => { |
250 | const picker = renderPicker(); | 247 | const picker = renderPicker(); |
251 | expect(picker.state.open).not.to.be.ok(); | 248 | expect(picker.state.open).not.to.be.ok(); |
252 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0]; | 249 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, |
250 | 'rc-time-picker-input')[0]; | ||
253 | let header; | 251 | let header; |
254 | async.series([(next) => { | 252 | async.series([(next) => { |
255 | Simulate.click(input); | 253 | Simulate.click(input); |
256 | setTimeout(next, 100); | 254 | setTimeout(next, 100); |
257 | }, (next) => { | 255 | }, (next) => { |
258 | expect(picker.state.open).to.be(true); | 256 | expect(picker.state.open).to.be(true); |
259 | header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0]; | 257 | header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, |
258 | 'rc-time-picker-panel-input')[0]; | ||
260 | expect(header).to.be.ok(); | 259 | expect(header).to.be.ok(); |
261 | expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); | 260 | expect((header).value).to.be('01:02:03'); |
262 | expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); | 261 | expect((input).value).to.be('01:02:03'); |
263 | 262 | ||
264 | ReactDOM.findDOMNode(header).value = '3:34:56'; | 263 | (header).value = '3:34:56'; |
265 | Simulate.change(header); | 264 | Simulate.change(header); |
266 | setTimeout(next, 100); | 265 | setTimeout(next, 100); |
267 | }, (next) => { | 266 | }, (next) => { |
268 | expect(picker.state.open).to.be(true); | 267 | expect(picker.state.open).to.be(true); |
269 | expect(ReactDOM.findDOMNode(header).value).to.be('3:34:56'); | 268 | expect((header).value).to.be('3:34:56'); |
270 | expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); | 269 | expect((input).value).to.be('01:02:03'); |
271 | expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid'); | 270 | expect((header).className).to.contain('rc-time-picker-panel-input-invalid'); |
272 | 271 | ||
273 | ReactDOM.findDOMNode(header).value = '13:3:56'; | 272 | (header).value = '13:3:56'; |
274 | Simulate.change(header); | 273 | Simulate.change(header); |
275 | setTimeout(next, 100); | 274 | setTimeout(next, 100); |
276 | }, (next) => { | 275 | }, (next) => { |
277 | expect(picker.state.open).to.be(true); | 276 | expect(picker.state.open).to.be(true); |
278 | expect(ReactDOM.findDOMNode(header).value).to.be('13:3:56'); | 277 | expect((header).value).to.be('13:3:56'); |
279 | expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); | 278 | expect((input).value).to.be('01:02:03'); |
280 | expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid'); | 279 | expect((header).className).to.contain('rc-time-picker-panel-input-invalid'); |
281 | 280 | ||
282 | ReactDOM.findDOMNode(header).value = '13:34:5'; | 281 | (header).value = '13:34:5'; |
283 | Simulate.change(header); | 282 | Simulate.change(header); |
284 | setTimeout(next, 100); | 283 | setTimeout(next, 100); |
285 | }, (next) => { | 284 | }, (next) => { |
286 | expect(picker.state.open).to.be(true); | 285 | expect(picker.state.open).to.be(true); |
287 | expect(ReactDOM.findDOMNode(header).value).to.be('13:34:5'); | 286 | expect((header).value).to.be('13:34:5'); |
288 | expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); | 287 | expect((input).value).to.be('01:02:03'); |
289 | expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid'); | 288 | expect((header).className).to.contain('rc-time-picker-panel-input-invalid'); |
290 | next(); | 289 | next(); |
291 | }], () => { | 290 | }], () => { |
292 | done(); | 291 | done(); |
@@ -303,7 +302,8 @@ describe('Header', () => { | |||
303 | }, | 302 | }, |
304 | }); | 303 | }); |
305 | expect(picker.state.open).not.to.be.ok(); | 304 | expect(picker.state.open).not.to.be.ok(); |
306 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0]; | 305 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, |
306 | 'rc-time-picker-input')[0]; | ||
307 | let header; | 307 | let header; |
308 | async.series([(next) => { | 308 | async.series([(next) => { |
309 | expect(picker.state.open).to.be(false); | 309 | expect(picker.state.open).to.be(false); |
@@ -312,20 +312,22 @@ describe('Header', () => { | |||
312 | setTimeout(next, 100); | 312 | setTimeout(next, 100); |
313 | }, (next) => { | 313 | }, (next) => { |
314 | expect(picker.state.open).to.be(true); | 314 | expect(picker.state.open).to.be(true); |
315 | header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0]; | 315 | header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, |
316 | const clearButton = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-clear-btn')[0]; | 316 | 'rc-time-picker-panel-input')[0]; |
317 | const clearButton = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, | ||
318 | 'rc-time-picker-panel-clear-btn')[0]; | ||
317 | expect(header).to.be.ok(); | 319 | expect(header).to.be.ok(); |
318 | expect(clearButton).to.be.ok(); | 320 | expect(clearButton).to.be.ok(); |
319 | expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); | 321 | expect((header).value).to.be('01:02:03'); |
320 | expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); | 322 | expect((input).value).to.be('01:02:03'); |
321 | 323 | ||
322 | Simulate.mouseDown(clearButton); | 324 | Simulate.mouseDown(clearButton); |
323 | setTimeout(next, 100); | 325 | setTimeout(next, 100); |
324 | }, (next) => { | 326 | }, (next) => { |
325 | expect(picker.state.open).to.be(false); | 327 | expect(picker.state.open).to.be(false); |
326 | expect(change).to.be(null); | 328 | expect(change).to.be(null); |
327 | expect(ReactDOM.findDOMNode(header).value).to.be(''); | 329 | expect((header).value).to.be(''); |
328 | expect(ReactDOM.findDOMNode(input).value).to.be(''); | 330 | expect((input).value).to.be(''); |
329 | 331 | ||
330 | next(); | 332 | next(); |
331 | }], () => { | 333 | }], () => { |
@@ -336,7 +338,8 @@ describe('Header', () => { | |||
336 | it('exit correctly', (done) => { | 338 | it('exit correctly', (done) => { |
337 | const picker = renderPicker(); | 339 | const picker = renderPicker(); |
338 | expect(picker.state.open).not.to.be.ok(); | 340 | expect(picker.state.open).not.to.be.ok(); |
339 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0]; | 341 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, |
342 | 'rc-time-picker-input')[0]; | ||
340 | let header; | 343 | let header; |
341 | async.series([(next) => { | 344 | async.series([(next) => { |
342 | expect(picker.state.open).to.be(false); | 345 | expect(picker.state.open).to.be(false); |
@@ -345,19 +348,20 @@ describe('Header', () => { | |||
345 | setTimeout(next, 100); | 348 | setTimeout(next, 100); |
346 | }, (next) => { | 349 | }, (next) => { |
347 | expect(picker.state.open).to.be(true); | 350 | expect(picker.state.open).to.be(true); |
348 | header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0]; | 351 | header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, |
352 | 'rc-time-picker-panel-input')[0]; | ||
349 | expect(header).to.be.ok(); | 353 | expect(header).to.be.ok(); |
350 | expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); | 354 | expect((header).value).to.be('01:02:03'); |
351 | expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); | 355 | expect((input).value).to.be('01:02:03'); |
352 | 356 | ||
353 | Simulate.keyDown(ReactDOM.findDOMNode(header), { | 357 | Simulate.keyDown((header), { |
354 | keyCode: KeyCode.ESC, | 358 | keyCode: KeyCode.ESC, |
355 | }); | 359 | }); |
356 | setTimeout(next, 100); | 360 | setTimeout(next, 100); |
357 | }, (next) => { | 361 | }, (next) => { |
358 | expect(picker.state.open).to.be(false); | 362 | expect(picker.state.open).to.be(false); |
359 | expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); | 363 | expect((header).value).to.be('01:02:03'); |
360 | expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); | 364 | expect((input).value).to.be('01:02:03'); |
361 | 365 | ||
362 | next(); | 366 | next(); |
363 | }], () => { | 367 | }], () => { |