aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Select.spec.jsx
diff options
context:
space:
mode:
authorMG12 <wuzhao.mail@gmail.com>2015-12-13 00:03:19 +0800
committerMG12 <wuzhao.mail@gmail.com>2015-12-13 00:03:19 +0800
commit0e62bf0b7bdc260e882fd185492939cbaed04d56 (patch)
tree84f678a775ead7577fdcac9089ca918b4febcf39 /tests/Select.spec.jsx
parent518b852e8bd9c50a6c5c7e84cddecb5c94ebb5b6 (diff)
downloadtime-picker-0e62bf0b7bdc260e882fd185492939cbaed04d56.tar.gz
time-picker-0e62bf0b7bdc260e882fd185492939cbaed04d56.tar.zst
time-picker-0e62bf0b7bdc260e882fd185492939cbaed04d56.zip
update test case and fix bugs
Diffstat (limited to 'tests/Select.spec.jsx')
-rw-r--r--tests/Select.spec.jsx114
1 files changed, 108 insertions, 6 deletions
diff --git a/tests/Select.spec.jsx b/tests/Select.spec.jsx
index 7e53c31..6dd7796 100644
--- a/tests/Select.spec.jsx
+++ b/tests/Select.spec.jsx
@@ -89,12 +89,12 @@ describe('Select', () => {
89 }, (next) => { 89 }, (next) => {
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 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[0];
93 const option = selector.getElementsByTagName('li')[19];
94 expect(header).to.be.ok(); 92 expect(header).to.be.ok();
95 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); 93 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
96 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); 94 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
97 95
96 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[0];
97 const option = selector.getElementsByTagName('li')[19];
98 Simulate.click(option); 98 Simulate.click(option);
99 setTimeout(next, 100); 99 setTimeout(next, 100);
100 }, (next) => { 100 }, (next) => {
@@ -128,12 +128,12 @@ describe('Select', () => {
128 }, (next) => { 128 }, (next) => {
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 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[1];
132 const option = selector.getElementsByTagName('li')[19];
133 expect(header).to.be.ok(); 131 expect(header).to.be.ok();
134 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); 132 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
135 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); 133 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
136 134
135 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[1];
136 const option = selector.getElementsByTagName('li')[19];
137 Simulate.click(option); 137 Simulate.click(option);
138 setTimeout(next, 100); 138 setTimeout(next, 100);
139 }, (next) => { 139 }, (next) => {
@@ -167,12 +167,12 @@ describe('Select', () => {
167 }, (next) => { 167 }, (next) => {
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 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[2];
171 const option = selector.getElementsByTagName('li')[19];
172 expect(header).to.be.ok(); 170 expect(header).to.be.ok();
173 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); 171 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
174 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); 172 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
175 173
174 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[2];
175 const option = selector.getElementsByTagName('li')[19];
176 Simulate.click(option); 176 Simulate.click(option);
177 setTimeout(next, 100); 177 setTimeout(next, 100);
178 }, (next) => { 178 }, (next) => {
@@ -187,5 +187,107 @@ describe('Select', () => {
187 done(); 187 done();
188 }); 188 });
189 }); 189 });
190
191 it('disabled correctly', (done) => {
192 let change;
193 const picker = renderPicker({
194 onChange(v) {
195 change = v;
196 },
197 disabledMinutes: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]
198 });
199 expect(picker.state.open).not.to.be.ok();
200 const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
201 let header;
202 async.series([(next) => {
203 expect(picker.state.open).to.be(false);
204
205 Simulate.click(input);
206 setTimeout(next, 100);
207 }, (next) => {
208 expect(picker.state.open).to.be(true);
209 header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
210 expect(header).to.be.ok();
211 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
212 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
213
214 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[1];
215 const option = selector.getElementsByTagName('li')[6];
216 Simulate.click(option);
217 setTimeout(next, 100);
218 }, (next) => {
219 expect(change).not.to.be.ok();
220 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
221 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
222 expect(picker.state.open).to.be.ok();
223
224 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[1];
225 const option = selector.getElementsByTagName('li')[7];
226 Simulate.click(option);
227 setTimeout(next, 100);
228 }, (next) => {
229 expect(change).to.be.ok();
230 expect(change.getMinutes()).to.be(7);
231 expect(ReactDOM.findDOMNode(header).value).to.be('01:07:03');
232 expect(ReactDOM.findDOMNode(input).value).to.be('01:07:03');
233 expect(picker.state.open).to.be.ok();
234
235 next();
236 }], () => {
237 done();
238 });
239 });
240
241 it('hidden correctly', (done) => {
242 let change;
243 const picker = renderPicker({
244 onChange(v) {
245 change = v;
246 },
247 disabledHours: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],
248 hideDisabledOptions: true
249 });
250 expect(picker.state.open).not.to.be.ok();
251 const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
252 let header;
253 async.series([(next) => {
254 expect(picker.state.open).to.be(false);
255
256 Simulate.click(input);
257 setTimeout(next, 100);
258 }, (next) => {
259 expect(picker.state.open).to.be(true);
260 header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
261 expect(header).to.be.ok();
262 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
263 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
264
265 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[0];
266 const option = selector.getElementsByTagName('li')[3];
267 Simulate.click(option);
268 setTimeout(next, 100);
269 }, (next) => {
270 expect(change).to.be.ok();
271 expect(change.getHourOfDay()).to.be(6);
272 expect(ReactDOM.findDOMNode(header).value).to.be('06:02:03');
273 expect(ReactDOM.findDOMNode(input).value).to.be('06:02:03');
274 expect(picker.state.open).to.be.ok();
275
276 const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[0];
277 const option = selector.getElementsByTagName('li')[4];
278 Simulate.click(option);
279 setTimeout(next, 100);
280 }, (next) => {
281 expect(change).to.be.ok();
282 expect(change.getHourOfDay()).to.be(8);
283 expect(ReactDOM.findDOMNode(header).value).to.be('08:02:03');
284 expect(ReactDOM.findDOMNode(input).value).to.be('08:02:03');
285 expect(picker.state.open).to.be.ok();
286
287 next();
288 }], () => {
289 done();
290 });
291 });
190 }); 292 });
191}); 293});