]> git.immae.eu Git - github/fretlink/time-picker.git/commitdiff
Add test cases
authorafc163 <afc163@gmail.com>
Mon, 20 Feb 2017 08:40:58 +0000 (16:40 +0800)
committerafc163 <afc163@gmail.com>
Mon, 20 Feb 2017 08:40:58 +0000 (16:40 +0800)
examples/open.js
tests/TimePicker.spec.jsx

index 5a0d1ed4ebca77a7d9ffc393fd53ba77e7a82676..100bf352d368e64d64756a64a9a27aa84024ab0e 100644 (file)
@@ -12,14 +12,14 @@ const App = React.createClass({
       open: false,
     };
   },
+  setOpen({ open }) {
+    this.setState({ open });
+  },
   toggleOpen() {
     this.setState({
       open: !this.state.open,
     });
   },
-  setOpen({ open }) {
-    this.setState({ open });
-  },
   render() {
     return (
       <div>
index 150f727cb44918cd97f18e166374d388f198e60d..1ea3b8b95cfeef7206de5ffe427eaf6ef4c9a7b2 100644 (file)
@@ -111,6 +111,33 @@ describe('TimePicker', () => {
         done();
       });
     });
+
+    it('support name', () => {
+      const picker = renderPicker({
+        name: 'time-picker-form-name',
+      });
+      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker,
+        'rc-time-picker-input')[0];
+      expect(input.name).to.be('time-picker-form-name');
+    });
+
+    it('support focus', () => {
+      const picker = renderPicker({
+        name: 'time-picker-form-name',
+      });
+      expect(picker.focus).to.be.a('function');
+    });
+
+    it('should be controlled by open', () => {
+      const picker = renderPicker({
+        open: false,
+      });
+      expect(picker.state.open).not.to.be.ok();
+      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker,
+        'rc-time-picker-input')[0];
+      Simulate.click(input);
+      expect(picker.state.open).not.to.be.ok();
+    });
   });
 
   describe('render panel to body (without seconds)', () => {