Dashboard page: unit tests separated in different files

This commit is contained in:
gianantoniopini
2021-02-01 18:00:52 +01:00
parent 5ee077dac5
commit e39026c8b4
6 changed files with 583 additions and 483 deletions

View File

@ -0,0 +1,50 @@
import { screen, waitFor } from '@testing-library/react';
import { DatabaseConstants } from 'gatsby-plugin-firebase';
import { createResumeButtonDataTestId } from '../../../components/dashboard/CreateResume';
import setup, {
setupAndWaitForLoadingScreenToDisappear,
expectResumeToBeRenderedInPreview,
expectLoadingScreenToBeRendered,
waitForLoadingScreenToDisappear,
} from './helpers/dashboard';
const user = DatabaseConstants.user1;
it('renders loading screen', async () => {
await setup(user);
expect(expectLoadingScreenToBeRendered()).toBeUndefined();
await waitForLoadingScreenToDisappear();
});
it('renders document title', async () => {
await setupAndWaitForLoadingScreenToDisappear(user);
await waitFor(() => {
expect(document.title).toEqual('Dashboard | Reactive Resume');
});
});
it('renders create resume', async () => {
await setupAndWaitForLoadingScreenToDisappear(user);
await waitFor(() => {
expect(screen.getByText(/create resume/i)).toBeInTheDocument();
});
await waitFor(() => {
expect(
screen.getByTestId(createResumeButtonDataTestId),
).toBeInTheDocument();
});
});
it('renders preview of user resumes', async () => {
const userResumes = await setupAndWaitForLoadingScreenToDisappear(user);
expect(Object.keys(userResumes)).toHaveLength(2);
await expectResumeToBeRenderedInPreview(Object.values(userResumes)[0].name);
await expectResumeToBeRenderedInPreview(Object.values(userResumes)[1].name);
});