Builder and Dashboard unit tests: fine tuning of assertions related to toast/notification

This commit is contained in:
gianantoniopini
2021-01-23 12:21:02 +01:00
parent 5317f5e525
commit 74335a1771
2 changed files with 16 additions and 6 deletions

View File

@ -2,6 +2,7 @@ import { navigate as mockNavigateFunction } from 'gatsby';
import React from 'react';
import {
fireEvent,
getByText,
render,
screen,
waitFor,
@ -117,9 +118,13 @@ describe('Builder', () => {
);
expect(mockNavigateFunction).toHaveBeenCalledWith('/app/dashboard');
await waitFor(() => {
expect(screen.getByRole('alert')).toBeInTheDocument();
});
const notification = await screen.findByRole('alert');
expect(
getByText(
notification,
/The resume you were looking for does not exist anymore/i,
),
).toBeInTheDocument();
await waitFor(() =>
expect(

View File

@ -1,6 +1,7 @@
import React from 'react';
import {
fireEvent,
getByText,
queryByText,
render,
screen,
@ -160,9 +161,13 @@ describe('Dashboard', () => {
});
it('displays notification', async () => {
await waitFor(() => {
expect(screen.getByRole('alert')).toBeInTheDocument();
});
const notification = await screen.findByRole('alert');
expect(
getByText(
notification,
new RegExp(`${resumeToDelete.name} was deleted successfully`, 'i'),
),
).toBeInTheDocument();
await waitForDatabaseRemoveToHaveCompleted();
});