Add test for nav

This commit is contained in:
bulby97 2021-09-08 08:37:02 +02:00
parent 3dadfe51b9
commit 738a4567d6
2 changed files with 79 additions and 0 deletions

View File

@ -0,0 +1,37 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<ContentTypeBuilderNav /> renders and matches the snapshot 1`] = `
.c0 {
border: 0;
-webkit-clip: rect(0 0 0 0);
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
<div>
<div
class="c0"
>
<p
aria-live="polite"
id="live-region-log"
role="log"
/>
<p
aria-live="polite"
id="live-region-status"
role="status"
/>
<p
aria-live="assertive"
id="live-region-alert"
role="alert"
/>
</div>
</div>
`;

View File

@ -0,0 +1,42 @@
/**
*
* Tests for ContentTypeBuilderNav
*
*/
import React from 'react';
import { render } from '@testing-library/react';
import { Router, Route } from 'react-router-dom';
import { createMemoryHistory } from 'history';
import Theme from '../../../../../../admin/admin/src/components/Theme';
import LanguageProvider from '../../../../../../admin/admin/src/components/LanguageProvider';
import en from '../../../../../../admin/admin/src/translations/en.json';
import ContentTypeBuilderNav from '../index';
const makeApp = () => {
const history = createMemoryHistory();
const messages = { en };
const localeNames = { en: 'English' };
return (
<LanguageProvider messages={messages} localeNames={localeNames}>
<Theme>
<Router history={history}>
<Route path="/plugins/content-type-builder">
<ContentTypeBuilderNav />
</Route>
</Router>
</Theme>
</LanguageProvider>
);
};
describe('<ContentTypeBuilderNav />', () => {
it('renders and matches the snapshot', () => {
const App = makeApp(ContentTypeBuilderNav);
const { container } = render(App);
expect(container).toMatchSnapshot();
});
});