Newer
Older
import { render, screen } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import React from 'react'
import { mockGlobalState } from 'tests/__mocks__/store'
describe('StepConsent component', () => {
it('should be rendered correctly', () => {
const { container } = render(
<StepConsent
sgeState={mockGlobalState.sgeConnect}
onChange={mockHandleChange}
/>
it('should change dataConsent and pdlConfirm value', async () => {
render(
<StepConsent
sgeState={mockGlobalState.sgeConnect}
onChange={mockHandleChange}
/>
const consentCheckbox = screen.getByLabelText(
'auth.enedissgegrandlyon.consentCheck1'
)
await userEvent.click(consentCheckbox)
expect(mockHandleChange).toHaveBeenCalledWith('dataConsent', true)
const pdlCheckbox = screen.getByLabelText(
'auth.enedissgegrandlyon.consentCheck2'
)
await userEvent.click(pdlCheckbox)
expect(mockHandleChange).toHaveBeenCalledWith('pdlConfirm', true)