-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reopen https://github.com/airbnb/react-dates/pull/943 #955
Conversation
test/components/DateInput_spec.jsx
Outdated
const wrapper = shallow(<DateInput id="date" />).dive(); | ||
wrapper.setState({ dateString }); | ||
wrapper.instance().componentWillReceiveProps({ displayValue: '1991-07-13' }); | ||
expect(wrapper.state().dateString).to.equal(''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(wrapper.state()).to.have.property('dateString', '')
has a better failure message
test/components/DateInput_spec.jsx
Outdated
const wrapper = shallow(<DateInput id="date" />).dive(); | ||
wrapper.setState({ dateString }); | ||
wrapper.instance().componentWillReceiveProps({ displayValue: null }); | ||
expect(wrapper.state().dateString).to.equal(dateString); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(wrapper.state()).to.have.property('dateString', dateString)
has a better failure message
0df2ba8
to
513bce6
Compare
@@ -121,8 +121,7 @@ class DateInput extends React.Component { | |||
if (dateString[dateString.length - 1] === '?') { | |||
onKeyDownQuestionMark(e); | |||
} else { | |||
this.setState({ dateString }); | |||
onChange(dateString); | |||
this.setState({ dateString }, () => onChange(dateString)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call with this change 👍
test/components/DateInput_spec.jsx
Outdated
@@ -89,6 +89,28 @@ describe('DateInput', () => { | |||
}); | |||
}); | |||
|
|||
describe('#componentWillReceiveProps', () => { | |||
describe('nextProps.displayValue exists', () => { | |||
it('sets state.displayString to \'\'', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be state.dateString
instead of state.displayString
?
test/components/DateInput_spec.jsx
Outdated
}); | ||
|
||
describe('nextProps.displayValue does not exist', () => { | ||
it('does not change state.displayString', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here with dateString
instead of displayString
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right! Will fix
513bce6
to
2f6f2cc
Compare
Github... did something very strange for me. :/
Fixes #805
Sorry @rokborf, I appear to have messed up the log on your original PR (#943)
What's weird is I literally just pushed the same code I had locally as I did to your branch... but github decided there were no changes. ANYWAYS @ljharb can you take a look and stamp?