Skip to content

Instantly share code, notes, and snippets.

@atmd83
Created February 27, 2018 12:48
Show Gist options
  • Save atmd83/21dde9ef0932a262763b6ff40397ed4f to your computer and use it in GitHub Desktop.
Save atmd83/21dde9ef0932a262763b6ff40397ed4f to your computer and use it in GitHub Desktop.
medium post updated describe
describe('when the props change', () => {
it('will publish the correct messages based on the prop', () => {
// lets give the component a 'value' prop
component = shallow(<Thing value={3} />);
// lets update the component with the same prop
component.setProps({ value: 3 });
expect(PubSub.publish).lastCalledWith('thing.will.receive.props');
// shouldComponentUpdate will return false
// so componentWillUpdate() will not call
expect(PubSub.publish).not.toHaveBeenCalledWith('thing.should.update');
expect(PubSub.publish).not.toHaveBeenCalledWith('thing.will.update');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment