From: Levi Lansing Date: Thu, 28 Sep 2017 15:44:03 +0000 (-0400) Subject: add test that covers focus on open code X-Git-Tag: 3.0.0~5^2~1 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=bcb307b79a2481bad496085b75b701bf864adc6d;p=github%2Ffretlink%2Ftime-picker.git add test that covers focus on open code --- diff --git a/tests/Header.spec.jsx b/tests/Header.spec.jsx index 5ab0ba0..4b27abb 100644 --- a/tests/Header.spec.jsx +++ b/tests/Header.spec.jsx @@ -368,5 +368,33 @@ describe('Header', () => { done(); }); }); + + it('focus on open', (done) => { + const picker = renderPicker({ + focusOnOpen: true, + }); + expect(picker.state.open).not.to.be.ok(); + const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, + 'rc-time-picker-input')[0]; + let header; + async.series([(next) => { + expect(picker.state.open).to.be(false); + + Simulate.click(input); + setTimeout(next, 100); + }, (next) => { + // this touches the focusOnOpen code, but we cannot verify the input is in focus + expect(picker.state.open).to.be(true); + header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, + 'rc-time-picker-panel-input')[0]; + expect(header).to.be.ok(); + expect((header).value).to.be('01:02:03'); + expect((input).value).to.be('01:02:03'); + + next(); + }], () => { + done(); + }); + }); }); });