diff options
author | afc163 <afc163@gmail.com> | 2017-02-20 16:40:58 +0800 |
---|---|---|
committer | afc163 <afc163@gmail.com> | 2017-02-20 16:40:58 +0800 |
commit | e3583f75ca49c8a746689644563c65f40236c23b (patch) | |
tree | 57b39468186b25d10a8c1d12497fd08423784a68 | |
parent | 71c3a19635d989f1ed99119bf230856d9faeef21 (diff) | |
download | time-picker-e3583f75ca49c8a746689644563c65f40236c23b.tar.gz time-picker-e3583f75ca49c8a746689644563c65f40236c23b.tar.zst time-picker-e3583f75ca49c8a746689644563c65f40236c23b.zip |
Add test cases
-rw-r--r-- | examples/open.js | 6 | ||||
-rw-r--r-- | tests/TimePicker.spec.jsx | 27 |
2 files changed, 30 insertions, 3 deletions
diff --git a/examples/open.js b/examples/open.js index 5a0d1ed..100bf35 100644 --- a/examples/open.js +++ b/examples/open.js | |||
@@ -12,14 +12,14 @@ const App = React.createClass({ | |||
12 | open: false, | 12 | open: false, |
13 | }; | 13 | }; |
14 | }, | 14 | }, |
15 | setOpen({ open }) { | ||
16 | this.setState({ open }); | ||
17 | }, | ||
15 | toggleOpen() { | 18 | toggleOpen() { |
16 | this.setState({ | 19 | this.setState({ |
17 | open: !this.state.open, | 20 | open: !this.state.open, |
18 | }); | 21 | }); |
19 | }, | 22 | }, |
20 | setOpen({ open }) { | ||
21 | this.setState({ open }); | ||
22 | }, | ||
23 | render() { | 23 | render() { |
24 | return ( | 24 | return ( |
25 | <div> | 25 | <div> |
diff --git a/tests/TimePicker.spec.jsx b/tests/TimePicker.spec.jsx index 150f727..1ea3b8b 100644 --- a/tests/TimePicker.spec.jsx +++ b/tests/TimePicker.spec.jsx | |||
@@ -111,6 +111,33 @@ describe('TimePicker', () => { | |||
111 | done(); | 111 | done(); |
112 | }); | 112 | }); |
113 | }); | 113 | }); |
114 | |||
115 | it('support name', () => { | ||
116 | const picker = renderPicker({ | ||
117 | name: 'time-picker-form-name', | ||
118 | }); | ||
119 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, | ||
120 | 'rc-time-picker-input')[0]; | ||
121 | expect(input.name).to.be('time-picker-form-name'); | ||
122 | }); | ||
123 | |||
124 | it('support focus', () => { | ||
125 | const picker = renderPicker({ | ||
126 | name: 'time-picker-form-name', | ||
127 | }); | ||
128 | expect(picker.focus).to.be.a('function'); | ||
129 | }); | ||
130 | |||
131 | it('should be controlled by open', () => { | ||
132 | const picker = renderPicker({ | ||
133 | open: false, | ||
134 | }); | ||
135 | expect(picker.state.open).not.to.be.ok(); | ||
136 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, | ||
137 | 'rc-time-picker-input')[0]; | ||
138 | Simulate.click(input); | ||
139 | expect(picker.state.open).not.to.be.ok(); | ||
140 | }); | ||
114 | }); | 141 | }); |
115 | 142 | ||
116 | describe('render panel to body (without seconds)', () => { | 143 | describe('render panel to body (without seconds)', () => { |