From bcb307b79a2481bad496085b75b701bf864adc6d Mon Sep 17 00:00:00 2001 From: Levi Lansing Date: Thu, 28 Sep 2017 11:44:03 -0400 Subject: add test that covers focus on open code --- tests/Header.spec.jsx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests') 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(); + }); + }); }); }); -- cgit v1.2.3