From 71bd9bc11f2ca6068f7977ff3511b2798f73d0c6 Mon Sep 17 00:00:00 2001
From: MG12 <wuzhao.mail@gmail.com>
Date: Mon, 14 Dec 2015 00:50:41 +0800
Subject: update disabled options

---
 tests/Select.spec.jsx | 71 +++++++++++++++++++++++++++++++--------------------
 1 file changed, 44 insertions(+), 27 deletions(-)

(limited to 'tests/Select.spec.jsx')

diff --git a/tests/Select.spec.jsx b/tests/Select.spec.jsx
index 6dd7796..f7717c7 100644
--- a/tests/Select.spec.jsx
+++ b/tests/Select.spec.jsx
@@ -29,7 +29,7 @@ describe('Select', () => {
         formatter={formatter}
         locale={TimePickerLocale}
         showSecond={showSecond}
-        defaultValue={formatTime('01:02:03', formatter)}
+        defaultValue={formatTime('01:02:04', formatter)}
         {...props}
       />, container);
   }
@@ -90,8 +90,8 @@ describe('Select', () => {
         expect(picker.state.open).to.be(true);
         header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
         expect(header).to.be.ok();
-        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
+        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:04');
+        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:04');
 
         const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[0];
         const option = selector.getElementsByTagName('li')[19];
@@ -100,8 +100,8 @@ describe('Select', () => {
       }, (next) => {
         expect(change).to.be.ok();
         expect(change.getHourOfDay()).to.be(19);
-        expect(ReactDOM.findDOMNode(header).value).to.be('19:02:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('19:02:03');
+        expect(ReactDOM.findDOMNode(header).value).to.be('19:02:04');
+        expect(ReactDOM.findDOMNode(input).value).to.be('19:02:04');
         expect(picker.state.open).to.be.ok();
 
         next();
@@ -129,8 +129,8 @@ describe('Select', () => {
         expect(picker.state.open).to.be(true);
         header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
         expect(header).to.be.ok();
-        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
+        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:04');
+        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:04');
 
         const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[1];
         const option = selector.getElementsByTagName('li')[19];
@@ -139,8 +139,8 @@ describe('Select', () => {
       }, (next) => {
         expect(change).to.be.ok();
         expect(change.getMinutes()).to.be(19);
-        expect(ReactDOM.findDOMNode(header).value).to.be('01:19:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:19:03');
+        expect(ReactDOM.findDOMNode(header).value).to.be('01:19:04');
+        expect(ReactDOM.findDOMNode(input).value).to.be('01:19:04');
         expect(picker.state.open).to.be.ok();
 
         next();
@@ -168,8 +168,8 @@ describe('Select', () => {
         expect(picker.state.open).to.be(true);
         header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
         expect(header).to.be.ok();
-        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
+        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:04');
+        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:04');
 
         const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[2];
         const option = selector.getElementsByTagName('li')[19];
@@ -194,7 +194,12 @@ describe('Select', () => {
         onChange(v) {
           change = v;
         },
-        disabledMinutes: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]
+        disabledMinutes(h) {
+          return [h];
+        },
+        disabledSeconds(h, m) {
+          return [h + m % 60];
+        },
       });
       expect(picker.state.open).not.to.be.ok();
       const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
@@ -208,17 +213,27 @@ describe('Select', () => {
         expect(picker.state.open).to.be(true);
         header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
         expect(header).to.be.ok();
-        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
+        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:04');
+        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:04');
 
         const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[1];
-        const option = selector.getElementsByTagName('li')[6];
+        const option = selector.getElementsByTagName('li')[1];
         Simulate.click(option);
         setTimeout(next, 100);
       }, (next) => {
         expect(change).not.to.be.ok();
-        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
+        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:04');
+        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:04');
+        expect(picker.state.open).to.be.ok();
+
+        const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[2];
+        const option = selector.getElementsByTagName('li')[3];
+        Simulate.click(option);
+        setTimeout(next, 100);
+      }, (next) => {
+        expect(change).not.to.be.ok();
+        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:04');
+        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:04');
         expect(picker.state.open).to.be.ok();
 
         const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[1];
@@ -228,8 +243,8 @@ describe('Select', () => {
       }, (next) => {
         expect(change).to.be.ok();
         expect(change.getMinutes()).to.be(7);
-        expect(ReactDOM.findDOMNode(header).value).to.be('01:07:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:07:03');
+        expect(ReactDOM.findDOMNode(header).value).to.be('01:07:04');
+        expect(ReactDOM.findDOMNode(input).value).to.be('01:07:04');
         expect(picker.state.open).to.be.ok();
 
         next();
@@ -244,8 +259,10 @@ describe('Select', () => {
         onChange(v) {
           change = v;
         },
-        disabledHours: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],
-        hideDisabledOptions: true
+        disabledHours() {
+          return [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23];
+        },
+        hideDisabledOptions: true,
       });
       expect(picker.state.open).not.to.be.ok();
       const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
@@ -259,8 +276,8 @@ describe('Select', () => {
         expect(picker.state.open).to.be(true);
         header = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-input')[0];
         expect(header).to.be.ok();
-        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
+        expect(ReactDOM.findDOMNode(header).value).to.be('01:02:04');
+        expect(ReactDOM.findDOMNode(input).value).to.be('01:02:04');
 
         const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[0];
         const option = selector.getElementsByTagName('li')[3];
@@ -269,8 +286,8 @@ describe('Select', () => {
       }, (next) => {
         expect(change).to.be.ok();
         expect(change.getHourOfDay()).to.be(6);
-        expect(ReactDOM.findDOMNode(header).value).to.be('06:02:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('06:02:03');
+        expect(ReactDOM.findDOMNode(header).value).to.be('06:02:04');
+        expect(ReactDOM.findDOMNode(input).value).to.be('06:02:04');
         expect(picker.state.open).to.be.ok();
 
         const selector = TestUtils.scryRenderedDOMComponentsWithClass(picker.panelInstance, 'rc-time-picker-panel-select')[0];
@@ -280,8 +297,8 @@ describe('Select', () => {
       }, (next) => {
         expect(change).to.be.ok();
         expect(change.getHourOfDay()).to.be(8);
-        expect(ReactDOM.findDOMNode(header).value).to.be('08:02:03');
-        expect(ReactDOM.findDOMNode(input).value).to.be('08:02:03');
+        expect(ReactDOM.findDOMNode(header).value).to.be('08:02:04');
+        expect(ReactDOM.findDOMNode(input).value).to.be('08:02:04');
         expect(picker.state.open).to.be.ok();
 
         next();
-- 
cgit v1.2.3

