Untitled
unknown
plain_text
2 years ago
1.3 kB
2
Indexable
Never
import React from 'react'; import { cleanup, render } from '@testing-library/react'; import { store } from 'store/store'; import { Provider } from 'react-redux'; import CreateCompanyPage, { getServerSideProps } from 'pages/companies/add'; jest.mock('next-i18next/serverSideTranslations', () => ({ serverSideTranslations: (locale: string, files: string[]) => Promise.resolve({ locale, files }), })); const renderComponent = () => render( <Provider store={store}> <CreateCompanyPage /> </Provider> ); describe('Add company page tests', () => { afterEach(() => { cleanup(); }); it('should render the page', () => { const { container } = renderComponent(); expect(container).toMatchSnapshot(); }); describe('companies getServerSideProps tests', () => { it('should return translations', async () => { const result = await getServerSideProps( { locale: 'bg' } ) as never as { props: { locale: string, files: string[] } }; expect(result.props.locale).toEqual('bg'); expect(result.props.files).toEqual(['company', 'validations', 'common']); }); }); });