diff options
author | Antony Shaleynikov <shaleynikov@gmail.com> | 2017-03-08 22:50:57 +0300 |
---|---|---|
committer | Antony Shaleynikov <shaleynikov@gmail.com> | 2017-03-08 22:50:57 +0300 |
commit | 4f26f23b14ec9f1aa6260b1eee9a190639530b45 (patch) | |
tree | 593b73049f75bbb14914f514b80bdc02c3622cc5 | |
parent | 5423edb11fac7f8ed5d35ba739878ee4435fa5af (diff) | |
download | time-picker-4f26f23b14ec9f1aa6260b1eee9a190639530b45.tar.gz time-picker-4f26f23b14ec9f1aa6260b1eee9a190639530b45.tar.zst time-picker-4f26f23b14ec9f1aa6260b1eee9a190639530b45.zip |
Fixed unwanted exception on missed value
-rw-r--r-- | src/Combobox.jsx | 2 | ||||
-rw-r--r-- | tests/TimePicker.spec.jsx | 34 |
2 files changed, 35 insertions, 1 deletions
diff --git a/src/Combobox.jsx b/src/Combobox.jsx index 36b61cc..477c5ee 100644 --- a/src/Combobox.jsx +++ b/src/Combobox.jsx | |||
@@ -170,7 +170,7 @@ const Combobox = React.createClass({ | |||
170 | }, | 170 | }, |
171 | 171 | ||
172 | isAM() { | 172 | isAM() { |
173 | const { value } = this.props; | 173 | const value = (this.props.value || this.props.defaultOpenValue); |
174 | return value.hour() >= 0 && value.hour() < 12; | 174 | return value.hour() >= 0 && value.hour() < 12; |
175 | }, | 175 | }, |
176 | 176 | ||
diff --git a/tests/TimePicker.spec.jsx b/tests/TimePicker.spec.jsx index 1ea3b8b..6f9ac2d 100644 --- a/tests/TimePicker.spec.jsx +++ b/tests/TimePicker.spec.jsx | |||
@@ -174,4 +174,38 @@ describe('TimePicker', () => { | |||
174 | }); | 174 | }); |
175 | }); | 175 | }); |
176 | }); | 176 | }); |
177 | |||
178 | describe('render panel to body 12pm mode', () => { | ||
179 | it('popup correctly', (done) => { | ||
180 | let change; | ||
181 | const picker = renderPickerWithoutSeconds({ | ||
182 | use12Hours: true, | ||
183 | value: null, | ||
184 | onChange(v) { | ||
185 | change = v; | ||
186 | }, | ||
187 | }); | ||
188 | expect(picker.state.open).not.to.be.ok(); | ||
189 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, | ||
190 | 'rc-time-picker-input')[0]; | ||
191 | expect((input).value).to.be(''); | ||
192 | async.series([(next) => { | ||
193 | Simulate.click(input); | ||
194 | setTimeout(next, 100); | ||
195 | }, (next) => { | ||
196 | expect(TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, | ||
197 | 'rc-time-picker-panel-inner')[0]).to.be.ok(); | ||
198 | expect(picker.state.open).to.be(true); | ||
199 | const hour = TestUtils.scryRenderedDOMComponentsWithTag(picker.panelInstance, 'li')[1]; | ||
200 | Simulate.click(hour); | ||
201 | setTimeout(next, 100); | ||
202 | }, (next) => { | ||
203 | expect(change).to.be.ok(); | ||
204 | expect(picker.state.open).to.be.ok(); | ||
205 | next(); | ||
206 | }], () => { | ||
207 | done(); | ||
208 | }); | ||
209 | }); | ||
210 | }); | ||
177 | }); | 211 | }); |