From 9cdfbf12f50f0347c98f1cb3ae5741d742ca4409 Mon Sep 17 00:00:00 2001 From: Bastien DUMONT <bdumont@grandlyon.com> Date: Tue, 14 Nov 2023 15:58:50 +0000 Subject: [PATCH] test(rtl): splash --- src/components/Splash/SplashScreenError.spec.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/components/Splash/SplashScreenError.spec.tsx b/src/components/Splash/SplashScreenError.spec.tsx index 2f3837093..4f44a4380 100644 --- a/src/components/Splash/SplashScreenError.spec.tsx +++ b/src/components/Splash/SplashScreenError.spec.tsx @@ -1,4 +1,5 @@ -import Button from '@material-ui/core/Button' +import { render, screen } from '@testing-library/react' +import { userEvent } from '@testing-library/user-event' import { mount } from 'enzyme' import toJson from 'enzyme-to-json' import { InitStepsErrors } from 'models/initialisationSteps.model' @@ -23,11 +24,9 @@ describe('SplashScreenError component', () => { ) expect(toJson(component)).toMatchSnapshot() }) - it('should reload the page', () => { - const component = mount( - <SplashScreenError error={InitStepsErrors.CONSENT_ERROR} /> - ) - component.find(Button).first().simulate('click') + it('should reload the page', async () => { + render(<SplashScreenError error={InitStepsErrors.CONSENT_ERROR} />) + await userEvent.click(screen.getByRole('button')) expect(window.location.reload).toHaveBeenCalled() }) }) -- GitLab