aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Header.spec.jsx
diff options
context:
space:
mode:
authorMG12 <wuzhao.mail@gmail.com>2015-12-14 00:50:41 +0800
committerMG12 <wuzhao.mail@gmail.com>2015-12-14 00:50:41 +0800
commit71bd9bc11f2ca6068f7977ff3511b2798f73d0c6 (patch)
treee24404e929db29204fa008546377351d314f9480 /tests/Header.spec.jsx
parent0e62bf0b7bdc260e882fd185492939cbaed04d56 (diff)
downloadtime-picker-71bd9bc11f2ca6068f7977ff3511b2798f73d0c6.tar.gz
time-picker-71bd9bc11f2ca6068f7977ff3511b2798f73d0c6.tar.zst
time-picker-71bd9bc11f2ca6068f7977ff3511b2798f73d0c6.zip
update disabled options
Diffstat (limited to 'tests/Header.spec.jsx')
-rw-r--r--tests/Header.spec.jsx70
1 files changed, 57 insertions, 13 deletions
diff --git a/tests/Header.spec.jsx b/tests/Header.spec.jsx
index 18d61c5..e992279 100644
--- a/tests/Header.spec.jsx
+++ b/tests/Header.spec.jsx
@@ -123,7 +123,12 @@ describe('Header', () => {
123 123
124 it('carry disabled correctly', (done) => { 124 it('carry disabled correctly', (done) => {
125 const picker = renderPicker({ 125 const picker = renderPicker({
126 disabledMinutes: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22] 126 disabledMinutes(h) {
127 return [h];
128 },
129 disabledSeconds(h, m) {
130 return [h + m % 60];
131 },
127 }); 132 });
128 expect(picker.state.open).not.to.be.ok(); 133 expect(picker.state.open).not.to.be.ok();
129 const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0]; 134 const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
@@ -138,22 +143,39 @@ describe('Header', () => {
138 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); 143 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
139 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); 144 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
140 145
141 ReactDOM.findDOMNode(header).value = '12:15:78'; 146 ReactDOM.findDOMNode(header).value = '10:09:78';
142 Simulate.change(header); 147 Simulate.change(header);
143 setTimeout(next, 100); 148 setTimeout(next, 100);
144 }, (next) => { 149 }, (next) => {
145 expect(picker.state.open).to.be(true); 150 expect(picker.state.open).to.be(true);
146 expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid'); 151 expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid');
147 expect(ReactDOM.findDOMNode(header).value).to.be('12:15:78'); 152 expect(ReactDOM.findDOMNode(header).value).to.be('10:09:78');
148 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); 153 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
149 154
150 ReactDOM.findDOMNode(header).value = '12:10:78'; 155 ReactDOM.findDOMNode(header).value = '10:10:78';
156 Simulate.change(header);
157 setTimeout(next, 100);
158 }, (next) => {
159 expect(picker.state.open).to.be(true);
160 expect(ReactDOM.findDOMNode(header).value).to.be('10:11:18');
161 expect(ReactDOM.findDOMNode(input).value).to.be('10:11:18');
162
163 ReactDOM.findDOMNode(header).value = '10:09:19';
164 Simulate.change(header);
165 setTimeout(next, 100);
166 }, (next) => {
167 expect(picker.state.open).to.be(true);
168 expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid');
169 expect(ReactDOM.findDOMNode(header).value).to.be('10:09:19');
170 expect(ReactDOM.findDOMNode(input).value).to.be('10:11:18');
171
172 ReactDOM.findDOMNode(header).value = '10:09:20';
151 Simulate.change(header); 173 Simulate.change(header);
152 setTimeout(next, 100); 174 setTimeout(next, 100);
153 }, (next) => { 175 }, (next) => {
154 expect(picker.state.open).to.be(true); 176 expect(picker.state.open).to.be(true);
155 expect(ReactDOM.findDOMNode(header).value).to.be('12:11:18'); 177 expect(ReactDOM.findDOMNode(header).value).to.be('10:09:20');
156 expect(ReactDOM.findDOMNode(input).value).to.be('12:11:18'); 178 expect(ReactDOM.findDOMNode(input).value).to.be('10:09:20');
157 179
158 next(); 180 next();
159 }], () => { 181 }], () => {
@@ -163,8 +185,13 @@ describe('Header', () => {
163 185
164 it('carry hidden correctly', (done) => { 186 it('carry hidden correctly', (done) => {
165 const picker = renderPicker({ 187 const picker = renderPicker({
166 disabledMinutes: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22], 188 disabledMinutes(h) {
167 hideDisabledOptions: true 189 return [h];
190 },
191 disabledSeconds(h, m) {
192 return [h + m % 60];
193 },
194 hideDisabledOptions: true,
168 }); 195 });
169 expect(picker.state.open).not.to.be.ok(); 196 expect(picker.state.open).not.to.be.ok();
170 const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0]; 197 const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, 'rc-time-picker-input')[0];
@@ -179,22 +206,39 @@ describe('Header', () => {
179 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03'); 206 expect(ReactDOM.findDOMNode(header).value).to.be('01:02:03');
180 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); 207 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
181 208
182 ReactDOM.findDOMNode(header).value = '12:15:78'; 209 ReactDOM.findDOMNode(header).value = '10:09:78';
183 Simulate.change(header); 210 Simulate.change(header);
184 setTimeout(next, 100); 211 setTimeout(next, 100);
185 }, (next) => { 212 }, (next) => {
186 expect(picker.state.open).to.be(true); 213 expect(picker.state.open).to.be(true);
187 expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid'); 214 expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid');
188 expect(ReactDOM.findDOMNode(header).value).to.be('12:15:78'); 215 expect(ReactDOM.findDOMNode(header).value).to.be('10:09:78');
189 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03'); 216 expect(ReactDOM.findDOMNode(input).value).to.be('01:02:03');
190 217
191 ReactDOM.findDOMNode(header).value = '12:10:78'; 218 ReactDOM.findDOMNode(header).value = '10:10:78';
219 Simulate.change(header);
220 setTimeout(next, 100);
221 }, (next) => {
222 expect(picker.state.open).to.be(true);
223 expect(ReactDOM.findDOMNode(header).value).to.be('10:11:18');
224 expect(ReactDOM.findDOMNode(input).value).to.be('10:11:18');
225
226 ReactDOM.findDOMNode(header).value = '10:09:19';
227 Simulate.change(header);
228 setTimeout(next, 100);
229 }, (next) => {
230 expect(picker.state.open).to.be(true);
231 expect(ReactDOM.findDOMNode(header).className).to.contain('rc-time-picker-panel-input-invalid');
232 expect(ReactDOM.findDOMNode(header).value).to.be('10:09:19');
233 expect(ReactDOM.findDOMNode(input).value).to.be('10:11:18');
234
235 ReactDOM.findDOMNode(header).value = '10:09:20';
192 Simulate.change(header); 236 Simulate.change(header);
193 setTimeout(next, 100); 237 setTimeout(next, 100);
194 }, (next) => { 238 }, (next) => {
195 expect(picker.state.open).to.be(true); 239 expect(picker.state.open).to.be(true);
196 expect(ReactDOM.findDOMNode(header).value).to.be('12:11:18'); 240 expect(ReactDOM.findDOMNode(header).value).to.be('10:09:20');
197 expect(ReactDOM.findDOMNode(input).value).to.be('12:11:18'); 241 expect(ReactDOM.findDOMNode(input).value).to.be('10:09:20');
198 242
199 next(); 243 next();
200 }], () => { 244 }], () => {