Newer
Older
import { render, screen } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import React from 'react'
import { mockSgeState } from 'tests/__mocks__/forms.mock'
describe('StepConsent component', () => {
it('should be rendered correctly', () => {
<StepConsent sgeState={mockSgeState} onChange={mockHandleChange} />
it('should change dataConsent and pdlConfirm value', async () => {
render(<StepConsent sgeState={mockSgeState} 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)