Add test for updating dateFormat
| | |
| | | var Wrapper = React.createClass({ |
| | | getInitialState: function() { |
| | | return { |
| | | dateFormat: 'YYYY-mm-DD' |
| | | dateFormat: 'YYYY-MM-DD' |
| | | }; |
| | | }, |
| | | |
| | | updateFormat: function(format) { |
| | | console.log('changing state'); |
| | | this.setState({ |
| | | dateFormat: 'DD.mm.YYYY' |
| | | dateFormat: 'DD.MM.YYYY' |
| | | }); |
| | | }, |
| | | |
| | |
| | | |
| | | render: function() { |
| | | return React.createElement(DateTime, |
| | | { dateFormat: this.state.dateFormat, timeFormat: false, defaultValue: moment() }); |
| | | { dateFormat: this.state.dateFormat, timeFormat: false, defaultValue: moment() }); |
| | | } |
| | | }); |
| | | |
| | | ReactDOM.render( |
| | | React.createElement(Wrapper), |
| | | document.getElementById('datetime') |
| | | React.createElement(Wrapper), |
| | | document.getElementById('datetime') |
| | | ); |
| | |
| | | expect(utils.isOpen(component)).toBeTruthy(); |
| | | }); |
| | | |
| | | it('dateFormat -> prop changes and value updates accordingly', () => { |
| | | const date = new Date(2000, 0, 15, 2, 2, 2, 2), |
| | | component = utils.createDatetime({ |
| | | dateFormat: 'YYYY-MM-DD', timeFormat: false, defaultValue: date |
| | | }); |
| | | |
| | | const valueBefore = utils.getInputValue(component); |
| | | component.setProps({ dateFormat: 'DD.MM.YYYY'}); |
| | | const valueAfter = utils.getInputValue(component); |
| | | |
| | | expect(valueBefore).not.toEqual(valueAfter); |
| | | }); |
| | | |
| | | describe('with custom props', () => { |
| | | it('input=false', () => { |
| | | const component = utils.createDatetime({ input: false }); |