diff --git a/src/components/Season/SeasonCard.spec.tsx b/src/components/Season/SeasonCard.spec.tsx index 8496d1de2cfb790a7d71bdf959f2381f2a4bf60d..8c44452c8c820a63f015bb8bde41cf1f0e6c8b82 100644 --- a/src/components/Season/SeasonCard.spec.tsx +++ b/src/components/Season/SeasonCard.spec.tsx @@ -5,10 +5,6 @@ import SeasonCardLocked from './SeasonCardLocked' import SeasonCardUnlocked from './SeasonCardUnlocked' import SeasonCardOnGoing from './SeasonCardOnGoing' import { userSeasonData } from '../../../test/__mocks__/userSeasonData.mock' -import StyledButtonValid from 'components/CommonKit/Button/StyledButtonValid' -import MockTheme from './MockTheme' -import * as Style from '@material-ui/core/styles' -import { createMuiTheme } from '@material-ui/core/styles' jest.mock('cozy-ui/transpiled/react/I18n', () => { return { @@ -21,18 +17,9 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => { }) jest.mock('@material-ui/core/styles/createMuiTheme', () => jest.fn()) -// const mockTheme = createMuiTheme({}) -// jest.spyOn(Style, 'createMuiTheme').mockReturnValue(mockTheme) -// const mockStyle = new CSSStyleDeclaration().setProperty('main', '#fff') -// jest.spyOn(window, 'getComputedStyle').mockReturnValue(mockStyle) -//TODO fis MUI theme error describe('SeasonCard component', () => { it('should be rendered correctly', () => { - // const mockStyle = new CSSStyleDeclaration() - // mockStyle.setProperty('color', '#fff') - // console.log('prop', mockStyle.getPropertyValue('color')) - // jest.spyOn(window, 'getComputedStyle').mockReturnValue(mockStyle) const component = shallow( <SeasonCard userSeason={userSeasonData[1]} diff --git a/src/components/Season/SeasonCardUnlocked.spec.tsx b/src/components/Season/SeasonCardUnlocked.spec.tsx index b46ae8b0c72ede7a4837802108d3bc20f9a85d41..dfa739de7ebbc5fe9f512241fa57e32d401245d3 100644 --- a/src/components/Season/SeasonCardUnlocked.spec.tsx +++ b/src/components/Season/SeasonCardUnlocked.spec.tsx @@ -3,6 +3,7 @@ import { shallow } from 'enzyme' import SeasonCardUnlocked from './SeasonCardUnlocked' import { userSeasonData } from '../../../test/__mocks__/userSeasonData.mock' import { globalStateData } from '../../../test/__mocks__/globalStateData.mock' +import StyledButtonValid from 'components/CommonKit/Button/StyledButtonValid' jest.mock('cozy-ui/transpiled/react/I18n', () => { return { @@ -13,13 +14,16 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => { }), } }) +jest.mock('@material-ui/core/styles/createMuiTheme', () => jest.fn()) +const mocklaunchSeason = jest.fn() + const mockUseSelector = globalStateData jest.mock('react-redux', () => ({ useSelector: jest.fn().mockResolvedValue(mockUseSelector), useDispatch: () => jest.fn(), })) -//TODO fis MUI theme error +//TODO fix click test describe('SeasonCardUnlocked component', () => { it('should be rendered correctly', () => { const component = shallow( @@ -29,12 +33,15 @@ describe('SeasonCardUnlocked component', () => { }) it('should launch the season', () => { - const mocklaunchSeason = jest.fn() const wrapper = shallow( <SeasonCardUnlocked userSeason={userSeasonData[0]} /> ) - wrapper.find('.launchButton').simulate('click') - expect(mocklaunchSeason).toBeCalledTimes(1) + wrapper + .find(StyledButtonValid) + .first() + .simulate('click') + console.log('button', wrapper.find(StyledButtonValid).first()) + expect(mocklaunchSeason).toHaveBeenCalled() }) // it('should open the fluid modal', () => {}) }) diff --git a/src/components/Season/SeasonView.spec.tsx b/src/components/Season/SeasonView.spec.tsx index fa6fa808e8c29072a4d2447be9c60ff1a4d7252f..02a0159ef274c7d5c3403414e137914a47f44dbb 100644 --- a/src/components/Season/SeasonView.spec.tsx +++ b/src/components/Season/SeasonView.spec.tsx @@ -8,12 +8,14 @@ const mockaHandleTouchStart = jest.fn() // const mockaHandleTouchEnd = jest.fn() const mockUseSelector = seasonStateDataFull +jest.mock('@material-ui/core/styles/createMuiTheme', () => jest.fn()) jest.mock('react-redux', () => ({ useSelector: jest.fn().mockResolvedValue(mockUseSelector), useDispatch: () => jest.fn(), })) +//TODO fix error userseasonlist undefined describe('SeasonView component', () => { it('should be rendered correctly', () => { const component = shallow(<SeasonView />).getElement() diff --git a/src/components/Season/SeasonView.tsx b/src/components/Season/SeasonView.tsx index 18274eb3971c03cbd7335776ee73705aaf014fa6..560b50d6114d4d8c933dd798932bfe59b79a3f68 100644 --- a/src/components/Season/SeasonView.tsx +++ b/src/components/Season/SeasonView.tsx @@ -92,7 +92,7 @@ const SeasonView: React.FC = () => { setTouchEnd(e.targetTouches[0].clientX) if (e.nativeEvent instanceof MouseEvent) setTouchEnd(e.clientX) } - console.log('userseasonlist', userSeasonList) + return ( <> <CozyBar titleKey={'COMMON.APP_CHALLENGE_TITLE'} /> diff --git a/src/components/Season/__snapshots__/SeasonCard.spec.tsx.snap b/src/components/Season/__snapshots__/SeasonCard.spec.tsx.snap index c5904934ac786fdebc4a1dbd24b07c3b855201ef..ff491cc77ea214149c7120d9da19327d55d808fe 100644 --- a/src/components/Season/__snapshots__/SeasonCard.spec.tsx.snap +++ b/src/components/Season/__snapshots__/SeasonCard.spec.tsx.snap @@ -32,7 +32,7 @@ exports[`SeasonCard component should be rendered correctly 1`] = ` "startDate": null, "state": 0, "success": 0, - "target": 40, + "target": 15, "title": "Tata", } } diff --git a/test/__mocks__/seasonEntity.mock.ts b/test/__mocks__/seasonEntity.mock.ts index e4bc32585fdc9e5fb6712466bf6d09e876aa1916..00abc464f3a18ad483a851673b4be5355be576cd 100644 --- a/test/__mocks__/seasonEntity.mock.ts +++ b/test/__mocks__/seasonEntity.mock.ts @@ -5,7 +5,7 @@ export const seasonEntityData: SeasonEntity = { id: 'SEASON0001', title: 'Nicolas Hublot', description: 'foobar', - target: 40, + target: 15, boss: bossEntity, quizType: 'cultureG', } diff --git a/test/__mocks__/userSeasonData.mock.ts b/test/__mocks__/userSeasonData.mock.ts index 78f017d6780f6e3065257eda65b137fa9a25ce53..f1bcd347893b1dd76ce100662662cc41490f3fe3 100644 --- a/test/__mocks__/userSeasonData.mock.ts +++ b/test/__mocks__/userSeasonData.mock.ts @@ -8,7 +8,7 @@ export const userSeasonData: UserSeason[] = [ title: 'Nicolas Hublot', description: 'foobar', state: UserSeasonState.UNLOCKED, - target: 40, + target: 15, progress: 0, boss: bossData, success: UserSeasonSuccess.ONGOING, @@ -21,7 +21,7 @@ export const userSeasonData: UserSeason[] = [ title: 'Tata', description: 'foobar', state: UserSeasonState.LOCKED, - target: 40, + target: 15, progress: 0, boss: bossData, success: UserSeasonSuccess.ONGOING, @@ -34,7 +34,7 @@ export const userSeasonData: UserSeason[] = [ title: 'Toto', description: 'foobar', state: UserSeasonState.ONGOING, - target: 40, + target: 15, progress: 0, boss: bossData, success: UserSeasonSuccess.ONGOING, @@ -50,7 +50,7 @@ export const userSeasonDefault: UserSeason[] = [ title: 'Nicolas Hublot', description: 'foobar', state: UserSeasonState.UNLOCKED, - target: 40, + target: 15, progress: 0, boss: bossDefault, success: UserSeasonSuccess.ONGOING, @@ -63,7 +63,7 @@ export const userSeasonDefault: UserSeason[] = [ title: 'titi', description: 'foobar', state: UserSeasonState.LOCKED, - target: 40, + target: 15, progress: 0, boss: bossDefault, success: UserSeasonSuccess.ONGOING, @@ -76,7 +76,7 @@ export const userSeasonDefault: UserSeason[] = [ title: 'tata', description: 'foobar', state: UserSeasonState.LOCKED, - target: 40, + target: 15, progress: 0, boss: bossDefault, success: UserSeasonSuccess.ONGOING,