update components tests to use mountWithContexts when relevant

This commit is contained in:
John Mitchell
2019-04-22 16:34:33 -04:00
parent 986641de9f
commit 261980f18e
12 changed files with 399 additions and 546 deletions

View File

@@ -1,6 +1,5 @@
import React from 'react';
import { mount } from 'enzyme';
import { I18nProvider } from '@lingui/react';
import { mountWithContexts } from '../enzymeHelpers';
import About from '../../src/components/About';
describe('<About />', () => {
@@ -8,20 +7,16 @@ describe('<About />', () => {
let closeButton;
const onClose = jest.fn();
test('initially renders without crashing', () => {
aboutWrapper = mount(
<I18nProvider>
<About isOpen onClose={onClose} />
</I18nProvider>
aboutWrapper = mountWithContexts(
<About isOpen onClose={onClose} />
);
expect(aboutWrapper.length).toBe(1);
aboutWrapper.unmount();
});
test('close button calls onClose handler', () => {
aboutWrapper = mount(
<I18nProvider>
<About isOpen onClose={onClose} />
</I18nProvider>
aboutWrapper = mountWithContexts(
<About isOpen onClose={onClose} />
);
closeButton = aboutWrapper.find('AboutModalBoxCloseButton Button');
closeButton.simulate('click');