Skip to content

Commit

Permalink
[Tests] ensure that the setState callback is actually called
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jan 6, 2018
1 parent 847b59b commit c262c69
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1381,11 +1381,14 @@ describe('shallow', () => {
}
const wrapper = shallow(<Foo />);
expect(wrapper.state()).to.eql({ id: 'foo' });
wrapper.setState({ id: 'bar' }, function callback(...args) {
expect(wrapper.state()).to.eql({ id: 'bar' });
expect(this.state).to.eql({ id: 'bar' });
expect(wrapper.find('div').prop('className')).to.eql('bar');
expect(args).to.eql(CALLING_SETSTATE_CALLBACK_WITH_UNDEFINED ? [undefined] : []);
return new Promise((resolve) => {
wrapper.setState({ id: 'bar' }, function callback(...args) {
expect(wrapper.state()).to.eql({ id: 'bar' });
expect(this.state).to.eql({ id: 'bar' });
expect(wrapper.find('div').prop('className')).to.eql('bar');
expect(args).to.eql(CALLING_SETSTATE_CALLBACK_WITH_UNDEFINED ? [undefined] : []);
resolve();
});
});
});

Expand Down

0 comments on commit c262c69

Please sign in to comment.