Skip to content
Snippets Groups Projects
ActionChoose.spec.tsx 1.5 KiB
Newer Older
  • Learn to ignore specific revisions
  • Guilhem CARRON's avatar
    Guilhem CARRON committed
    import { mount } from 'enzyme'
    
    import toJson from 'enzyme-to-json'
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    import { Provider } from 'react-redux'
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    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'
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    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,
        }
      })
    })
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    
    describe('ActionChoose component', () => {
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
      const store = createMockEcolyoStore({
        global: { ...mockGlobalState, fluidTypes: [0, 1, 2] },
        profile: mockProfileState,
      })
    
      it('should render correctly', async () => {
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
        const wrapper = mount(
          <Provider store={store}>
            <ActionChoose userChallenge={userChallengeData[1]} />
          </Provider>
        )
    
        await waitForComponentToPaint(wrapper)
        expect(toJson(wrapper)).toMatchSnapshot()
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
      })
      it('should render ActionBegin component', async () => {
        const wrapper = mount(
          <Provider store={store}>
            <ActionChoose userChallenge={userChallengeData[1]} />
          </Provider>
        )
        expect(wrapper.find(ActionBegin).exists()).toBeTruthy()
      })
    })