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

Incremental PR towards #347 #462

Merged
merged 4 commits into from
Dec 6, 2020
Merged

Conversation

kolharsam
Copy link
Contributor

This PR is an incremental PR against #347 based on this comment

@changelogg
Copy link

changelogg bot commented Nov 22, 2020

Hey! Changelogs info seems to be missing or might be in incorrect format.
Please use the below template in PR description to ensure Changelogg can detect your changes:
- (tag) changelog_text
or
- tag: changelog_text
OR
You can add tag in PR header or while doing a commit too
(tag) PR header
or
tag: PR header
Valid tags: added / feat, changed, deprecated, fixed / fix, removed, security, build, ci, chore, docs, perf, refactor, revert, style, test
Thanks!
For more info, check out changelogg docs

@kolharsam
Copy link
Contributor Author

@s-yadav I'm not sure if a changelog entry is needed for this PR. I could just add one for #347 directly.

@s-yadav
Copy link
Owner

s-yadav commented Nov 22, 2020

@kolharsam Can you add failing test case, which this PR fixes.

@kolharsam
Copy link
Contributor Author

@s-yadav I have added some tests with regards to these changes but I failed to think of a failing test. Would passing an empty string be considered a failing test? Would appreciate some input here. If so, then we could change the condition to just be !props.value ? .... : ..... here

@s-yadav
Copy link
Owner

s-yadav commented Dec 6, 2020

Looks good. Approved.

@s-yadav s-yadav merged commit e37d22d into s-yadav:master Dec 6, 2020
@s-yadav
Copy link
Owner

s-yadav commented Dec 8, 2020

@kolharsam Looks like some specs are failing after this merge. Can you check that.

@kolharsam
Copy link
Contributor Author

@s-yadav I think the specs are failing because the original PR #347 hasn't been merged yet and these changes were increments over the mentioned PR. So yeah, I guess things would get fixed if we merge #347.

@s-yadav
Copy link
Owner

s-yadav commented Dec 11, 2020

Merged. Working.

@@ -56,6 +56,33 @@ describe('NumberFormat as input', () => {
expect(wrapper.find('input').instance().value).toEqual('$2,456,981');
});

it('should load the default value when initial value is null', () => {
const wrapper = mount(<NumberFormat value={null} defaultValue={89} />);
expect(wrapper.state().value).toEqual('89');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should never check for state value. As it's implementation details. Instead we should test for the end side-effect.

expect(wrapper.find('input').instance().value).toEqual('89');

expect(wrapper.state().value).toEqual('89');
});

it('should load the prevous valid value if the state is changed to null', () => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo on the statement.

  should load the previous valid value

const domInput = input.instance();

expect(domInput.value).toEqual('90');
wrapper.setState({testState: null});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This spec could be simplified you just mount <NumberFormat value={this.state.testState} /> and then change the props through setProps.

Also FYI. Try avoiding interacting with states in specs. You shouldn't depend much on implementation detail.

@s-yadav
Copy link
Owner

s-yadav commented Dec 18, 2020

@kolharsam The test is still failing when I am trying to run the test.
Screenshot 2020-12-18 at 12 18 07 PM

Also, missed reviewing specs earlier. Added some comments there.

@s-yadav
Copy link
Owner

s-yadav commented Dec 18, 2020

@kolharsam Can you try pulling code from origin and rerun the test.

@kolharsam
Copy link
Contributor Author

kolharsam commented Dec 19, 2020

@s-yadav thanks for the review remarks. Will be making a new PR to fix this ASAP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants