Skip to content
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

Merged
merged 3 commits into from
Jan 17, 2018

Conversation

majapw
Copy link
Collaborator

@majapw majapw commented Jan 16, 2018

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?

@majapw majapw added the semver-patch: fixes/refactors/etc Anything that's not major or minor. label Jan 16, 2018
@majapw majapw requested a review from ljharb January 16, 2018 18:09
ljharb
ljharb previously approved these changes Jan 16, 2018
const wrapper = shallow(<DateInput id="date" />).dive();
wrapper.setState({ dateString });
wrapper.instance().componentWillReceiveProps({ displayValue: '1991-07-13' });
expect(wrapper.state().dateString).to.equal('');
Copy link
Member

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

const wrapper = shallow(<DateInput id="date" />).dive();
wrapper.setState({ dateString });
wrapper.instance().componentWillReceiveProps({ displayValue: null });
expect(wrapper.state().dateString).to.equal(dateString);
Copy link
Member

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

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 86.329% when pulling 513bce6 on maja-uh-reopen-dateinput-issue into 44f3842 on master.

@@ -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));
Copy link
Collaborator

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 👍

@@ -89,6 +89,28 @@ describe('DateInput', () => {
});
});

describe('#componentWillReceiveProps', () => {
describe('nextProps.displayValue exists', () => {
it('sets state.displayString to \'\'', () => {
Copy link
Collaborator

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?

});

describe('nextProps.displayValue does not exist', () => {
it('does not change state.displayString', () => {
Copy link
Collaborator

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.

Copy link
Collaborator Author

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

@majapw majapw force-pushed the maja-uh-reopen-dateinput-issue branch from 513bce6 to 2f6f2cc Compare January 17, 2018 17:52
@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 86.329% when pulling 2f6f2cc on maja-uh-reopen-dateinput-issue into 602ce9a on master.

@majapw majapw merged commit 7e39a67 into master Jan 17, 2018
@majapw majapw deleted the maja-uh-reopen-dateinput-issue branch January 17, 2018 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-patch: fixes/refactors/etc Anything that's not major or minor.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants