diff --git a/frontend/src/views/Account/AccountCreation/test/AccountEmailActivationView.test.tsx b/frontend/src/views/Account/AccountCreation/test/AccountEmailActivationView.test.tsx index 16741f3713..bd7378f1c0 100644 --- a/frontend/src/views/Account/AccountCreation/test/AccountEmailActivationView.test.tsx +++ b/frontend/src/views/Account/AccountCreation/test/AccountEmailActivationView.test.tsx @@ -1,6 +1,6 @@ import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { MemoryRouter as Router, Route } from 'react-router-dom'; +import { createMemoryRouter, RouterProvider } from 'react-router-dom'; import AccountEmailActivationView from '../AccountEmailActivationView'; import { Provider } from 'react-redux'; import { store } from '../../../../store/store'; @@ -11,16 +11,22 @@ describe('AccountEmailActivationView', () => { describe('Without passing an email in route state', () => { function setup() { + const router = createMemoryRouter( + [ + { path: '/inscription/email', element: 'Créer votre compte' }, + { + path: '/inscription/activation', + element: + } + ], + { + initialEntries: ['/inscription/activation'] + } + ); render( - - Créer votre compte - - - , + + ); } @@ -34,24 +40,26 @@ describe('AccountEmailActivationView', () => { describe('With an email', () => { function setup() { + const router = createMemoryRouter( + [ + { + path: '/inscription/activation', + element: + } + ], + { + initialEntries: [ + { + pathname: '/inscription/activation', + state: { email: 'ok@beta.gouv.fr' } + } + ] + } + ); render( - - - - , + + ); } @@ -59,7 +67,7 @@ describe('AccountEmailActivationView', () => { setup(); const title = screen.getByText( - 'Vous devez confirmer votre adresse mail.', + 'Vous devez confirmer votre adresse mail.' ); expect(title).toBeVisible(); @@ -68,7 +76,7 @@ describe('AccountEmailActivationView', () => { it('should send an email again', async () => { const sendActivationEmail = jest.spyOn( signupLinkApi.endpoints.sendActivationEmail, - 'initiate', + 'initiate' ); setup(); @@ -76,7 +84,7 @@ describe('AccountEmailActivationView', () => { await user.click(sendAgain); expect(sendActivationEmail).toHaveBeenCalledWith('ok@beta.gouv.fr', { - fixedCacheKey: undefined, + fixedCacheKey: undefined }); const sent = screen.getByText('Email envoyé.'); expect(sent).toBeVisible();