]> git.immae.eu Git - github/fretlink/time-picker.git/commitdiff
add test case
authorafc163 <afc163@gmail.com>
Wed, 8 Mar 2017 07:00:09 +0000 (15:00 +0800)
committerafc163 <afc163@gmail.com>
Wed, 8 Mar 2017 07:00:09 +0000 (15:00 +0800)
tests/Select.spec.jsx

index ea0a8270f6ff395a696ceedfe8b6b4103a8dc2cc..fd2ec326800dfb80d65058e99b8b571ee03d6529 100644 (file)
@@ -452,5 +452,43 @@ describe('Select', () => {
         done();
       });
     });
+
+    it('renders uppercase AM correctly', (done) => {
+      const picker = renderPicker({
+        use12Hours: true,
+        defaultValue: moment().hour(0).minute(0).second(0),
+        showSecond: false,
+        format: 'h:mm A',
+      });
+      expect(picker.state.open).not.to.be.ok();
+      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker,
+        'rc-time-picker-input')[0];
+      let selector;
+      async.series([(next) => {
+        expect(picker.state.open).to.be(false);
+
+        Simulate.click(input);
+        setTimeout(next, 100);
+      }, (next) => {
+        expect(picker.state.open).to.be(true);
+        selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance,
+          'rc-time-picker-panel-select')[2];
+        expect((input).value).to.be('12:00 AM');
+        const option = selector.getElementsByTagName('li')[1];
+        Simulate.click(option);
+        setTimeout(next, 200);
+      }, (next) => {
+        expect((input).value).to.be('12:00 PM');
+        next();
+      }, (next) => {
+        Simulate.click(selector.getElementsByTagName('li')[0]);
+        setTimeout(next, 200);
+      }, (next) => {
+        expect((input).value).to.be('12:00 AM');
+        next();
+      }], () => {
+        done();
+      });
+    });
   });
 });