Newer
Older
import { render, screen, waitFor } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import React from 'react'
import { Provider } from 'react-redux'
import {
AllEcogestureData,
defaultEcogestureData,
} from 'tests/__mocks__/actionData.mock'
import { mockedEcogesturesData } from 'tests/__mocks__/ecogesturesData.mock'
import {
createMockEcolyoStore,
mockGlobalState,
mockProfileState,
} from 'tests/__mocks__/store'
import { userChallengeData } from 'tests/__mocks__/userChallengeData.mock'
import ActionBegin from './ActionBegin'

Hugo SUBTIL
committed
})
describe('ActionBegin component', () => {
it('should render correctly', async () => {
const store = createMockEcolyoStore({
global: { ...mockGlobalState, fluidTypes: [0, 1, 2] },
profile: mockProfileState,

Hugo SUBTIL
committed
<Provider store={store}>
<ActionBegin
action={defaultEcogestureData[1]}
setShowList={jest.fn()}
userChallenge={userChallengeData[1]}
setFocus={jest.fn()}
await waitFor(() => null, { container })
expect(container).toMatchSnapshot()
})
it('should render correctly with custom action', async () => {
AllEcogestureData[0],
AllEcogestureData[5],
AllEcogestureData[2],
])
const store = createMockEcolyoStore({
global: { ...mockGlobalState, fluidTypes: [0, 1, 2] },
profile: { ...mockProfileState, isProfileTypeCompleted: true },
action={mockedEcogesturesData[1]}
setShowList={jest.fn()}
userChallenge={userChallengeData[1]}
setFocus={jest.fn()}
expect(screen.getByText('Coup de vent')).toBeInTheDocument()
it('should open launch Modal', async () => {
const store = createMockEcolyoStore({
global: { ...mockGlobalState, fluidTypes: [0, 1, 2] },
profile: mockProfileState,

Hugo SUBTIL
committed
<Provider store={store}>
<ActionBegin
action={defaultEcogestureData[1]}
setShowList={jest.fn()}
userChallenge={userChallengeData[1]}
setFocus={jest.fn()}
await userEvent.click(screen.getByText('action.apply'))
expect(await screen.findByRole('dialog')).toBeInTheDocument()