mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-08-08 15:54:19 -07:00
Addresses issue #11 items unit testing, snapshot testing. Follows instructions from https://www.gatsbyjs.com/docs/how-to/testing/unit-testing/ ; Adding typescript config, mocks, snapshot capabilities; initial test for j40footer and snapshot, readme update, test helper for intl plugin (#79)
This commit is contained in:
parent
a432a0d8c9
commit
ce7245b1a2
11 changed files with 3633 additions and 27 deletions
13
client/src/components/J40Footer.spec.tsx
Normal file
13
client/src/components/J40Footer.spec.tsx
Normal file
|
@ -0,0 +1,13 @@
|
|||
import React from 'react';
|
||||
import renderer from 'react-test-renderer';
|
||||
import J40Footer from './J40Footer';
|
||||
import {LocalizedComponent} from '../test/testHelpers';
|
||||
|
||||
describe('J40Footer', () => {
|
||||
it('renders correctly', () => {
|
||||
const tree = renderer
|
||||
.create(<LocalizedComponent><J40Footer /></LocalizedComponent>)
|
||||
.toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
});
|
28
client/src/components/__snapshots__/J40Footer.spec.tsx.snap
Normal file
28
client/src/components/__snapshots__/J40Footer.spec.tsx.snap
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`J40Footer renders correctly 1`] = `
|
||||
Array [
|
||||
<footer
|
||||
className="usa-footer"
|
||||
>
|
||||
<div
|
||||
className="usa-footer__primary-section"
|
||||
/>
|
||||
<div
|
||||
className="usa-footer__secondary-section"
|
||||
>
|
||||
<div
|
||||
className="grid-container"
|
||||
>
|
||||
<a
|
||||
href="/en/"
|
||||
onClick={[Function]}
|
||||
>
|
||||
Home
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>,
|
||||
",",
|
||||
]
|
||||
`;
|
16
client/src/test/testHelpers.tsx
Normal file
16
client/src/test/testHelpers.tsx
Normal file
|
@ -0,0 +1,16 @@
|
|||
import React, {ReactNode} from 'react';
|
||||
import {IntlContextProvider} from 'gatsby-plugin-intl';
|
||||
|
||||
interface ILocalizedComponentProps {
|
||||
children: ReactNode
|
||||
}
|
||||
|
||||
export const LocalizedComponent = ({children}: ILocalizedComponentProps) => {
|
||||
return (
|
||||
<>
|
||||
<IntlContextProvider value={{language: 'en', routed: true}}>
|
||||
{children}
|
||||
</IntlContextProvider>,
|
||||
</>
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue