Newer
Older

Guilhem CARRON
committed
import React from 'react'
import { shallow } from 'enzyme'
import ChallengeCard from './ChallengeCard'
import ChallengeCardLocked from './ChallengeCardLocked'
import ChallengeCardUnlocked from './ChallengeCardUnlocked'
import ChallengeCardOnGoing from './ChallengeCardOnGoing'
import { userChallengeData } from '../../../tests/__mocks__/userChallengeData.mock'

Guilhem CARRON
committed
jest.mock('cozy-ui/transpiled/react/I18n', () => {
return {
useI18n: jest.fn(() => {
return {
t: (str: string) => str,
}
}),
}
})
const mockMoveToSlide = jest.fn()
describe('ChallengeCard component', () => {

Guilhem CARRON
committed
it('should be rendered correctly', () => {
const component = shallow(
userChallenge={userChallengeData[1]}

Guilhem CARRON
committed
indexSlider={0}
index={0}
cardWidth={200}
cardHeight={400}
moveToSlide={mockMoveToSlide}

Guilhem CARRON
committed
/>
).getElement()
expect(component).toMatchSnapshot()
})
it('should render locked Card', () => {
const wrapper = shallow(
userChallenge={userChallengeData[4]}

Guilhem CARRON
committed
indexSlider={0}
index={0}
cardWidth={200}
cardHeight={400}
moveToSlide={mockMoveToSlide}

Guilhem CARRON
committed
/>
)
expect(wrapper.find(ChallengeCardLocked).exists()).toBeTruthy()

Guilhem CARRON
committed
})
it('should render unlocked Card', () => {
const wrapper = shallow(
userChallenge={userChallengeData[3]}

Guilhem CARRON
committed
indexSlider={0}
index={0}
cardWidth={200}
cardHeight={400}
moveToSlide={mockMoveToSlide}

Guilhem CARRON
committed
/>
)
expect(wrapper.find(ChallengeCardUnlocked).exists()).toBeTruthy()

Guilhem CARRON
committed
})
it('should render ongoing Card', () => {
const wrapper = shallow(
userChallenge={userChallengeData[2]}

Guilhem CARRON
committed
indexSlider={0}
index={0}
cardWidth={200}
cardHeight={400}
moveToSlide={mockMoveToSlide}

Guilhem CARRON
committed
/>
)
expect(wrapper.find(ChallengeCardOnGoing).exists()).toBeTruthy()