Newer
Older
import React from 'react'
import {
createMockEcolyoStore,
mockGlobalState,
mockProfileState,
} from 'tests/__mocks__/store'
import { waitForComponentToPaint } from 'tests/__mocks__/testUtils'
import { userChallengeData } from 'tests/__mocks__/userChallengeData.mock'
import ActionBegin from '../ActionBegin/ActionBegin'
import ActionChoose from './ActionChoose'
jest.mock('cozy-ui/transpiled/react/I18n', () => ({
useI18n: jest.fn(() => ({
t: (str: string) => str,
})),
}))
const mockGetEcogesturesByIds = jest.fn(() => [])
jest.mock('services/ecogesture.service', () => {
return jest.fn(() => {
return {
getEcogesturesByIds: mockGetEcogesturesByIds,
}
})
})
const store = createMockEcolyoStore({
global: { ...mockGlobalState, fluidTypes: [0, 1, 2] },
profile: mockProfileState,
})
it('should render correctly', async () => {
const wrapper = mount(
<Provider store={store}>
<ActionChoose userChallenge={userChallengeData[1]} />
</Provider>
)
await waitForComponentToPaint(wrapper)
expect(toJson(wrapper)).toMatchSnapshot()
})
it('should render ActionBegin component', async () => {
const wrapper = mount(
<Provider store={store}>
<ActionChoose userChallenge={userChallengeData[1]} />
</Provider>
)
expect(wrapper.find(ActionBegin).exists()).toBeTruthy()
})
})