Fix Registration tests

This commit is contained in:
Alex Gleason 2023-01-05 17:34:47 -06:00
parent b98073ee8f
commit 83c93a6d51
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -30,7 +30,10 @@ describe('<Registration />', () => {
fireEvent.submit(screen.getByTestId('button'), { preventDefault: () => {} }); fireEvent.submit(screen.getByTestId('button'), { preventDefault: () => {} });
}); });
expect(screen.getByTestId('toast')).toHaveTextContent(/welcome to/i); await waitFor(() => {
expect(screen.getByTestId('toast')).toHaveTextContent(/welcome to/i);
});
expect(screen.queryAllByRole('heading')).toHaveLength(0); expect(screen.queryAllByRole('heading')).toHaveLength(0);
}); });
}); });
@ -47,7 +50,9 @@ describe('<Registration />', () => {
fireEvent.submit(screen.getByTestId('button'), { preventDefault: () => {} }); fireEvent.submit(screen.getByTestId('button'), { preventDefault: () => {} });
}); });
expect(screen.getByTestId('toast')).toHaveTextContent(/this username has already been taken/i); await waitFor(() => {
expect(screen.getByTestId('toast')).toHaveTextContent(/this username has already been taken/i);
});
}); });
it('handles generic errors', async() => { it('handles generic errors', async() => {
@ -61,7 +66,9 @@ describe('<Registration />', () => {
fireEvent.submit(screen.getByTestId('button'), { preventDefault: () => {} }); fireEvent.submit(screen.getByTestId('button'), { preventDefault: () => {} });
}); });
expect(screen.getByTestId('toast')).toHaveTextContent(/failed to register your account/i); await waitFor(() => {
expect(screen.getByTestId('toast')).toHaveTextContent(/failed to register your account/i);
});
}); });
}); });