diff --git a/src/components/Connection/SGEConnect/StepAddress.spec.tsx b/src/components/Connection/SGEConnect/StepAddress.spec.tsx index e7e1326c249c7c046f6afce0d3856bfba13ee33a..62a897e6560feaaac4cae0d271dbae3ef63fe2ee 100644 --- a/src/components/Connection/SGEConnect/StepAddress.spec.tsx +++ b/src/components/Connection/SGEConnect/StepAddress.spec.tsx @@ -18,15 +18,13 @@ describe('StepAddress component', () => { }) describe('should change inputs', () => { - beforeEach(() => { + it('should change address value', async () => { render( <StepAddress sgeState={mockGlobalState.sgeConnect} onChange={mockHandleChange} /> ) - }) - it('should change address value', async () => { const input = screen.getByRole('textbox', { name: 'auth.enedissgegrandlyon.address', }) @@ -36,6 +34,12 @@ describe('StepAddress component', () => { expect(mockHandleChange).toHaveBeenCalledWith('address', 't') }) it('should change zipCode value', async () => { + render( + <StepAddress + sgeState={mockGlobalState.sgeConnect} + onChange={mockHandleChange} + /> + ) const input = screen.getByRole('spinbutton', { name: 'auth.enedissgegrandlyon.zipCode', }) @@ -46,6 +50,12 @@ describe('StepAddress component', () => { }) it('should change city value', async () => { + render( + <StepAddress + sgeState={mockGlobalState.sgeConnect} + onChange={mockHandleChange} + /> + ) const input = screen.getByRole('textbox', { name: 'auth.enedissgegrandlyon.city', }) diff --git a/src/components/EcogestureSelection/EcogestureSelectionDetail/EcogestureSelectionDetail.spec.tsx b/src/components/EcogestureSelection/EcogestureSelectionDetail/EcogestureSelectionDetail.spec.tsx index 5608a326dbb4161f40386bff9d8e374be2603b14..f16ad9ebe3cb38245bf2122ed0ecb53da6539755 100644 --- a/src/components/EcogestureSelection/EcogestureSelectionDetail/EcogestureSelectionDetail.spec.tsx +++ b/src/components/EcogestureSelection/EcogestureSelectionDetail/EcogestureSelectionDetail.spec.tsx @@ -20,25 +20,27 @@ describe('EcogestureSelectionDetail component', () => { }) describe('should click on buttons', () => { - let container: HTMLElement - beforeEach(async () => { - container = render( + it('should toggle more details', async () => { + render( <EcogestureSelectionDetail ecogesture={mockedEcogesturesData[0]} validate={mockValidate} title={mockedEcogesturesData[0].shortName} /> - ).container - await waitFor(() => null, { container }) - }) - - it('should toggle more details', async () => { + ) await act(async () => { await userEvent.click(screen.getByText('ecogesture_modal.show_more')) }) expect(screen.getByText('ecogesture_modal.show_less')).toBeInTheDocument() }) it('should call validate with objective to true', async () => { + render( + <EcogestureSelectionDetail + ecogesture={mockedEcogesturesData[0]} + validate={mockValidate} + title={mockedEcogesturesData[0].shortName} + /> + ) await act(async () => { await userEvent.click( screen.getByText('ecogesture_selection.button_objective') @@ -48,6 +50,13 @@ describe('EcogestureSelectionDetail component', () => { }) it('should call validate with doing to true', async () => { + render( + <EcogestureSelectionDetail + ecogesture={mockedEcogesturesData[0]} + validate={mockValidate} + title={mockedEcogesturesData[0].shortName} + /> + ) await act(async () => { await userEvent.click( screen.getByText('ecogesture_selection.button_doing') @@ -57,6 +66,13 @@ describe('EcogestureSelectionDetail component', () => { }) it('should call validate with objective and doing to false', async () => { + render( + <EcogestureSelectionDetail + ecogesture={mockedEcogesturesData[0]} + validate={mockValidate} + title={mockedEcogesturesData[0].shortName} + /> + ) await act(async () => { await userEvent.click( screen.getByText('ecogesture_selection.button_skip') diff --git a/src/components/WelcomeModal/WelcomeModal.spec.tsx b/src/components/WelcomeModal/WelcomeModal.spec.tsx index 0db03efefffaf7fdb00de4e109c994f91f473d99..e6104c84270c4a833d39aeba79a39661c8ca0ccc 100644 --- a/src/components/WelcomeModal/WelcomeModal.spec.tsx +++ b/src/components/WelcomeModal/WelcomeModal.spec.tsx @@ -52,24 +52,21 @@ describe('WelcomeModal component', () => { }) it('should not be rendered', () => { - const { container } = render( + render( <Provider store={store}> <WelcomeModal open={false} /> </Provider> ) - expect(container.firstChild).toBeNull() expect(screen.queryByRole('dialog')).not.toBeInTheDocument() }) describe('should test modal interactivity', () => { - beforeEach(() => { + it('should send mail and update profile when user click on the ok button', async () => { render( <Provider store={store}> <WelcomeModal open={true} /> </Provider> ) - }) - it('should send mail and update profile when user click on the ok button', async () => { await act(async () => { await userEvent.click( screen.getByText('onboarding.welcomeModal.button_valid') @@ -85,6 +82,11 @@ describe('WelcomeModal component', () => { }) it('should send mail and update profile when modal is closed by user', async () => { + render( + <Provider store={store}> + <WelcomeModal open={true} /> + </Provider> + ) await act(async () => { await userEvent.click( screen.getAllByLabelText(