-
Notifications
You must be signed in to change notification settings - Fork 5
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
Fix CheckboxGroup tests to use process.nextTick() #721
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,12 +30,13 @@ describe('CheckboxGroup', () => { | |
<Checkbox label="The Sound of Music" value="soundofmusic" /> | ||
</CheckboxGroup> | ||
); | ||
|
||
const childCheckboxes = component.find('Checkbox'); | ||
const firstChild = childCheckboxes.at(0); | ||
const event = { target: { value: 'terminator', checked: false } }; | ||
const event = { target: { value: 'terminator' } }; | ||
firstChild.simulate('change', event); | ||
expect(component.state().value).to.eql({ terminator: false, predator: true, soundofmusic: false }); | ||
process.nextTick(() => { | ||
expect(component.state().value).to.eql({ terminator: false, predator: true, soundofmusic: false }); | ||
}); | ||
expect(onChangeGroup.callCount).to.equal(1); | ||
expect(onChangeIndividual.callCount).to.equal(1); | ||
}); | ||
|
@@ -54,7 +55,7 @@ describe('CheckboxGroup', () => { | |
}); | ||
|
||
it('should handle change events without a custom onChange handler', () => { | ||
const event = { target: { value: 'terminator', checked: true } }; | ||
const event = { target: { value: 'terminator' } }; | ||
const component = shallow( | ||
<CheckboxGroup name="movies"> | ||
<Checkbox label="The Terminator" value="terminator" /> | ||
|
@@ -64,7 +65,9 @@ describe('CheckboxGroup', () => { | |
); | ||
const firstChild = component.find('Checkbox').at(0); | ||
firstChild.simulate('change', event); | ||
expect(component.state().value).to.eql({ terminator: true, predator: false, soundofmusic: false }); | ||
process.nextTick(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like this is a good retro learned to add and talk about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, once we're sure what we've learned... so far it's all very weird. Multiple discussions on github but no resolution that works, at least, not for our use case:
|
||
expect(component.state().value).to.eql({ terminator: true, predator: false, soundofmusic: false }); | ||
}); | ||
}); | ||
|
||
it('should handle props changes', () => { | ||
|
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 need to pass in
done()
to ensure that the test will finish afternextTick()
is executedThere 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 pickup man
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.
When I do that, the test fails... go figure.