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

View File

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