From b39ea4fb4b9a16ef2a8c2eca37307c5231cd7224 Mon Sep 17 00:00:00 2001 From: jbpenrath Date: Thu, 20 Apr 2023 17:07:21 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85(frontend)=20fix=20test=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There was a missing fetch mock. --- src/frontend/js/widgets/Dashboard/index.spec.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/frontend/js/widgets/Dashboard/index.spec.tsx b/src/frontend/js/widgets/Dashboard/index.spec.tsx index 859664e24d..630acff6b6 100644 --- a/src/frontend/js/widgets/Dashboard/index.spec.tsx +++ b/src/frontend/js/widgets/Dashboard/index.spec.tsx @@ -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, @@ -58,14 +57,20 @@ describe('', () => { 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(); + it('should redirect to the site root if user is not authenticated', async () => { + await act(async () => { + render(); + }); expect(location.replace).toHaveBeenNthCalledWith(1, '/'); });