aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Header.spec.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Header.spec.jsx')
-rw-r--r--tests/Header.spec.jsx125
1 files changed, 125 insertions, 0 deletions
diff --git a/tests/Header.spec.jsx b/tests/Header.spec.jsx
index cc8f954..e992279 100644
--- a/tests/Header.spec.jsx
+++ b/tests/Header.spec.jsx
@@ -121,6 +121,131 @@ describe('Header', () => {
121 }); 121 });
122 }); 122 });
123 123
124 it('carry disabled correctly', (done) => {
125 const picker = renderPicker({
126 disabledMinutes(h) {
127 return [h];
128 },
129 disabledSeconds(h, m) {
130 return [h + m % 60];
131 },
132 });
133 expect(picker.state.open).not.to.be.ok();
134 const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
135 let header;
136 async.series([(next) => {
137 Simulate.click(input);
138 setTimeout(next, 100);
139 }, (next) => {
140 expect(picker.state.open).to.be(true);
141 header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
142 expect(header).to.be.ok();
143 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
144 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
145
146 ReactDOM.findDOMNode(header).value = '10:09:78';
147 Simulate.change(header);
148 setTimeout(next, 100);
149 }, (next) => {
150 expect(picker.state.open).to.be(true);
151 expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid');
152 expect(ReactDOM.findDOMNode(header).value).to.be('10:09:78');
153 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
154
155 ReactDOM.findDOMNode(header).value = '10:10:78';
156 Simulate.change(header);
157 setTimeout(next, 100);
158 }, (next) => {
159 expect(picker.state.open).to.be(true);
160 expect(ReactDOM.findDOMNode(header).value).to.be('10:11:18');
161 expect(ReactDOM.findDOMNode(input).value).to.be('10:11:18');
162
163 ReactDOM.findDOMNode(header).value = '10:09:19';
164 Simulate.change(header);
165 setTimeout(next, 100);
166 }, (next) => {
167 expect(picker.state.open).to.be(true);
168 expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid');
169 expect(ReactDOM.findDOMNode(header).value).to.be('10:09:19');
170 expect(ReactDOM.findDOMNode(input).value).to.be('10:11:18');
171
172 ReactDOM.findDOMNode(header).value = '10:09:20';
173 Simulate.change(header);
174 setTimeout(next, 100);
175 }, (next) => {
176 expect(picker.state.open).to.be(true);
177 expect(ReactDOM.findDOMNode(header).value).to.be('10:09:20');
178 expect(ReactDOM.findDOMNode(input).value).to.be('10:09:20');
179
180 next();
181 }], () => {
182 done();
183 });
184 });
185
186 it('carry hidden correctly', (done) => {
187 const picker = renderPicker({
188 disabledMinutes(h) {
189 return [h];
190 },
191 disabledSeconds(h, m) {
192 return [h + m % 60];
193 },
194 hideDisabledOptions: true,
195 });
196 expect(picker.state.open).not.to.be.ok();
197 const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
198 let header;
199 async.series([(next) => {
200 Simulate.click(input);
201 setTimeout(next, 100);
202 }, (next) => {
203 expect(picker.state.open).to.be(true);
204 header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
205 expect(header).to.be.ok();
206 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
207 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
208
209 ReactDOM.findDOMNode(header).value = '10:09:78';
210 Simulate.change(header);
211 setTimeout(next, 100);
212 }, (next) => {
213 expect(picker.state.open).to.be(true);
214 expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid');
215 expect(ReactDOM.findDOMNode(header).value).to.be('10:09:78');
216 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
217
218 ReactDOM.findDOMNode(header).value = '10:10:78';
219 Simulate.change(header);
220 setTimeout(next, 100);
221 }, (next) => {
222 expect(picker.state.open).to.be(true);
223 expect(ReactDOM.findDOMNode(header).value).to.be('10:11:18');
224 expect(ReactDOM.findDOMNode(input).value).to.be('10:11:18');
225
226 ReactDOM.findDOMNode(header).value = '10:09:19';
227 Simulate.change(header);
228 setTimeout(next, 100);
229 }, (next) => {
230 expect(picker.state.open).to.be(true);
231 expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid');
232 expect(ReactDOM.findDOMNode(header).value).to.be('10:09:19');
233 expect(ReactDOM.findDOMNode(input).value).to.be('10:11:18');
234
235 ReactDOM.findDOMNode(header).value = '10:09:20';
236 Simulate.change(header);
237 setTimeout(next, 100);
238 }, (next) => {
239 expect(picker.state.open).to.be(true);
240 expect(ReactDOM.findDOMNode(header).value).to.be('10:09:20');
241 expect(ReactDOM.findDOMNode(input).value).to.be('10:09:20');
242
243 next();
244 }], () => {
245 done();
246 });
247 });
248
124 it('check correctly', (done) => { 249 it('check correctly', (done) => {
125 const picker = renderPicker(); 250 const picker = renderPicker();
126 expect(picker.state.open).not.to.be.ok(); 251 expect(picker.state.open).not.to.be.ok();