Updating 404 page to use react-testing-library

This commit is contained in:
Jeff Avallone 2019-03-24 12:59:31 -04:00
parent 58dc36b0c6
commit 5d700f47aa
2 changed files with 27 additions and 13 deletions

View File

@ -1,14 +1,19 @@
jest.mock('components/Metadata', () =>
require('__mocks__/component-mock')('components/Metadata'));
jest.mock('components/Message', () =>
require('__mocks__/component-mock')('components/Message'));
import React from 'react';
import { shallow } from 'enzyme';
import { render } from 'react-testing-library';
import { mockT } from 'i18n';
import { ErrorPage } from 'pages/404';
describe('Error Page', () => {
test('rendering', () => {
const component = shallow(
const { asFragment } = render(
<ErrorPage t={ mockT } />
);
expect(component).toMatchSnapshot();
expect(asFragment()).toMatchSnapshot();
});
});

View File

@ -1,19 +1,28 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Error Page rendering 1`] = `
<Fragment>
<withI18nextTranslation(Metadata)
title="TRANSLATE(Page Not Found)"
<DocumentFragment>
<span
data-component="withI18nextTranslation(Metadata)"
data-props="{
\\"title\\": \\"TRANSLATE(Page Not Found)\\"
}"
/>
<Message
heading="TRANSLATE(404 Page Not Found)"
type="error"
<span
data-component="Message"
data-props="{
\\"type\\": \\"error\\",
\\"heading\\": \\"TRANSLATE(404 Page Not Found)\\"
}"
>
<p>
<Trans>
<span
data-component="Trans"
data-props="{}"
>
The page you have requested could not be found.
</Trans>
</span>
</p>
</Message>
</Fragment>
</span>
</DocumentFragment>
`;