Skip to content

Commit

Permalink
✅(frontend) fix test warning
Browse files Browse the repository at this point in the history
There was a missing fetch mock.
  • Loading branch information
jbpenrath committed Apr 20, 2023
1 parent 8084c0a commit b39ea4f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/frontend/js/widgets/Dashboard/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { fireEvent, getByText, render, screen } from '@testing-library/react';
import { fireEvent, getByText, render, screen, act } from '@testing-library/react';
import { IntlProvider } from 'react-intl';
import { QueryClientProvider } from '@tanstack/react-query';
import fetchMock from 'fetch-mock';
import { act } from 'react-dom/test-utils';
import {
RichieContextFactory as mockRichieContextFactory,
UserFactory,
Expand Down Expand Up @@ -58,14 +57,20 @@ describe('<Dashboard />', () => {
fetchMock.get('https://joanie.endpoint/api/v1.0/orders/', []);
fetchMock.get('https://joanie.endpoint/api/v1.0/credit-cards/', []);
fetchMock.get('https://joanie.endpoint/api/v1.0/addresses/', []);
fetchMock.get(
'https://joanie.endpoint/api/v1.0/enrollments/?page=1&page_size=10&was_created_by_order=false',
[],
);
});

afterEach(() => {
fetchMock.restore();
});

it('should redirect to the site root if user is not authenticated', () => {
render(<DashboardWithUser user={null} />);
it('should redirect to the site root if user is not authenticated', async () => {
await act(async () => {
render(<DashboardWithUser user={null} />);
});

expect(location.replace).toHaveBeenNthCalledWith(1, '/');
});
Expand Down

0 comments on commit b39ea4f

Please sign in to comment.