]> git.immae.eu Git - github/fretlink/time-picker.git/commitdiff
Fixed unwanted exception on missed value
authorAntony Shaleynikov <shaleynikov@gmail.com>
Wed, 8 Mar 2017 19:50:57 +0000 (22:50 +0300)
committerAntony Shaleynikov <shaleynikov@gmail.com>
Wed, 8 Mar 2017 19:50:57 +0000 (22:50 +0300)
src/Combobox.jsx
tests/TimePicker.spec.jsx

index 36b61cca13712b78fe33f1977823daa8d5d5c815..477c5eea5aa9e2a1d5f869f21047840f9d427139 100644 (file)
@@ -170,7 +170,7 @@ const Combobox = React.createClass({
   },
 
   isAM() {
-    const { value } = this.props;
+    const value = (this.props.value || this.props.defaultOpenValue);
     return value.hour() >= 0 && value.hour() < 12;
   },
 
index 1ea3b8b95cfeef7206de5ffe427eaf6ef4c9a7b2..6f9ac2de1f75d635df2069a49ec40a0cf93787b3 100644 (file)
@@ -174,4 +174,38 @@ describe('TimePicker', () => {
       });
     });
   });
+
+  describe('render panel to body 12pm mode', () => {
+    it('popup correctly', (done) => {
+      let change;
+      const picker = renderPickerWithoutSeconds({
+        use12Hours: true,
+        value: null,
+        onChange(v) {
+          change = v;
+        },
+      });
+      expect(picker.state.open).not.to.be.ok();
+      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker,
+        'rc-time-picker-input')[0];
+      expect((input).value).to.be('');
+      async.series([(next) => {
+        Simulate.click(input);
+        setTimeout(next, 100);
+      }, (next) => {
+        expect(TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance,
+          'rc-time-picker-panel-inner')[0]).to.be.ok();
+        expect(picker.state.open).to.be(true);
+        const hour = TestUtils.scryRenderedDOMComponentsWithTag(picker.panelInstance, 'li')[1];
+        Simulate.click(hour);
+        setTimeout(next, 100);
+      }, (next) => {
+        expect(change).to.be.ok();
+        expect(picker.state.open).to.be.ok();
+        next();
+      }], () => {
+        done();
+      });
+    });
+  });
 });