diff --git a/.vscode/settings.json b/.vscode/settings.json index 379318f79a5162c138c561f6cbc3a4899dab5d2a..7f5cf2b2b27149237b6d777af535f4a000cb4f62 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -131,5 +131,6 @@ "usageevent", "Usain", "userchallenge" - ] + ], + "typescript.tsdk": "node_modules/typescript/lib" } diff --git a/src/components/Charts/AxisRight.tsx b/src/components/Charts/AxisRight.tsx index 710b50b34260c9918f952dd6ba6d0cc695ce9714..7ba81a2e94c7a921985dd33332974c52b3d8fcfd 100644 --- a/src/components/Charts/AxisRight.tsx +++ b/src/components/Charts/AxisRight.tsx @@ -37,7 +37,7 @@ const AxisRight = ({ .tickSize(-width) .tickSizeOuter(0) .tickFormat(d => - d >= 1000 && fluidStyle !== 'MULTIFLUID' + Number(d) >= 1000 && fluidStyle !== 'MULTIFLUID' ? typeof d === 'number' ? `${d / 1000} ${t('FLUID.' + fluidStyle + '.MEGAUNIT')}` : `${d.valueOf() / 1000} ${t( diff --git a/src/components/CommonKit/Card/StyledCard.spec.tsx b/src/components/CommonKit/Card/StyledCard.spec.tsx index 59f7d4dcd2f8aaa19b90e84891a178bcffc97d34..e302e4f5c08be287a9fce2982230e7e25cd841cc 100644 --- a/src/components/CommonKit/Card/StyledCard.spec.tsx +++ b/src/components/CommonKit/Card/StyledCard.spec.tsx @@ -4,7 +4,7 @@ import React from 'react' import StyledCard from './StyledCard' describe('StyledCard component test', () => { - it('should render correctly Electricty StyledCard', () => { + it('should render correctly Electricity StyledCard', () => { const wrapper = mount(<StyledCard fluidType={FluidType.ELECTRICITY} />) expect(wrapper.getElement()).toMatchSnapshot() }) diff --git a/src/components/CommonKit/Card/__snapshots__/StyledCard.spec.tsx.snap b/src/components/CommonKit/Card/__snapshots__/StyledCard.spec.tsx.snap index 5d0d39416eca9070294430421b7e184ce602b89c..52bb45d8bd676b5fb217f3ea9195340af328efaf 100644 --- a/src/components/CommonKit/Card/__snapshots__/StyledCard.spec.tsx.snap +++ b/src/components/CommonKit/Card/__snapshots__/StyledCard.spec.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`StyledCard component test should render correctly Electricty StyledCard 1`] = ` +exports[`StyledCard component test should render correctly Electricity StyledCard 1`] = ` <StyledCard fluidType={0} /> diff --git a/src/components/CommonKit/Switch/StyledSwitch.spec.tsx b/src/components/CommonKit/Switch/StyledSwitch.spec.tsx index 2e585e6a7f3e701c5d50581246be3210117e5363..b3605a86cb94e5fc6e909b6f83b65692c7006bb6 100644 --- a/src/components/CommonKit/Switch/StyledSwitch.spec.tsx +++ b/src/components/CommonKit/Switch/StyledSwitch.spec.tsx @@ -4,7 +4,7 @@ import React from 'react' import StyledSwitch from './StyledSwitch' describe('StyledSwitch component test', () => { - it('should render correctly electricty StyledSwitch', () => { + it('should render correctly electricity StyledSwitch', () => { const wrapper = mount(<StyledSwitch fluidType={FluidType.ELECTRICITY} />) expect(wrapper.getElement()).toMatchSnapshot() diff --git a/src/components/CommonKit/Switch/__snapshots__/StyledSwitch.spec.tsx.snap b/src/components/CommonKit/Switch/__snapshots__/StyledSwitch.spec.tsx.snap index 14ab2c5e208a9f9476926663179baeba853df57d..a69f06614469b151eed0b9a94b44c6d9ebfd0247 100644 --- a/src/components/CommonKit/Switch/__snapshots__/StyledSwitch.spec.tsx.snap +++ b/src/components/CommonKit/Switch/__snapshots__/StyledSwitch.spec.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`StyledSwitch component test should render correctly electricty StyledSwitch 1`] = ` +exports[`StyledSwitch component test should render correctly electricity StyledSwitch 1`] = ` <StyledSwitch fluidType={0} /> diff --git a/src/components/ConsumptionVisualizer/DataloadSectionValue.tsx b/src/components/ConsumptionVisualizer/DataloadSectionValue.tsx index e336163753a8e9fc10afd32e0fd41dbe9de6856f..72ed67a78d4c991c0b00965ff0010ae6014464d8 100644 --- a/src/components/ConsumptionVisualizer/DataloadSectionValue.tsx +++ b/src/components/ConsumptionVisualizer/DataloadSectionValue.tsx @@ -39,10 +39,15 @@ const DataloadSectionValue = ({ ) } + const formattedValue = formatNumberValues( + dataload.value, + FluidType[fluidType], + true + ) + return ( <> - {formatNumberValues(dataload.value, FluidType[fluidType], true) >= - 1000 ? ( + {Number(formattedValue) >= 1000 ? ( <> {formatNumberValues(dataload.value, FluidType[fluidType])} <span className="text-18-normal"> diff --git a/src/components/EcogestureForm/EcogestureFormSingleChoice.spec.tsx b/src/components/EcogestureForm/EcogestureFormSingleChoice.spec.tsx index 08b6e351d70524280a3448f315285a292e598b6c..1f961c4a03fcb1dbd74113a1d55ba8b9c1c8f734 100644 --- a/src/components/EcogestureForm/EcogestureFormSingleChoice.spec.tsx +++ b/src/components/EcogestureForm/EcogestureFormSingleChoice.spec.tsx @@ -45,7 +45,7 @@ describe('EcogestureFormSingleChoice component', () => { <Provider store={store}> <EcogestureFormSingleChoice step={0} - viewedStep={-1} + viewedStep={1} setNextStep={mockHandleNextStep} setPreviousStep={mockHandlePreviousStep} profileEcogesture={mockProfileEcogesture} @@ -61,7 +61,7 @@ describe('EcogestureFormSingleChoice component', () => { <Provider store={store}> <EcogestureFormSingleChoice step={0} - viewedStep={-1} + viewedStep={1} setNextStep={mockHandleNextStep} setPreviousStep={mockHandlePreviousStep} profileEcogesture={mockProfileEcogesture} @@ -79,7 +79,7 @@ describe('EcogestureFormSingleChoice component', () => { <Provider store={store}> <EcogestureFormSingleChoice step={0} - viewedStep={-1} + viewedStep={1} setNextStep={mockHandleNextStep} setPreviousStep={mockHandlePreviousStep} profileEcogesture={mockProfileEcogesture} diff --git a/src/components/EcogestureForm/__snapshots__/EcogestureFormSingleChoice.spec.tsx.snap b/src/components/EcogestureForm/__snapshots__/EcogestureFormSingleChoice.spec.tsx.snap index 78708be125a12ebf084aa15ad7387fd81f4640cd..8dfe3731ddfe10627e288544994e65b4ae2fdd5a 100644 --- a/src/components/EcogestureForm/__snapshots__/EcogestureFormSingleChoice.spec.tsx.snap +++ b/src/components/EcogestureForm/__snapshots__/EcogestureFormSingleChoice.spec.tsx.snap @@ -35,7 +35,7 @@ exports[`EcogestureFormSingleChoice component should be rendered correctly 1`] = setNextStep={[MockFunction]} setPreviousStep={[MockFunction]} step={0} - viewedStep={-1} + viewedStep={1} > <div className="ecogesture-profile-container" @@ -49,12 +49,12 @@ exports[`EcogestureFormSingleChoice component should be rendered correctly 1`] = ecogesture_form.heating_type.question </div> <label - className="radio_short" + className="radio_short answer-checked" key="0" > <input - checked={false} - className="" + checked={true} + className="checked-input" name="individual" onChange={[Function]} type="radio" @@ -78,7 +78,7 @@ exports[`EcogestureFormSingleChoice component should be rendered correctly 1`] = </label> </div> <FormNavigation - disableNextButton={true} + disableNextButton={false} handleNext={[Function]} handlePrevious={[Function]} isEcogesture={true} @@ -196,19 +196,19 @@ exports[`EcogestureFormSingleChoice component should be rendered correctly 1`] = </WithStyles(ForwardRef(Button))> <WithStyles(ForwardRef(Button)) aria-label="profile_type.accessibility.button_next" - className="profile-navigation-button disabled" + className="profile-navigation-button" classes={ Object { "label": "text-16-bold", "root": "btn-profile-next", } } - disabled={true} + disabled={false} onClick={[Function]} > <ForwardRef(Button) aria-label="profile_type.accessibility.button_next" - className="profile-navigation-button disabled" + className="profile-navigation-button" classes={ Object { "colorInherit": "MuiButton-colorInherit", @@ -242,14 +242,14 @@ exports[`EcogestureFormSingleChoice component should be rendered correctly 1`] = "textSizeSmall": "MuiButton-textSizeSmall", } } - disabled={true} + disabled={false} onClick={[Function]} > <WithStyles(ForwardRef(ButtonBase)) aria-label="profile_type.accessibility.button_next" - className="MuiButton-root btn-profile-next MuiButton-text profile-navigation-button disabled Mui-disabled" + className="MuiButton-root btn-profile-next MuiButton-text profile-navigation-button" component="button" - disabled={true} + disabled={false} focusRipple={true} focusVisibleClassName="Mui-focusVisible" onClick={[Function]} @@ -257,7 +257,7 @@ exports[`EcogestureFormSingleChoice component should be rendered correctly 1`] = > <ForwardRef(ButtonBase) aria-label="profile_type.accessibility.button_next" - className="MuiButton-root btn-profile-next MuiButton-text profile-navigation-button disabled Mui-disabled" + className="MuiButton-root btn-profile-next MuiButton-text profile-navigation-button" classes={ Object { "disabled": "Mui-disabled", @@ -266,7 +266,7 @@ exports[`EcogestureFormSingleChoice component should be rendered correctly 1`] = } } component="button" - disabled={true} + disabled={false} focusRipple={true} focusVisibleClassName="Mui-focusVisible" onClick={[Function]} @@ -274,8 +274,8 @@ exports[`EcogestureFormSingleChoice component should be rendered correctly 1`] = > <button aria-label="profile_type.accessibility.button_next" - className="MuiButtonBase-root MuiButton-root btn-profile-next MuiButton-text profile-navigation-button disabled Mui-disabled Mui-disabled" - disabled={true} + className="MuiButtonBase-root MuiButton-root btn-profile-next MuiButton-text profile-navigation-button" + disabled={false} onBlur={[Function]} onClick={[Function]} onDragLeave={[Function]} @@ -288,7 +288,7 @@ exports[`EcogestureFormSingleChoice component should be rendered correctly 1`] = onTouchEnd={[Function]} onTouchMove={[Function]} onTouchStart={[Function]} - tabIndex={-1} + tabIndex={0} type="button" > <span @@ -296,6 +296,34 @@ exports[`EcogestureFormSingleChoice component should be rendered correctly 1`] = > profile_type.form.button_next > </span> + <WithStyles(memo) + center={false} + > + <ForwardRef(TouchRipple) + center={false} + classes={ + Object { + "child": "MuiTouchRipple-child", + "childLeaving": "MuiTouchRipple-childLeaving", + "childPulsate": "MuiTouchRipple-childPulsate", + "ripple": "MuiTouchRipple-ripple", + "ripplePulsate": "MuiTouchRipple-ripplePulsate", + "rippleVisible": "MuiTouchRipple-rippleVisible", + "root": "MuiTouchRipple-root", + } + } + > + <span + className="MuiTouchRipple-root" + > + <TransitionGroup + childFactory={[Function]} + component={null} + exit={true} + /> + </span> + </ForwardRef(TouchRipple)> + </WithStyles(memo)> </button> </ForwardRef(ButtonBase)> </WithStyles(ForwardRef(ButtonBase))> diff --git a/src/components/FluidChart/FluidChartSlide.tsx b/src/components/FluidChart/FluidChartSlide.tsx index 0497c9d27028e89378f6764a629364002f681f8e..b272ab25a177fc30f98ca24ebe55542e199ce9a1 100644 --- a/src/components/FluidChart/FluidChartSlide.tsx +++ b/src/components/FluidChart/FluidChartSlide.tsx @@ -45,7 +45,7 @@ const FluidChartSlide: React.FC<FluidChartSlideProps> = ({ comparisonData: null, }) const [isDataLoaded, setIsDataLoaded] = useState<boolean>(false) - const [timeStep, setTimeStep] = useState<TimeStep>(99) + const [timeStep, setTimeStep] = useState<TimeStep>(TimeStep.WEEK) useEffect(() => { let subscribed = true diff --git a/src/components/Splash/SplashRoot.spec.tsx b/src/components/Splash/SplashRoot.spec.tsx index 6cb1bdd7b2a2ed679c6f72855a5525a4cc945954..18e45c09edb558e89e47b2d3cc25d57070afb514 100644 --- a/src/components/Splash/SplashRoot.spec.tsx +++ b/src/components/Splash/SplashRoot.spec.tsx @@ -21,7 +21,7 @@ describe('SplashRoot component', () => { it('should be rendered correctly', () => { mockUseSelector.mockReturnValue(userChallengeExplo1OnGoing) mockUseDispatch.mockReturnValue(jest.fn()) - const component = mount(<SplashRoot>children</SplashRoot>).getElement() + const component = mount(<SplashRoot>children</SplashRoot>) expect(toJson(component)).toMatchSnapshot() }) }) diff --git a/src/components/Splash/__snapshots__/SplashRoot.spec.tsx.snap b/src/components/Splash/__snapshots__/SplashRoot.spec.tsx.snap index cc8029032259ae786424aab72473e829c45eec6c..0da1b0c6c7c37d42ee372c08ea2cbe6aef628683 100644 --- a/src/components/Splash/__snapshots__/SplashRoot.spec.tsx.snap +++ b/src/components/Splash/__snapshots__/SplashRoot.spec.tsx.snap @@ -1,3 +1,63 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`SplashRoot component should be rendered correctly 1`] = `undefined`; +exports[`SplashRoot component should be rendered correctly 1`] = ` +<SplashRoot> + <div + className="splash-root" + style={ + Object { + "transitionDuration": "1s", + } + } + > + <SplashScreen + initStep={0} + > + <div + className="splash-content" + > + <div + className="splash-loader" + > + <img + alt="Chargement" + src="test-file-stub" + /> + <span> + Ecolyo + </span> + <div + className="splash-progress" + > + <div + className="splash-progress-bar-container" + > + <div + className="splash-progress-bar-content" + style={ + Object { + "width": "10%", + } + } + /> + </div> + </div> + </div> + <div + className="step-label text-18-normal" + > + splashscreen.step.0 + </div> + <div + className="splash-logos-container" + > + <img + alt="ensemble de logos" + src="test-file-stub" + /> + </div> + </div> + </SplashScreen> + </div> +</SplashRoot> +`; diff --git a/src/services/challenge.service.spec.ts b/src/services/challenge.service.spec.ts index fdd71daf062d3793e51a154b329b9c3fb4cf59b0..b05f55465cffc743227c81ea9e673f3e68cd5a0f 100644 --- a/src/services/challenge.service.spec.ts +++ b/src/services/challenge.service.spec.ts @@ -38,7 +38,7 @@ import { userExploration1, userExploration4, userExploration4_0, - UserExplorationUnlocked, + userExplorationUnlocked, } from '../../tests/__mocks__/explorationData.mock' import { fluidStatusData } from '../../tests/__mocks__/fluidStatusData.mock' import { quizEntity, userQuiz } from '../../tests/__mocks__/quizData.mock' @@ -53,7 +53,7 @@ import ChallengeService from './challenge.service' const mockGetExplorationEntityById = jest.fn() const mockParseExplorationEntityToUserExploration = jest.fn() -const mockGetUserExplorationfromExplorationEntities = jest.fn() +const mockGetUserExplorationFromExplorationEntities = jest.fn() jest.mock('./exploration.service', () => { return jest.fn(() => { return { @@ -61,7 +61,7 @@ jest.mock('./exploration.service', () => { parseExplorationEntityToUserExploration: mockParseExplorationEntityToUserExploration, getUserExplorationfromExplorationEntities: - mockGetUserExplorationfromExplorationEntities, + mockGetUserExplorationFromExplorationEntities, } }) }) @@ -83,7 +83,7 @@ describe('Challenge service', () => { beforeEach(() => { mockGetExplorationEntityById.mockClear() mockParseExplorationEntityToUserExploration.mockClear() - mockGetUserExplorationfromExplorationEntities.mockClear() + mockGetUserExplorationFromExplorationEntities.mockClear() mockGetGraphData.mockClear() mockCalculatePerformanceIndicatorValue.mockClear() }) @@ -122,7 +122,7 @@ describe('Challenge service', () => { startDate: null, endingDate: null, quiz: userQuiz, - exploration: UserExplorationUnlocked, + exploration: userExplorationUnlocked, action: { ecogesture: null, startDate: null, @@ -133,7 +133,7 @@ describe('Challenge service', () => { challengeEntityData, duelData, userQuiz, - UserExplorationUnlocked + userExplorationUnlocked ) expect(result).toEqual(expectedResult) }) @@ -179,7 +179,7 @@ describe('Challenge service', () => { mockParseExplorationEntityToUserExploration.mockReturnValue( userExploration ) - mockGetUserExplorationfromExplorationEntities.mockReturnValue( + mockGetUserExplorationFromExplorationEntities.mockReturnValue( userExploration ) const result = await challengeService.buildUserChallengeList( @@ -219,7 +219,7 @@ describe('Challenge service', () => { mockParseExplorationEntityToUserExploration.mockReturnValue( explorationDefault ) - mockGetUserExplorationfromExplorationEntities.mockReturnValue( + mockGetUserExplorationFromExplorationEntities.mockReturnValue( explorationDefault ) const result = await challengeService.buildUserChallengeList( @@ -365,7 +365,7 @@ describe('Challenge service', () => { expect(result).toEqual(userChallengeData[0]) const resultDefault = await challengeService.updateUserChallenge( userChallengeData[0], - 999 + 999 as UserChallengeUpdateFlag ) expect(resultDefault).toEqual(userChallengeData[0]) }) diff --git a/src/services/consumption.service.spec.ts b/src/services/consumption.service.spec.ts index 226026b0218eb20bf7268620490e7e5289394e61..e57b614a04c5659650811615a96a8a1b56f2425d 100644 --- a/src/services/consumption.service.spec.ts +++ b/src/services/consumption.service.spec.ts @@ -404,7 +404,7 @@ describe('Consumption service', () => { }) describe('getExportableFluids method', () => { - it('should return the array of fluidtypes that have entries', async () => { + it('should return the array of fluidTypes that have entries', async () => { const fluidTypes: FluidType[] = [ FluidType.ELECTRICITY, FluidType.WATER, @@ -501,17 +501,16 @@ describe('Consumption service', () => { describe('checkDoctypeEntries method', () => { it('should return a boolean if doctype are correct', async () => { - let fluidType: FluidType = FluidType.GAS + const fluidType: FluidType = FluidType.GAS mockGetEntries.mockResolvedValueOnce({ data: [1] }) let result = await consumptionDataManager.checkDoctypeEntries( fluidType, TimeStep.DAY ) expect(result).toBeTruthy() - fluidType = 999 mockGetEntries.mockResolvedValueOnce({ data: [] }) result = await consumptionDataManager.checkDoctypeEntries( - fluidType, + 999 as FluidType, TimeStep.DAY ) expect(result).toBeFalsy() diff --git a/src/services/consumptionFormatter.service.spec.ts b/src/services/consumptionFormatter.service.spec.ts index 085dab6fb05aa93daec27a81908119c69e7c82c5..1b6e2c2b9d7d31d288524351448127e476847e41 100644 --- a/src/services/consumptionFormatter.service.spec.ts +++ b/src/services/consumptionFormatter.service.spec.ts @@ -66,7 +66,7 @@ let mockTimePeriod: TimePeriod = { zone: 'utc', }), } -const unknowTimeStep = 999 +const unknownTimeStep = 999 as TimeStep describe('ConsumptionFormatter service', () => { const consumptionFormatterService = new ConsumptionFormatterService() @@ -256,7 +256,7 @@ describe('ConsumptionFormatter service', () => { consumptionFormatterService.formatGraphData( mockDataLoad, mockTimePeriod, - unknowTimeStep, + unknownTimeStep, FluidType.ELECTRICITY, fluidStatus[FluidType.ELECTRICITY] ) @@ -283,7 +283,7 @@ describe('ConsumptionFormatter service', () => { state: DataloadState.EMPTY, valueDetail: null, } - it('sould return not change state because data date < today and no firstFluidDataDate & no lastFluidDataDate', () => { + it('should return not change state because data date < today and no firstFluidDataDate & no lastFluidDataDate', () => { const expectedResult: Dataload = mockData const result: Dataload = consumptionFormatterService.defineDataloadState( mockData, @@ -293,7 +293,7 @@ describe('ConsumptionFormatter service', () => { ) expect(result).toEqual(expectedResult) }) - it('sould return COMING state because data date >= today', () => { + it('should return COMING state because data date >= today', () => { localSpy.mockReturnValueOnce( DateTime.fromISO('2020-10-01T00:00:00.000Z', { zone: 'utc' }) ) @@ -309,7 +309,7 @@ describe('ConsumptionFormatter service', () => { ) expect(result).toEqual(expectedResult) }) - it('sould return VALID state because data.date < firstFluidDataDate for day timestep', () => { + it('should return VALID state because data.date < firstFluidDataDate for day timestep', () => { fluidStatus[FluidType.ELECTRICITY].firstDataDate = DateTime.fromISO( '2020-10-20T00:00:00.000Z', { @@ -328,7 +328,7 @@ describe('ConsumptionFormatter service', () => { ) expect(result).toEqual(expectedResult) }) - it('sould return VALID state because data.date < start of month of firstFluidDataDate for month timestep', () => { + it('should return VALID state because data.date < start of month of firstFluidDataDate for month timestep', () => { fluidStatus[FluidType.ELECTRICITY].firstDataDate = DateTime.fromISO( '2020-11-01T00:00:00.000Z', { @@ -347,7 +347,7 @@ describe('ConsumptionFormatter service', () => { ) expect(result).toEqual(expectedResult) }) - it('sould return VALID state because data.date < start of year firstFluidDataDate for year timestep', () => { + it('should return VALID state because data.date < start of year firstFluidDataDate for year timestep', () => { fluidStatus[FluidType.ELECTRICITY].firstDataDate = DateTime.fromISO( '2021-10-20T00:00:00.000Z', { @@ -366,7 +366,7 @@ describe('ConsumptionFormatter service', () => { ) expect(result).toEqual(expectedResult) }) - it('sould return VALID state because data.date < firstFluidDataDate for month timestep', () => { + it('should return VALID state because data.date < firstFluidDataDate for month timestep', () => { fluidStatus[FluidType.ELECTRICITY].firstDataDate = DateTime.fromISO( '2020-10-20T00:00:00.000Z', { @@ -385,7 +385,7 @@ describe('ConsumptionFormatter service', () => { ) expect(result).toEqual(expectedResult) }) - it('sould return VALID state because data.date < firstFluidDataDate for year timestep', () => { + it('should return VALID state because data.date < firstFluidDataDate for year timestep', () => { fluidStatus[FluidType.ELECTRICITY].firstDataDate = DateTime.fromISO( '2020-12-20T00:00:00.000Z', { @@ -404,7 +404,7 @@ describe('ConsumptionFormatter service', () => { ) expect(result).toEqual(expectedResult) }) - it('sould return HOLE state because data.date between firstFluidDataDate and lastFluidDataDate and value is -1', () => { + it('should return HOLE state because data.date between firstFluidDataDate and lastFluidDataDate and value is -1', () => { fluidStatus[FluidType.ELECTRICITY].firstDataDate = DateTime.fromISO( '2020-08-01T00:00:00.000Z', { @@ -429,7 +429,7 @@ describe('ConsumptionFormatter service', () => { ) expect(result).toEqual(expectedResult) }) - it('sould return VALID state because data.date between firstFluidDataDate and lastFluidDataDate and value is -1', () => { + it('should return VALID state because data.date between firstFluidDataDate and lastFluidDataDate and value is -1', () => { fluidStatus[FluidType.ELECTRICITY].firstDataDate = DateTime.fromISO( '2020-08-01T00:00:00.000Z', { @@ -455,7 +455,7 @@ describe('ConsumptionFormatter service', () => { expect(result).toEqual(expectedResult) }) - describe('sould return COMING state because data.date > lastFluidDataDate and is in dataDelayOffset period', () => { + describe('should return COMING state because data.date > lastFluidDataDate and is in dataDelayOffset period', () => { beforeEach(() => { fluidStatus[FluidType.ELECTRICITY].firstDataDate = DateTime.fromISO( '2020-08-01T00:00:00.000Z', @@ -553,7 +553,7 @@ describe('ConsumptionFormatter service', () => { }) }) - describe('sould return MISSING state because data.date > lastFluidDataDate and is not in dataDelayOffset period', () => { + describe('should return MISSING state because data.date > lastFluidDataDate and is not in dataDelayOffset period', () => { beforeEach(() => { fluidStatus[FluidType.ELECTRICITY].firstDataDate = DateTime.fromISO( '2019-08-01T00:00:00.000Z', diff --git a/src/services/dateChart.service.spec.ts b/src/services/dateChart.service.spec.ts index c48f2535c523c81097ea9d8035e1b60e3ac043be..83449b87a24a2c492f6f41e38e8d1352dbf5867f 100644 --- a/src/services/dateChart.service.spec.ts +++ b/src/services/dateChart.service.spec.ts @@ -4,6 +4,7 @@ import { TimePeriod } from 'models' import DateChartService from './dateChart.service' const localSpy = jest.spyOn(DateTime, 'local') +const unknownTimeStep = 0 as TimeStep describe('dateChart service', () => { beforeEach(() => { @@ -295,7 +296,7 @@ describe('dateChart service', () => { it('should throw error for unknown TimeStep', () => { try { - dateChartService.defineTimePeriod(refDate, 4, -1) + dateChartService.defineTimePeriod(refDate, unknownTimeStep, -1) } catch (error) { expect(error).toEqual(new Error('TimeStep unknown')) } @@ -693,7 +694,7 @@ describe('dateChart service', () => { zone: 'utc', }) try { - dateChartService.compareStepDate(4, firstDate, secondDate) + dateChartService.compareStepDate(unknownTimeStep, firstDate, secondDate) } catch (error) { expect(error).toEqual(new Error('TimeStep unknown')) } @@ -834,7 +835,7 @@ describe('dateChart service', () => { } ) const result = dateChartService.defineIncrementForPreviousIndex( - 0, + unknownTimeStep, selectedDate, 0 ) @@ -976,7 +977,7 @@ describe('dateChart service', () => { } ) const result = dateChartService.defineIncrementForNextIndex( - 0, + unknownTimeStep, selectedDate, 0 ) @@ -1069,7 +1070,11 @@ describe('dateChart service', () => { }) it('should return selected date for unknown time step', () => { - const result = dateChartService.incrementeDate(0, selectedDate, 1) + const result = dateChartService.incrementeDate( + unknownTimeStep, + selectedDate, + 1 + ) expect(result).toEqual(selectedDate) }) }) @@ -1287,7 +1292,10 @@ describe('dateChart service', () => { zone: 'utc', } ) - const result = dateChartService.defineDateIndex(0, selectedDate) + const result = dateChartService.defineDateIndex( + unknownTimeStep, + selectedDate + ) expect(result).toEqual(0) }) }) diff --git a/src/services/exploration.service.spec.ts b/src/services/exploration.service.spec.ts index cf2307bb942dc91f4cfc70603963583cd861db6f..d6d1b092aa5e52e98f304c7a279a84eac882b547 100644 --- a/src/services/exploration.service.spec.ts +++ b/src/services/exploration.service.spec.ts @@ -5,9 +5,9 @@ import mockClient from '../../tests/__mocks__/client' import { allExplorationEntities, explorationEntity, - UserExplorationDone, - UserExplorationStarted, - UserExplorationUnlocked, + userExplorationDone, + userExplorationStarted, + userExplorationUnlocked, } from '../../tests/__mocks__/explorationData.mock' import { userChallengeExplo1OnGoing, @@ -104,7 +104,7 @@ describe('Exploration service', () => { searchId ) const updatedUserExploration = { - ...UserExplorationUnlocked, + ...userExplorationUnlocked, date: result.date, } expect(result).toEqual(updatedUserExploration) @@ -113,17 +113,17 @@ describe('Exploration service', () => { describe('startUserExploration Method', () => { it('should return the started userExploration', async () => { const result = await explorationService.startUserExploration( - UserExplorationUnlocked + userExplorationUnlocked ) - expect(result).toEqual(UserExplorationStarted) + expect(result).toEqual(userExplorationStarted) }) }) describe('endUserExploration Method', () => { it('should return the finished userExploration', async () => { const result = explorationService.endUserExploration( - UserExplorationStarted + userExplorationStarted ) - expect(result).toEqual(UserExplorationDone) + expect(result).toEqual(userExplorationDone) }) }) describe('checkExploration Method', () => { diff --git a/src/services/profileType.service.spec.ts b/src/services/profileType.service.spec.ts index 298fdfefde3c993d1004fcda67b5618b30804e20..0d58b4f0a1a177ee0bbbd6ef1ff48aba844cdef2 100644 --- a/src/services/profileType.service.spec.ts +++ b/src/services/profileType.service.spec.ts @@ -40,7 +40,7 @@ import { import ProfileTypeService from './profileType.service' import ProfileTypeFormService from './profileTypeForm.service' -const wrongNumber = 99999 +const unknownStep = 99999 as ProfileTypeStepForm describe('ProfileType service', () => { const profileTypeService = new ProfileTypeService( mockProfileType, @@ -342,7 +342,7 @@ describe('ProfileType service', () => { false ) expect(nextStep).toEqual(ProfileTypeStepForm.END) - nextStep = profileTypeFormService.getNextFormStep(wrongNumber, false) + nextStep = profileTypeFormService.getNextFormStep(unknownStep, false) expect(nextStep).toEqual(ProfileTypeStepForm.HOUSING_TYPE) }) }) @@ -405,7 +405,7 @@ describe('ProfileType service', () => { ProfileTypeStepForm.COOKING_FLUID ) expect(previousStep).toEqual(ProfileTypeStepForm.HOT_WATER_EQUIPMENT) - previousStep = profileTypeFormService.getPreviousFormStep(wrongNumber) + previousStep = profileTypeFormService.getPreviousFormStep(unknownStep) expect(previousStep).toEqual(ProfileTypeStepForm.HOUSING_TYPE) }) }) @@ -475,7 +475,7 @@ describe('ProfileType service', () => { ProfileTypeStepForm.COOKING_FLUID ) expect(answers).toEqual(mockProfileTypeAnswers[15]) - answers = ProfileTypeFormService.getAnswerForStep(wrongNumber) + answers = ProfileTypeFormService.getAnswerForStep(unknownStep) expect(answers).toEqual(mockProfileTypeAnswers[16]) }) }) diff --git a/src/services/queryRunner.service.spec.ts b/src/services/queryRunner.service.spec.ts index 74597959f8b7a7860534ea5ed74b725cfc938c60..e820301be69aaf41cd3fadc60cf44df47dc2a2f9 100644 --- a/src/services/queryRunner.service.spec.ts +++ b/src/services/queryRunner.service.spec.ts @@ -11,6 +11,9 @@ import { loadMonthData } from '../../tests/__mocks__/loadMonthData.mock' import { loadYearData } from '../../tests/__mocks__/loadYearData.mock' import QueryRunner from './queryRunner.service' +const unknownTimeStep = 99 as TimeStep +const unknownFluidType = 99 as FluidType + describe('queryRunner service', () => { const queryRunner = new QueryRunner(mockClient) @@ -562,7 +565,7 @@ describe('queryRunner service', () => { mockClient.query.mockResolvedValue(mockQueryResult) const result: Dataload[] | null = await queryRunner.fetchFluidData( mockTimePeriod, - 99, + unknownTimeStep, FluidType.WATER ) expect(result).toEqual(expectedResult) @@ -839,7 +842,7 @@ describe('queryRunner service', () => { mockClient.query.mockResolvedValue(mockQueryResult) const result: Dataload[] | null = await queryRunner.fetchFluidData( mockTimePeriod, - 99, + unknownTimeStep, FluidType.GAS ) expect(result).toEqual(expectedResult) @@ -1091,7 +1094,7 @@ describe('queryRunner service', () => { const result: Dataload[] | null = await queryRunner.fetchFluidData( mockTimePeriod, TimeStep.DAY, - 99 + unknownFluidType ) expect(result).toBeNull() }) @@ -1107,7 +1110,7 @@ describe('queryRunner service', () => { } const result: Dataload[] | null = await queryRunner.fetchFluidData( mockTimePeriod, - 99, + unknownTimeStep, FluidType.ELECTRICITY ) expect(result).toBeNull() @@ -1235,7 +1238,11 @@ describe('queryRunner service', () => { }), } const result: number | Dataload | null = - await queryRunner.fetchFluidMaxData(mockTimePeriod, TimeStep.DAY, 99) + await queryRunner.fetchFluidMaxData( + mockTimePeriod, + TimeStep.DAY, + unknownFluidType + ) expect(result).toBeNull() }) @@ -1251,7 +1258,7 @@ describe('queryRunner service', () => { const result: number | Dataload | null = await queryRunner.fetchFluidMaxData( mockTimePeriod, - 99, + unknownTimeStep, FluidType.ELECTRICITY ) expect(result).toBeNull() @@ -1346,12 +1353,18 @@ describe('queryRunner service', () => { }) it('should return null when unknown fluid type', async () => { - const result = await queryRunner.getEntries(99, TimeStep.DAY) + const result = await queryRunner.getEntries( + unknownFluidType, + TimeStep.DAY + ) expect(result).toBeNull() }) it('should return null when unknown time step', async () => { - const result = await queryRunner.getEntries(FluidType.ELECTRICITY, 99) + const result = await queryRunner.getEntries( + FluidType.ELECTRICITY, + unknownTimeStep + ) expect(result).toBeNull() }) }) diff --git a/src/services/timePeriod.service.spec.ts b/src/services/timePeriod.service.spec.ts index 6a70e106a964946b80af401e287ea5d5640a7752..58830ee8c6192b513333f8ab1bb1b4be91b6821b 100644 --- a/src/services/timePeriod.service.spec.ts +++ b/src/services/timePeriod.service.spec.ts @@ -7,7 +7,7 @@ import TimePeriodService from './timePeriod.service' const randomDate = DateTime.fromISO('2020-10-10T08:00:00.000Z', { zone: 'utc', }) -const unknowTimeStep = 999 +const unknownTimeStep = 999 as TimeStep describe('timePeriod service', () => { const timePeriodService = new TimePeriodService() describe('getTimePeriods method', () => { @@ -264,7 +264,7 @@ describe('timePeriod service', () => { }), } try { - timePeriodService.getComparisonTimePeriod(timePeriod, unknowTimeStep) + timePeriodService.getComparisonTimePeriod(timePeriod, unknownTimeStep) } catch (error) { expect(error).toEqual(new Error('TimeStep unknown')) } @@ -324,7 +324,10 @@ describe('timePeriod service', () => { }) it('should return an error because of unknown TimeStep', () => { try { - timePeriodService.getLastDayOfCompletePeriod(randomDate, unknowTimeStep) + timePeriodService.getLastDayOfCompletePeriod( + randomDate, + unknownTimeStep + ) } catch (error) { expect(error).toEqual(new Error('TimeStep unknown')) } @@ -384,7 +387,7 @@ describe('timePeriod service', () => { }) it('should return the date of the last day of current period', () => { try { - timePeriodService.getLastDayOfTimePeriod(randomDate, unknowTimeStep) + timePeriodService.getLastDayOfTimePeriod(randomDate, unknownTimeStep) } catch (error) { expect(error).toEqual(new Error('TimeStep unknown')) } @@ -446,7 +449,7 @@ describe('timePeriod service', () => { try { timePeriodService.getStartDateFromEndDateByTimeStep( randomDate, - unknowTimeStep + unknownTimeStep ) } catch (error) { expect(error).toEqual(new Error('TimeStep unknown')) diff --git a/src/utils/date.spec.ts b/src/utils/date.spec.ts index d842b92430766906c4862f436cc2ff4fe6173a9a..0ce85152d330c353f1319a45a3f1a86b11099d40 100644 --- a/src/utils/date.spec.ts +++ b/src/utils/date.spec.ts @@ -172,14 +172,14 @@ describe('date utils', () => { }) describe('default', () => { - it('should return false', () => { + it('should return false for default case', () => { const result = isLastDateReached( DateTime.local() .setZone('utc', { keepLocalTime: true, }) .minus({ years: 1 }), - 0 + 0 as TimeStep ) expect(result).toBe(false) }) @@ -335,7 +335,7 @@ describe('date utils', () => { keepLocalTime: true, }) .minus({ years: 1 }), - 0 + 0 as TimeStep ) expect(result).toBe(false) }) @@ -363,7 +363,7 @@ describe('date utils', () => { expect(result).toBe(2) }) - it('it should return when there is only ELECTRICTY Fluid Type', () => { + it('it should return when there is only ELECTRICITY Fluid Type', () => { const result = getLagDays([FluidType.ELECTRICITY]) expect(result).toBe(1) }) @@ -373,7 +373,7 @@ describe('date utils', () => { const actualData: Dataload[] = graphData.actualData it('should return an empty string when the TimePeriod is unknown', () => { - const result = convertDateToShortDateString(null, 99) + const result = convertDateToShortDateString(null, 0 as TimeStep) expect(result).toBe('') }) diff --git a/src/utils/picto.spec.ts b/src/utils/picto.spec.ts index c3c67e80910882800ecaa1c5160b82a9bf3f32a3..422ec60c8630a678d1d7eeaec81be58fbd237bc3 100644 --- a/src/utils/picto.spec.ts +++ b/src/utils/picto.spec.ts @@ -20,10 +20,12 @@ import WaterSmallIcon from '../assets/icons/visu/water-small.svg' import WaterIcon from '../assets/icons/visu/water.svg' import { getAddPicto, getParamPicto, getPartnerPicto, getPicto } from './picto' -describe('picto utilis test', () => { +const unknownFluidType = 99 as FluidType + +describe('picto utils test', () => { describe('getPicto test', () => { - describe('case ELECTRICTY', () => { - it('should return Electricty Icon', () => { + describe('case ELECTRICITY', () => { + it('should return Electricity Icon', () => { const result = getPicto(FluidType.ELECTRICITY) expect(result).toBe(ElecIcon) }) @@ -65,7 +67,7 @@ describe('picto utilis test', () => { }) describe('case default', () => { it('should return default Icon', () => { - const result = getPicto(4) + const result = getPicto(unknownFluidType) expect(result).toBe(ElecIcon) }) }) @@ -87,7 +89,7 @@ describe('picto utilis test', () => { expect(result).toBe(AddGasIcon) }) it('should return default Icon', () => { - const result = getPicto(4) + const result = getPicto(unknownFluidType) expect(result).toBe(ElecIcon) }) }) @@ -108,7 +110,7 @@ describe('picto utilis test', () => { expect(result).toBe(GasParamIcon) }) it('should return default Icon', () => { - const result = getPicto(4) + const result = getPicto(unknownFluidType) expect(result).toBe(ElecParamIcon) }) }) diff --git a/tests/__mocks__/explorationData.mock.ts b/tests/__mocks__/explorationData.mock.ts index 75e71ac1a5bccf66d8915c80f3003ff2ebfe1867..a5ea25b2a4725c8c036c236944127b4d28732776 100644 --- a/tests/__mocks__/explorationData.mock.ts +++ b/tests/__mocks__/explorationData.mock.ts @@ -178,7 +178,6 @@ export const allExplorationEntities: ExplorationEntity[] = [ fluid_condition: [], message_success: 'Vous nous avez envoyé votre avis sur le service', }, - { id: 'EXPLORATION006', state: 0, @@ -205,7 +204,7 @@ export const allExplorationEntities: ExplorationEntity[] = [ }, ] -export const UserExplorationStarted: UserExploration = { +export const userExplorationStarted: UserExploration = { id: 'EXPLORATION001', state: UserExplorationState.ONGOING, description: 'Avoir complété son profil', @@ -219,7 +218,7 @@ export const UserExplorationStarted: UserExploration = { message_success: 'Vous avez complété votre profil ou refait un tour dans votre profil', } -export const UserExplorationDone: UserExploration = { +export const userExplorationDone: UserExploration = { id: 'EXPLORATION001', state: UserExplorationState.DONE, description: 'Avoir complété son profil', @@ -234,7 +233,7 @@ export const UserExplorationDone: UserExploration = { 'Vous avez complété votre profil ou refait un tour dans votre profil', } -export const UserExplorationUnlocked: UserExploration = { +export const userExplorationUnlocked: UserExploration = { id: 'EXPLORATION001', state: UserExplorationState.UNLOCKED, description: 'Avoir complété son profil', diff --git a/tests/__mocks__/modalStateData.mock.ts b/tests/__mocks__/modalStateData.mock.ts index b8543efe8952c02cf00c34420c88eb2c684d3a4e..be2d0569a842dda8b09edbef3c6d9e205e202d07 100644 --- a/tests/__mocks__/modalStateData.mock.ts +++ b/tests/__mocks__/modalStateData.mock.ts @@ -2,4 +2,9 @@ import { ModalState } from 'models' export const modalStateData: ModalState = { isFeedbacksOpen: false, + partnersIssueModal: { + egl: false, + enedis: false, + grdf: false, + }, } diff --git a/tests/__mocks__/userChallengeData.mock.ts b/tests/__mocks__/userChallengeData.mock.ts index ba363b126a758d8362d9fc85a19427da31a3a84a..205338b0380ddbccaa9ab6cf3a2df8d79c26ca51 100644 --- a/tests/__mocks__/userChallengeData.mock.ts +++ b/tests/__mocks__/userChallengeData.mock.ts @@ -9,7 +9,7 @@ import { UserChallenge } from 'models' import { duelData, duelDefault } from './duelData.mock' import { explorationDefault, - UserExplorationUnlocked, + userExplorationUnlocked, } from './explorationData.mock' import { quizDefault, userQuiz } from './quizData.mock' @@ -30,7 +30,7 @@ export const userChallengeData: UserChallenge[] = [ startDate: null, endingDate: null, quiz: userQuiz, - exploration: UserExplorationUnlocked, + exploration: userExplorationUnlocked, action: { ecogesture: null, startDate: null, @@ -53,7 +53,7 @@ export const userChallengeData: UserChallenge[] = [ startDate: null, endingDate: null, quiz: userQuiz, - exploration: UserExplorationUnlocked, + exploration: userExplorationUnlocked, action: { ecogesture: null, startDate: null, @@ -76,7 +76,7 @@ export const userChallengeData: UserChallenge[] = [ startDate: null, endingDate: null, quiz: userQuiz, - exploration: UserExplorationUnlocked, + exploration: userExplorationUnlocked, action: { ecogesture: null, startDate: null, @@ -99,7 +99,7 @@ export const userChallengeData: UserChallenge[] = [ startDate: null, endingDate: null, quiz: userQuiz, - exploration: UserExplorationUnlocked, + exploration: userExplorationUnlocked, action: { ecogesture: null, startDate: null, @@ -122,7 +122,7 @@ export const userChallengeData: UserChallenge[] = [ startDate: null, endingDate: null, quiz: userQuiz, - exploration: UserExplorationUnlocked, + exploration: userExplorationUnlocked, action: { ecogesture: null, startDate: null, @@ -145,7 +145,7 @@ export const userChallengeData: UserChallenge[] = [ startDate: null, endingDate: null, quiz: userQuiz, - exploration: UserExplorationUnlocked, + exploration: userExplorationUnlocked, action: { ecogesture: null, startDate: null,