Skip to content

Instantly share code, notes, and snippets.

@bruceharris
Created March 2, 2018 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bruceharris/d4ec5f4aff437b7de772e69138d9eba2 to your computer and use it in GitHub Desktop.
Save bruceharris/d4ec5f4aff437b7de772e69138d9eba2 to your computer and use it in GitHub Desktop.
React Unit Testing Example 15
describe('on unmount', () => {
it('should clear timeout', () => {
jest.useFakeTimers();
const wrapper = mount(
<LoadingIndicator isLoading={true}>
<div>ahoy!</div>
</LoadingIndicator>
);
wrapper.unmount();
expect(clearTimeout.mock.calls.length).toEqual(1);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment