Newer
Older
import { render, screen } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import toJson from 'enzyme-to-json'
import { InitStepsErrors } from 'models/initialisationSteps.model'
import React from 'react'
import SplashScreenError from './SplashScreenError'
describe('SplashScreenError component', () => {

Hugo SUBTIL
committed
const reload = window.location.reload
beforeAll(() => {
Object.defineProperty(window, 'location', {
value: { reload: jest.fn() },
})
})
afterAll(() => {
window.location.reload = reload
})
const component = mount(
<SplashScreenError error={InitStepsErrors.CONSENT_ERROR} />
)
expect(toJson(component)).toMatchSnapshot()
it('should reload the page', async () => {
render(<SplashScreenError error={InitStepsErrors.CONSENT_ERROR} />)
await userEvent.click(screen.getByRole('button'))
expect(window.location.reload).toHaveBeenCalled()
})
})