Skip to content
Snippets Groups Projects
StepConsent.spec.tsx 1.08 KiB
Newer Older
  • Learn to ignore specific revisions
  • Bastien DUMONT's avatar
    Bastien DUMONT committed
    import { render, screen } from '@testing-library/react'
    import { userEvent } from '@testing-library/user-event'
    
    import { mockSgeState } from 'tests/__mocks__/forms.mock'
    
    import StepConsent from './StepConsent'
    
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    const mockHandleChange = jest.fn()
    
    
    describe('StepConsent component', () => {
      it('should be rendered correctly', () => {
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
        const { container } = render(
    
          <StepConsent sgeState={mockSgeState} onChange={mockHandleChange} />
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
        expect(container).toMatchSnapshot()
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    
      it('should change dataConsent and pdlConfirm value', async () => {
    
        render(<StepConsent sgeState={mockSgeState} onChange={mockHandleChange} />)
    
        const consentCheckbox = screen.getByLabelText(
          'auth.enedissgegrandlyon.consentCheck1'
        )
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
        await userEvent.click(consentCheckbox)
        expect(mockHandleChange).toHaveBeenCalledWith('dataConsent', true)
    
    
        const pdlCheckbox = screen.getByLabelText(
          'auth.enedissgegrandlyon.consentCheck2'
        )
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
        await userEvent.click(pdlCheckbox)
        expect(mockHandleChange).toHaveBeenCalledWith('pdlConfirm', true)