aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Header.spec.jsx81
-rw-r--r--tests/Select.spec.jsx114
2 files changed, 189 insertions, 6 deletions
diff --git a/tests/Header.spec.jsx b/tests/Header.spec.jsx
index cc8f954..18d61c5 100644
--- a/tests/Header.spec.jsx
+++ b/tests/Header.spec.jsx
@@ -121,6 +121,87 @@ describe('Header', () => {
121 }); 121 });
122 }); 122 });
123 123
124 it('carry disabled correctly', (done) => {
125 const picker = renderPicker({
126 disabledMinutes: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]
127 });
128 expect(picker.state.open).not.to.be.ok();
129 const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
130 let header;
131 async.series([(next) => {
132 Simulate.click(input);
133 setTimeout(next, 100);
134 }, (next) => {
135 expect(picker.state.open).to.be(true);
136 header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
137 expect(header).to.be.ok();
138 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
139 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
140
141 ReactDOM.findDOMNode(header).value = '12:15:78';
142 Simulate.change(header);
143 setTimeout(next, 100);
144 }, (next) => {
145 expect(picker.state.open).to.be(true);
146 expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid');
147 expect(ReactDOM.findDOMNode(header).value).to.be('12:15:78');
148 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
149
150 ReactDOM.findDOMNode(header).value = '12:10:78';
151 Simulate.change(header);
152 setTimeout(next, 100);
153 }, (next) => {
154 expect(picker.state.open).to.be(true);
155 expect(ReactDOM.findDOMNode(header).value).to.be('12:11:18');
156 expect(ReactDOM.findDOMNode(input).value).to.be('12:11:18');
157
158 next();
159 }], () => {
160 done();
161 });
162 });
163
164 it('carry hidden correctly', (done) => {
165 const picker = renderPicker({
166 disabledMinutes: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22],
167 hideDisabledOptions: true
168 });
169 expect(picker.state.open).not.to.be.ok();
170 const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
171 let header;
172 async.series([(next) => {
173 Simulate.click(input);
174 setTimeout(next, 100);
175 }, (next) => {
176 expect(picker.state.open).to.be(true);
177 header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
178 expect(header).to.be.ok();
179 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
180 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
181
182 ReactDOM.findDOMNode(header).value = '12:15:78';
183 Simulate.change(header);
184 setTimeout(next, 100);
185 }, (next) => {
186 expect(picker.state.open).to.be(true);
187 expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid');
188 expect(ReactDOM.findDOMNode(header).value).to.be('12:15:78');
189 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
190
191 ReactDOM.findDOMNode(header).value = '12:10:78';
192 Simulate.change(header);
193 setTimeout(next, 100);
194 }, (next) => {
195 expect(picker.state.open).to.be(true);
196 expect(ReactDOM.findDOMNode(header).value).to.be('12:11:18');
197 expect(ReactDOM.findDOMNode(input).value).to.be('12:11:18');
198
199 next();
200 }], () => {
201 done();
202 });
203 });
204
124 it('check correctly', (done) => { 205 it('check correctly', (done) => {
125 const picker = renderPicker(); 206 const picker = renderPicker();
126 expect(picker.state.open).not.to.be.ok(); 207 expect(picker.state.open).not.to.be.ok();
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});