Skip to content

Instantly share code, notes, and snippets.

@bruceharris
Created March 2, 2018 16:14
Show Gist options
  • Save bruceharris/16c16e7a4c39355125f315c053c18c31 to your computer and use it in GitHub Desktop.
Save bruceharris/16c16e7a4c39355125f315c053c18c31 to your computer and use it in GitHub Desktop.
React Unit Testing Example 7
describe('when isLoading is true', () => {
describe('given 200ms have elapsed', () => {
it('should render loading indicator', () => {
jest.useFakeTimers();
const wrapper = mount(
<LoadingIndicator isLoading={true}>
<div>ahoy!</div>
</LoadingIndicator>
);
jest.runAllTimers();
expect(wrapper.html()).toBe(<div>loading...</div>);
wrapper.unmount();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment