Newer
Older
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import React from 'react'
import EcogestureSelectionRestart from './EcogestureSelectionRestart'
const mockedNavigate = jest.fn()
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useNavigate: () => mockedNavigate,
}))
const mockRestart = jest.fn()
describe('EcogestureSelectionRestart component', () => {
it('should be rendered correctly', () => {
<EcogestureSelectionRestart listLength={10} restart={mockRestart} />
)
it('should call go to the ecogesture view when user click on the button', async () => {
render(<EcogestureSelectionRestart listLength={10} restart={mockRestart} />)
await userEvent.click(
screen.getByText('ecogesture_selection.button_go_to_ecogesture')
)
expect(mockedNavigate).toHaveBeenCalledWith('/ecogestures?tab=0')
it('should call the restart when user click on the button', async () => {
render(<EcogestureSelectionRestart listLength={10} restart={mockRestart} />)
await userEvent.click(
screen.getByText('ecogesture_selection.button_continue')
)
expect(mockRestart).toHaveBeenCalledTimes(1)
})
})