-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- TimePicker#getValue is now deprecated. - TimePicker#setValue is now deprecated. - Added value prop. - defaultTime is only used if value is not defined on props. - Added tests for TimePicker initialization behavior. - Adding utils/DateTime#formatTime Fixes #3094 Signed-off-by: rscnt <[email protected]>
- Loading branch information
1 parent
d4472ee
commit 2117dca
Showing
5 changed files
with
174 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react'; | ||
import TextField from 'text-field'; | ||
import TimePicker from 'time-picker/time-picker'; | ||
import DateTime from 'utils/date-time'; | ||
import TestUtils from 'react-addons-test-utils'; | ||
|
||
describe('TimePicker', () => { | ||
|
||
it('has to give value prop precedence over defaultTime', () => { | ||
let initialTime = new Date(1448967059892); // Tue, 01 Dec 2015 10:50:59 GMT | ||
let valueTime = DateTime.addHours(initialTime, 2); | ||
|
||
let render = TestUtils.renderIntoDocument( | ||
<TimePicker value={valueTime} format="ampm" locale="en-US" | ||
initialTime={initialTime} | ||
/> | ||
); | ||
|
||
let timeTextField = TestUtils.findRenderedComponentWithType(render, TextField); | ||
|
||
expect(timeTextField.props.value, DateTime.formatTime(valueTime)); | ||
}); | ||
|
||
it('takes defaulTime prop to set first value when value prop is missing', () => { | ||
let initialTime = new Date(1448967059892); // Tue, 01 Dec 2015 10:50:59 GMT | ||
|
||
let render = TestUtils.renderIntoDocument( | ||
<TimePicker format="ampm" locale="en-US" | ||
defaultTime={initialTime} | ||
/> | ||
); | ||
|
||
let timeTextField = TestUtils.findRenderedComponentWithType(render, TextField); | ||
|
||
expect(timeTextField.props.value, DateTime.formatTime(initialTime)); | ||
}); | ||
|
||
it('shows value prop if defaultTime is missing', () => { | ||
let initialTime = null; | ||
let valueTime = new Date(1448967059892); // Tue, 01 Dec 2015 10:50:59 GM | ||
|
||
let render = TestUtils.renderIntoDocument( | ||
<TimePicker value={valueTime} format="ampm" locale="en-US" | ||
defaultTime={initialTime} | ||
/> | ||
); | ||
|
||
let timeTextField = TestUtils.findRenderedComponentWithType(render, TextField); | ||
|
||
expect(timeTextField.props.value, DateTime.formatTime(valueTime)); | ||
}); | ||
|
||
}); |