]> git.immae.eu Git - github/fretlink/time-picker.git/commitdiff
add test that covers focus on open code
authorLevi Lansing <helives@gmail.com>
Thu, 28 Sep 2017 15:44:03 +0000 (11:44 -0400)
committerLevi Lansing <helives@gmail.com>
Thu, 28 Sep 2017 15:44:03 +0000 (11:44 -0400)
tests/Header.spec.jsx

index 5ab0ba004e3a4d68516fe9d913c0bb7bc9de4b4f..4b27abb85fe0fa55ccb924547f7e0091b37341a3 100644 (file)
@@ -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();
+      });
+    });
   });
 });