Skip to content
Snippets Groups Projects
SplashScreenError.spec.tsx 983 B
Newer Older
  • Learn to ignore specific revisions
  • import { render, screen } from '@testing-library/react'
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    import { userEvent } from '@testing-library/user-event'
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    import { InitStepsErrors } from 'models/initialisationSteps.model'
    import React from 'react'
    import SplashScreenError from './SplashScreenError'
    
    
    describe('SplashScreenError component', () => {
    
      const reload = window.location.reload
    
      beforeAll(() => {
        Object.defineProperty(window, 'location', {
          value: { reload: jest.fn() },
        })
      })
    
      afterAll(() => {
        window.location.reload = reload
      })
    
      it('should be rendered correctly', () => {
    
        const { container } = render(
    
          <SplashScreenError error={InitStepsErrors.CONSENT_ERROR} />
        )
    
        expect(container).toMatchSnapshot()
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
      it('should reload the page', async () => {
        render(<SplashScreenError error={InitStepsErrors.CONSENT_ERROR} />)
    
        await userEvent.click(screen.getByRole('button'))
    
        expect(window.location.reload).toHaveBeenCalled()
      })
    })