From dc6fec1b8bcd6ea8386ca43f56260209775f8cdf Mon Sep 17 00:00:00 2001 From: Renovate-Bot <le.rameur.94@gmail.com> Date: Thu, 30 Jun 2022 15:32:42 +0000 Subject: [PATCH] chore(deps): update dependency prettier to v2 --- .prettierrc | 3 +- package.json | 4 +- src/components/Action/ActionBegin.spec.tsx | 10 +- src/components/Action/ActionCard.spec.tsx | 5 +- src/components/Action/ActionDone.spec.tsx | 5 +- src/components/Action/ActionDone.tsx | 9 +- src/components/Action/ActionModal.spec.tsx | 5 +- src/components/Action/ActionModal.tsx | 15 +- src/components/Action/ActionOnGoing.spec.tsx | 5 +- src/components/Action/ActionOnGoing.tsx | 10 +- .../Analysis/AnalysisConsumption.spec.tsx | 35 +---- .../Analysis/AnalysisConsumption.tsx | 24 +-- .../Analysis/AnalysisConsumptionRow.spec.tsx | 114 ++++---------- .../Analysis/AnalysisConsumptionRow.tsx | 8 +- .../Analysis/AnalysisError.spec.tsx | 10 +- src/components/Analysis/AnalysisView.tsx | 5 +- .../ElecHalfHourMonthlyAnalysis.spec.tsx | 19 +-- .../Analysis/ElecHalfHourMonthlyAnalysis.tsx | 26 ++-- .../Analysis/MaxConsumptionCard.spec.tsx | 20 +-- src/components/Analysis/MonthlyAnalysis.tsx | 27 ++-- .../Challenge/ChallengeCardOnGoing.tsx | 7 +- .../Challenge/ChallengeCardUnlocked.spec.tsx | 10 +- src/components/Challenge/ChallengeView.tsx | 5 +- src/components/Charts/Bar.spec.tsx | 5 +- .../IconButton/StyledIconBorderedButton.tsx | 4 +- src/components/Connection/ConnectionLogin.tsx | 12 +- src/components/Connection/ConnectionOAuth.tsx | 12 +- .../Connection/ConnectionResult.tsx | 10 +- .../DeleteGRDFAccountModal.spec.tsx | 5 +- .../Connection/ExpiredConsentModal.spec.tsx | 5 +- src/components/Connection/FormLogin.tsx | 6 +- .../ConsumptionVisualizer.tsx | 2 +- .../DataloadConsumptionVisualizer.spec.tsx | 12 +- .../DataloadSectionValue.spec.tsx | 20 +-- .../DateNavigator/DateNavigator.spec.tsx | 20 +-- .../DateNavigator/DateNavigator.tsx | 11 +- src/components/Duel/DuelUnlocked.spec.tsx | 5 +- .../Ecogesture/EcogestureEmptyList.spec.tsx | 28 +--- .../Ecogesture/EcogestureInitModal.spec.tsx | 10 +- .../Ecogesture/EcogestureList.spec.tsx | 10 +- .../Ecogesture/EcogestureView.spec.tsx | 10 +- src/components/Ecogesture/EcogestureView.tsx | 15 +- .../Ecogesture/SingleEcogesture.spec.tsx | 15 +- .../Ecogesture/SingleEcogesture.tsx | 17 ++- .../EcogestureFormEquipment.spec.tsx | 34 +---- .../EcogestureFormSingleChoice.spec.tsx | 27 +--- .../EcogestureFormView.spec.tsx | 25 +--- .../EcogestureForm/EcogestureFormView.tsx | 20 +-- .../EcogestureLaunchFormModal.spec.tsx | 5 +- .../EcogestureForm/EquipmentIcon.spec.tsx | 7 +- .../EcogestureSelection.tsx | 30 ++-- .../EcogestureSelectionDetail.spec.tsx | 15 +- .../EcogestureSelectionRestart.spec.tsx | 10 +- .../Exploration/ExplorationFinished.spec.tsx | 5 +- .../Exploration/ExplorationOngoing.spec.tsx | 10 +- src/components/FAQ/FAQContent.tsx | 12 +- .../Feedback/FeedbackModal.spec.tsx | 17 +-- src/components/FluidChart/FluidChart.tsx | 5 +- src/components/GCU/GCUContent.spec.tsx | 2 +- src/components/Header/CozyBar.spec.tsx | 12 +- src/components/Header/Header.spec.tsx | 19 +-- src/components/Home/ConsumptionView.tsx | 12 +- src/components/Home/FluidButton.tsx | 6 +- .../Konnector/KonnectorViewerCard.tsx | 36 ++--- .../Konnector/KonnectorViewerList.spec.tsx | 5 +- src/components/Navbar/Navbar.spec.tsx | 14 +- .../Onboarding/WelcomeModal.spec.tsx | 10 +- .../Options/ProfileTypeOptions.spec.tsx | 5 +- src/components/Options/ProfileTypeOptions.tsx | 15 +- src/components/Options/ReportOptions.spec.tsx | 17 +-- src/components/Options/ReportOptions.tsx | 4 +- .../PartnerConnectionStepsModal.spec.tsx | 25 +--- .../PartnerConnectionStepsModal.tsx | 5 +- .../PerformanceIndicatorContent.tsx | 4 +- .../ProfileType/FormNavigation.spec.tsx | 10 +- .../ProfileType/ProfileTypeFinished.spec.tsx | 5 +- .../ProfileType/ProfileTypeFinished.tsx | 10 +- .../ProfileTypeFormDateSelection.tsx | 8 +- .../ProfileTypeFormMultiChoice.tsx | 4 +- .../ProfileTypeFormNumberSelection.tsx | 4 +- .../ProfileTypeFormSingleChoice.tsx | 4 +- .../ProfileType/ProfileTypeView.tsx | 19 ++- src/components/Quiz/QuizBegin.spec.tsx | 5 +- src/components/Quiz/QuizBegin.tsx | 9 +- .../Quiz/QuizCustomQuestionContent.tsx | 20 +-- src/components/Quiz/QuizFinish.tsx | 20 +-- src/components/Quiz/QuizQuestion.tsx | 14 +- .../Quiz/QuizQuestionContent.spec.tsx | 5 +- src/components/Quiz/QuizQuestionContent.tsx | 16 +- src/components/Routes/Routes.tsx | 16 +- src/components/Splash/SplashRoot.tsx | 49 +++--- .../Splash/SplashScreenError.spec.tsx | 5 +- src/components/Terms/TermsView.spec.tsx | 38 +---- src/components/Terms/TermsView.tsx | 10 +- .../TimeStepSelector.spec.tsx | 38 +---- .../TimeStepSelector/TimeStepSelector.tsx | 5 +- .../TotalConsumption.spec.tsx | 21 +-- src/migrations/migration.data.ts | 2 +- src/services/account.service.ts | 10 +- src/services/action.service.ts | 20 +-- src/services/challenge.service.spec.ts | 47 +++--- src/services/challenge.service.ts | 97 ++++++------ src/services/consumption.service.spec.ts | 7 +- src/services/consumption.service.ts | 103 +++++++------ .../consumptionFormatter.service.spec.ts | 141 ++++++++++-------- src/services/dateChart.service.ts | 3 +- src/services/duel.service.ts | 26 ++-- src/services/ecogesture.service.ts | 28 ++-- src/services/exploration.service.spec.ts | 16 +- src/services/exploration.service.ts | 10 +- src/services/fluid.service.spec.ts | 21 +-- src/services/fluid.service.ts | 114 +++++++------- src/services/fluidsPrices.service.ts | 34 ++--- src/services/initialization.service.ts | 23 ++- src/services/konnector.service.ts | 5 +- src/services/partnersInfo.service.spec.ts | 5 +- .../performanceIndicator.service.spec.ts | 42 +++--- src/services/profile.service.ts | 11 +- src/services/profileEcogesture.service.ts | 11 +- src/services/profileType.service.spec.ts | 34 ++--- src/services/profileType.service.ts | 27 ++-- src/services/profileTypeEntity.service.ts | 11 +- src/services/queryRunner.service.spec.ts | 80 ++++------ src/services/queryRunner.service.ts | 33 +--- src/services/quiz.service.ts | 21 ++- src/services/terms.service.ts | 5 +- src/services/triggers.service.spec.ts | 10 +- src/services/usageEvent.service.ts | 5 +- src/store/chart/chart.reducer.ts | 8 +- .../profileEcogesture.actions.ts | 5 +- src/targets/browser/index.tsx | 2 +- src/targets/services/aggregatorUsageEvents.ts | 78 ++++------ .../services/monthlyReportNotification.ts | 17 +-- yarn.lock | 13 +- 134 files changed, 966 insertions(+), 1522 deletions(-) diff --git a/.prettierrc b/.prettierrc index 83d4731a7..08012e88d 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,5 +3,6 @@ "semi": false, "singleQuote": true, "tabWidth": 2, - "trailingComma": "es5" + "trailingComma": "es5", + "arrowParens": "avoid" } diff --git a/package.json b/package.json index 2f63cf00f..b22cbe506 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "scripts": { "tx": "tx pull --all || true", "lint": "yarn lint:js", - "lint:js": "cs lint {src,test}/**/*.{js,jsx,ts,tsx}", + "lint:js": "cs lint {src,test}/**/*.{js,jsx,ts,tsx} --fix", "prebuild": "yarn lint", "build:cs": "build:browser", "build-dev:browser": "cs build --browser --config app.config.alpha.js", @@ -82,7 +82,7 @@ "mjml": "^4.10.2", "mjml-web": "^4.10.0", "npm-run-all": "^4.1.5", - "prettier": "^1.19.1", + "prettier": "^2.7.1", "prettier-eslint": "^15.0.1", "react-test-renderer": "16.14.0", "redux-mock-store": "1.5.4", diff --git a/src/components/Action/ActionBegin.spec.tsx b/src/components/Action/ActionBegin.spec.tsx index e8430a43b..d3294a161 100644 --- a/src/components/Action/ActionBegin.spec.tsx +++ b/src/components/Action/ActionBegin.spec.tsx @@ -148,10 +148,7 @@ describe('ActionBegin component', () => { await new Promise(resolve => setTimeout(resolve)) wrapper.update() }) - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') expect(wrapper.find(ActionModal).exists()).toBeTruthy() expect(wrapper.find(ActionModal).prop('open')).toBeTruthy() }) @@ -178,9 +175,6 @@ describe('ActionBegin component', () => { await new Promise(resolve => setTimeout(resolve)) wrapper.update() }) - wrapper - .find(Button) - .at(1) - .simulate('click') + wrapper.find(Button).at(1).simulate('click') }) }) diff --git a/src/components/Action/ActionCard.spec.tsx b/src/components/Action/ActionCard.spec.tsx index 6076a3da0..afc9734f1 100644 --- a/src/components/Action/ActionCard.spec.tsx +++ b/src/components/Action/ActionCard.spec.tsx @@ -66,10 +66,7 @@ describe('ActionCard component', () => { /> </Provider> ) - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') expect(wrapper.find(EcogestureModal).exists()).toBeTruthy() }) }) diff --git a/src/components/Action/ActionDone.spec.tsx b/src/components/Action/ActionDone.spec.tsx index f59cfe61f..748320be9 100644 --- a/src/components/Action/ActionDone.spec.tsx +++ b/src/components/Action/ActionDone.spec.tsx @@ -78,10 +78,7 @@ describe('ActionDone component', () => { <ActionDone currentChallenge={userChallengeData[1]} /> </Provider> ) - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') await act(async () => { await new Promise(resolve => setTimeout(resolve)) wrapper.update() diff --git a/src/components/Action/ActionDone.tsx b/src/components/Action/ActionDone.tsx index 2e909dad7..b5d5731bd 100644 --- a/src/components/Action/ActionDone.tsx +++ b/src/components/Action/ActionDone.tsx @@ -27,10 +27,11 @@ const ActionDone: React.FC<ActionDoneProps> = ({ const history = useHistory() const handleEndAction = useCallback(async () => { const challengeService = new ChallengeService(client) - const updatedChallenge: UserChallenge = await challengeService.updateUserChallenge( - currentChallenge, - UserChallengeUpdateFlag.ACTION_DONE - ) + const updatedChallenge: UserChallenge = + await challengeService.updateUserChallenge( + currentChallenge, + UserChallengeUpdateFlag.ACTION_DONE + ) await UsageEventService.addEvent(client, { type: UsageEventType.ACTION_END_EVENT, target: currentChallenge.action.ecogesture diff --git a/src/components/Action/ActionModal.spec.tsx b/src/components/Action/ActionModal.spec.tsx index 8e072fd70..29c27a23a 100644 --- a/src/components/Action/ActionModal.spec.tsx +++ b/src/components/Action/ActionModal.spec.tsx @@ -83,10 +83,7 @@ describe('ActionModal component', () => { /> </Provider> ) - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') await act(async () => { await new Promise(resolve => setTimeout(resolve)) wrapper.update() diff --git a/src/components/Action/ActionModal.tsx b/src/components/Action/ActionModal.tsx index cfc32d6fa..4ae600aff 100644 --- a/src/components/Action/ActionModal.tsx +++ b/src/components/Action/ActionModal.tsx @@ -31,13 +31,14 @@ const ActionModal: React.FC<ActionModalProps> = ({ const { t } = useI18n() const launchAction = useCallback(async () => { const challengeService = new ChallengeService(client) - const updatedChallenge: UserChallenge = await challengeService.updateUserChallenge( - userChallenge, - UserChallengeUpdateFlag.ACTION_START, - undefined, - undefined, - action - ) + const updatedChallenge: UserChallenge = + await challengeService.updateUserChallenge( + userChallenge, + UserChallengeUpdateFlag.ACTION_START, + undefined, + undefined, + action + ) dispatch(updateUserChallengeList(updatedChallenge)) }, [action, client, dispatch, userChallenge]) diff --git a/src/components/Action/ActionOnGoing.spec.tsx b/src/components/Action/ActionOnGoing.spec.tsx index b5a9a0ed8..ddf95e7df 100644 --- a/src/components/Action/ActionOnGoing.spec.tsx +++ b/src/components/Action/ActionOnGoing.spec.tsx @@ -80,10 +80,7 @@ describe('ActionOnGoing component', () => { await new Promise(resolve => setTimeout(resolve)) wrapper.update() }) - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') expect(wrapper.find(EcogestureModal).exists()).toBeTruthy() }) }) diff --git a/src/components/Action/ActionOnGoing.tsx b/src/components/Action/ActionOnGoing.tsx index cb7a95266..5253eaa67 100644 --- a/src/components/Action/ActionOnGoing.tsx +++ b/src/components/Action/ActionOnGoing.tsx @@ -39,8 +39,9 @@ const ActionOnGoing: React.FC<ActionOnGoingProps> = ({ return `linear-gradient(90deg, #121212 50%, #58ffff 50%)` } else if (progress > circle / 2) { if (durationInDays / 3 === 1) { - return `linear-gradient(${progress / - 2}deg, transparent 50%, #58ffff 50%), + return `linear-gradient(${ + progress / 2 + }deg, transparent 50%, #58ffff 50%), linear-gradient(90deg, transparent 50%, #58ffff 50%)` } else { @@ -51,8 +52,9 @@ const ActionOnGoing: React.FC<ActionOnGoingProps> = ({ if (durationInDays / 3 === 1) { return `linear-gradient(90deg, #121212 50%,transparent 50%), linear-gradient(240deg, #58ffff 50%, transparent 50%)` } else { - return `linear-gradient(90deg, #121212 50%,transparent 50%), linear-gradient(${progress * - 2}deg, #58ffff 50%, transparent 50%)` + return `linear-gradient(90deg, #121212 50%,transparent 50%), linear-gradient(${ + progress * 2 + }deg, #58ffff 50%, transparent 50%)` } } } diff --git a/src/components/Analysis/AnalysisConsumption.spec.tsx b/src/components/Analysis/AnalysisConsumption.spec.tsx index 1fbcf4beb..fb9eea498 100644 --- a/src/components/Analysis/AnalysisConsumption.spec.tsx +++ b/src/components/Analysis/AnalysisConsumption.spec.tsx @@ -198,10 +198,7 @@ describe('AnalysisConsumption component', () => { await new Promise(resolve => setTimeout(resolve)) wrapper.update() }) - wrapper - .find('.link-ideal') - .first() - .simulate('click') + wrapper.find('.link-ideal').first().simulate('click') expect( wrapper .find('#analysisconsumptionrow') @@ -233,10 +230,7 @@ describe('AnalysisConsumption component', () => { await new Promise(resolve => setTimeout(resolve)) wrapper.update() }) - wrapper - .find('.link-average') - .first() - .simulate('click') + wrapper.find('.link-average').first().simulate('click') expect( wrapper .find('#analysisconsumptionrow') @@ -279,10 +273,7 @@ describe('AnalysisConsumption component', () => { expect(mockgetMonthlyForecast).toHaveBeenCalledWith( profileData.monthlyAnalysisDate.month - 1 ) - wrapper - .find('.link-ideal') - .first() - .simulate('click') + wrapper.find('.link-ideal').first().simulate('click') expect( wrapper .find('#analysisconsumptionrow') @@ -327,10 +318,7 @@ describe('AnalysisConsumption component', () => { expect(mockgetMonthlyForecast).toHaveBeenCalledWith( profileData.monthlyAnalysisDate.month - 1 ) - wrapper - .find('.link-average') - .first() - .simulate('click') + wrapper.find('.link-average').first().simulate('click') expect( wrapper .find('#analysisconsumptionrow') @@ -371,10 +359,7 @@ describe('AnalysisConsumption component', () => { expect(mockgetMonthlyForecast).toHaveBeenCalledWith( profileData.monthlyAnalysisDate.month - 1 ) - wrapper - .find('.link-ideal') - .first() - .simulate('click') + wrapper.find('.link-ideal').first().simulate('click') expect( wrapper .find('#analysisconsumptionrow') @@ -414,10 +399,7 @@ describe('AnalysisConsumption component', () => { expect(mockgetMonthlyForecast).toHaveBeenCalledWith( profileData.monthlyAnalysisDate.month - 1 ) - wrapper - .find('.link-average') - .first() - .simulate('click') + wrapper.find('.link-average').first().simulate('click') expect( wrapper .find('#analysisconsumptionrow') @@ -450,10 +432,7 @@ describe('AnalysisConsumption component', () => { await new Promise(resolve => setTimeout(resolve)) wrapper.update() }) - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') expect(mockHistoryPush).toBeCalledWith('/profileType') }) }) diff --git a/src/components/Analysis/AnalysisConsumption.tsx b/src/components/Analysis/AnalysisConsumption.tsx index 2a589da8f..83fc2cfc6 100644 --- a/src/components/Analysis/AnalysisConsumption.tsx +++ b/src/components/Analysis/AnalysisConsumption.tsx @@ -90,18 +90,20 @@ const AnalysisConsumption: React.FC<AnalysisConsumptionProps> = ({ let subscribed = true async function loadAverageComsumption() { const profileTypeEntityService = new ProfileTypeEntityService(client) - const profileType: ProfileType | null = await profileTypeEntityService.getProfileType( - analysisDate.minus({ month: 1 }).startOf('month') - ) + const profileType: ProfileType | null = + await profileTypeEntityService.getProfileType( + analysisDate.minus({ month: 1 }).startOf('month') + ) if (profileType !== null) { const profileTypeService: ProfileTypeService = new ProfileTypeService( profileType, client, analysisDate.year ) - const monthlyForecast: MonthlyForecast = await profileTypeService.getMonthlyForecast( - analysisDate.minus({ month: 1 }).startOf('month').month - ) + const monthlyForecast: MonthlyForecast = + await profileTypeService.getMonthlyForecast( + analysisDate.minus({ month: 1 }).startOf('month').month + ) if (subscribed) { setForecast(monthlyForecast) if (monthlyForecast) { @@ -255,8 +257,9 @@ const AnalysisConsumption: React.FC<AnalysisConsumptionProps> = ({ <StyledCard onClick={toggleAverage} - className={`link-average ${toggleHome === 'average' && - 'active'} grid-align`} + className={`link-average ${ + toggleHome === 'average' && 'active' + } grid-align`} > <span className="check-icon"></span> <span className="link-label text-16-normal"> @@ -265,8 +268,9 @@ const AnalysisConsumption: React.FC<AnalysisConsumptionProps> = ({ </StyledCard> <StyledCard onClick={toggleIdeal} - className={`link-ideal ${toggleHome === 'ideal' && - 'active'} grid-align`} + className={`link-ideal ${ + toggleHome === 'ideal' && 'active' + } grid-align`} > <span className="check-icon"></span> <span className="link-label text-16-normal"> diff --git a/src/components/Analysis/AnalysisConsumptionRow.spec.tsx b/src/components/Analysis/AnalysisConsumptionRow.spec.tsx index 6bc0b0db5..866717ba5 100644 --- a/src/components/Analysis/AnalysisConsumptionRow.spec.tsx +++ b/src/components/Analysis/AnalysisConsumptionRow.spec.tsx @@ -39,18 +39,8 @@ describe('AnalysisConsumptionRow component', () => { /> ) expect(wrapper.find('.consumption-multifluid').exists()).toBeTruthy() - expect( - wrapper - .find('.price') - .first() - .text() - ).toBe('20,00 €') - expect( - wrapper - .find('.price') - .last() - .text() - ).toBe('18,00 €') + expect(wrapper.find('.price').first().text()).toBe('20,00 €') + expect(wrapper.find('.price').last().text()).toBe('18,00 €') expect(wrapper.find('.graph').exists()).toBeTruthy() expect(wrapper.find('.not-connected').exists()).toBeFalsy() }) @@ -71,18 +61,8 @@ describe('AnalysisConsumptionRow component', () => { /> ) expect(wrapper.find('.consumption-multifluid').exists()).toBeTruthy() - expect( - wrapper - .find('.price') - .first() - .text() - ).toBe('analysis.not_connected') - expect( - wrapper - .find('.price') - .last() - .text() - ).toBe('18,00 €') + expect(wrapper.find('.price').first().text()).toBe('analysis.not_connected') + expect(wrapper.find('.price').last().text()).toBe('18,00 €') expect(wrapper.find('.graph').exists()).toBeFalsy() expect(wrapper.find('.not-connected').exists()).toBeTruthy() }) @@ -101,18 +81,12 @@ describe('AnalysisConsumptionRow component', () => { /> ) expect(wrapper.find('.consumption-electricity').exists()).toBeTruthy() - expect( - wrapper - .find('.price') - .first() - .text() - ).toBe('25 FLUID.ELECTRICITY.UNIT') - expect( - wrapper - .find('.price') - .last() - .text() - ).toBe('4340 FLUID.ELECTRICITY.UNIT') + expect(wrapper.find('.price').first().text()).toBe( + '25 FLUID.ELECTRICITY.UNIT' + ) + expect(wrapper.find('.price').last().text()).toBe( + '4340 FLUID.ELECTRICITY.UNIT' + ) expect(wrapper.find('.graph').exists()).toBeTruthy() expect(wrapper.find('.not-connected').exists()).toBeFalsy() }) @@ -132,18 +106,12 @@ describe('AnalysisConsumptionRow component', () => { /> ) expect(wrapper.find('.consumption-electricity').exists()).toBeTruthy() - expect( - wrapper - .find('.price') - .first() - .text() - ).toBe('25 FLUID.ELECTRICITY.UNIT') - expect( - wrapper - .find('.price') - .last() - .text() - ).toBe('3906 FLUID.ELECTRICITY.UNIT') + expect(wrapper.find('.price').first().text()).toBe( + '25 FLUID.ELECTRICITY.UNIT' + ) + expect(wrapper.find('.price').last().text()).toBe( + '3906 FLUID.ELECTRICITY.UNIT' + ) expect(wrapper.find('.graph').exists()).toBeTruthy() expect(wrapper.find('.not-connected').exists()).toBeFalsy() }) @@ -163,18 +131,10 @@ describe('AnalysisConsumptionRow component', () => { /> ) expect(wrapper.find('.consumption-electricity').exists()).toBeTruthy() - expect( - wrapper - .find('.price') - .first() - .text() - ).toBe('analysis.not_connected') - expect( - wrapper - .find('.price') - .last() - .text() - ).toBe('4340 FLUID.ELECTRICITY.UNIT') + expect(wrapper.find('.price').first().text()).toBe('analysis.not_connected') + expect(wrapper.find('.price').last().text()).toBe( + '4340 FLUID.ELECTRICITY.UNIT' + ) expect(wrapper.find('.graph').exists()).toBeFalsy() expect(wrapper.find('.not-connected').exists()).toBeTruthy() }) @@ -194,18 +154,10 @@ describe('AnalysisConsumptionRow component', () => { /> ) expect(wrapper.find('.consumption-electricity').exists()).toBeTruthy() - expect( - wrapper - .find('.price') - .first() - .text() - ).toBe('-') - expect( - wrapper - .find('.price') - .last() - .text() - ).toBe('4340 FLUID.ELECTRICITY.UNIT') + expect(wrapper.find('.price').first().text()).toBe('-') + expect(wrapper.find('.price').last().text()).toBe( + '4340 FLUID.ELECTRICITY.UNIT' + ) expect(wrapper.find('.graph').exists()).toBeTruthy() expect(wrapper.find('.not-connected').exists()).toBeFalsy() }) @@ -237,18 +189,12 @@ describe('AnalysisConsumptionRow component', () => { /> ) expect(wrapper.find('.consumption-electricity').exists()).toBeTruthy() - expect( - wrapper - .find('.price') - .first() - .text() - ).toBe('25 FLUID.ELECTRICITY.UNIT') - expect( - wrapper - .find('.price') - .last() - .text() - ).toBe('50 FLUID.ELECTRICITY.UNIT') + expect(wrapper.find('.price').first().text()).toBe( + '25 FLUID.ELECTRICITY.UNIT' + ) + expect(wrapper.find('.price').last().text()).toBe( + '50 FLUID.ELECTRICITY.UNIT' + ) expect(wrapper.find('.graph').exists()).toBeTruthy() expect(wrapper.find('.not-connected').exists()).toBeFalsy() }) diff --git a/src/components/Analysis/AnalysisConsumptionRow.tsx b/src/components/Analysis/AnalysisConsumptionRow.tsx index 405dd7535..e3830ee19 100644 --- a/src/components/Analysis/AnalysisConsumptionRow.tsx +++ b/src/components/Analysis/AnalysisConsumptionRow.tsx @@ -98,9 +98,11 @@ const AnalysisConsumptionRow: React.FC<AnalysisConsumptionRowProps> = ({ if (_fluid === FluidType.MULTIFLUID) { return `${(userPriceConsumption / maxPriceConsumption) * 100}%` } else { - return `${(converterService.LoadToEuro(performanceValue || 0, _fluid) / - maxPriceConsumption) * - 100}%` + return `${ + (converterService.LoadToEuro(performanceValue || 0, _fluid) / + maxPriceConsumption) * + 100 + }%` } } diff --git a/src/components/Analysis/AnalysisError.spec.tsx b/src/components/Analysis/AnalysisError.spec.tsx index 2b44b6209..efd240911 100644 --- a/src/components/Analysis/AnalysisError.spec.tsx +++ b/src/components/Analysis/AnalysisError.spec.tsx @@ -56,10 +56,7 @@ describe('AnalysisErrorModal component', () => { <AnalysisErrorModal /> </Provider> ) - wrapper - .find('.btn-secondary-positive') - .first() - .simulate('click') + wrapper.find('.btn-secondary-positive').first().simulate('click') }) it('should redirect to options', () => { const store = mockStore({ @@ -73,9 +70,6 @@ describe('AnalysisErrorModal component', () => { <AnalysisErrorModal /> </Provider> ) - wrapper - .find('.btn-highlight') - .first() - .simulate('click') + wrapper.find('.btn-highlight').first().simulate('click') }) }) diff --git a/src/components/Analysis/AnalysisView.tsx b/src/components/Analysis/AnalysisView.tsx index 9ca28b01c..5e4273398 100644 --- a/src/components/Analysis/AnalysisView.tsx +++ b/src/components/Analysis/AnalysisView.tsx @@ -25,9 +25,8 @@ const AnalysisView: React.FC = () => { } = useSelector((state: AppStore) => state.ecolyo) const { selectedDate } = useSelector((state: AppStore) => state.ecolyo.chart) - const [currentAnalysisDate, setCurrentAnalysisDate] = useState<DateTime>( - monthlyAnalysisDate - ) + const [currentAnalysisDate, setCurrentAnalysisDate] = + useState<DateTime>(monthlyAnalysisDate) const { mailToken } = useSelector((state: AppStore) => state.ecolyo.profile) const dispatch = useDispatch() diff --git a/src/components/Analysis/ElecHalfHourMonthlyAnalysis.spec.tsx b/src/components/Analysis/ElecHalfHourMonthlyAnalysis.spec.tsx index 299d2a4da..02cfa8bca 100644 --- a/src/components/Analysis/ElecHalfHourMonthlyAnalysis.spec.tsx +++ b/src/components/Analysis/ElecHalfHourMonthlyAnalysis.spec.tsx @@ -126,10 +126,7 @@ describe('ElecHalfHourMonthlyAnalysis component', () => { /> ) await waitForComponentToPaint(wrapper) - wrapper - .find(IconButton) - .first() - .simulate('click') + wrapper.find(IconButton).first().simulate('click') await waitForComponentToPaint(wrapper) expect(wrapper.find('.week').exists()).toBeTruthy() }) @@ -153,16 +150,10 @@ describe('ElecHalfHourMonthlyAnalysis component', () => { /> ) await waitForComponentToPaint(wrapper) - wrapper - .find('.showmodal') - .first() - .simulate('click') + wrapper.find('.showmodal').first().simulate('click') await waitForComponentToPaint(wrapper) - expect( - wrapper - .find('mock-elecinfomodal') - .prop('open') - ?.valueOf() - ).toBe(true) + expect(wrapper.find('mock-elecinfomodal').prop('open')?.valueOf()).toBe( + true + ) }) }) diff --git a/src/components/Analysis/ElecHalfHourMonthlyAnalysis.tsx b/src/components/Analysis/ElecHalfHourMonthlyAnalysis.tsx index 3103495ad..644dcd3fa 100644 --- a/src/components/Analysis/ElecHalfHourMonthlyAnalysis.tsx +++ b/src/components/Analysis/ElecHalfHourMonthlyAnalysis.tsx @@ -35,10 +35,9 @@ interface ElecHalfHourMonthlyAnalysisProps { perfIndicator: PerformanceIndicator } -const ElecHalfHourMonthlyAnalysis: React.FC<ElecHalfHourMonthlyAnalysisProps> = ({ - analysisDate, - perfIndicator, -}: ElecHalfHourMonthlyAnalysisProps) => { +const ElecHalfHourMonthlyAnalysis: React.FC< + ElecHalfHourMonthlyAnalysisProps +> = ({ analysisDate, perfIndicator }: ElecHalfHourMonthlyAnalysisProps) => { const { t } = useI18n() const client = useClient() const fluidConfig: Array<FluidConfig> = new ConfigService().getFluidConfig() @@ -46,12 +45,10 @@ const ElecHalfHourMonthlyAnalysis: React.FC<ElecHalfHourMonthlyAnalysisProps> = const [isWeekend, setisWeekend] = useState<boolean>(true) const [isHalfHourActivated, setisHalfHourActivated] = useState<boolean>(true) const [isLoading, setisLoading] = useState<boolean>(true) - const [monthDataloads, setMonthDataloads] = useState< - AggregatedEnedisMonthlyDataloads - >() - const [enedisAnalysisValues, setenedisAnalysisValues] = useState< - EnedisMonthlyAnalysisData - >() + const [monthDataloads, setMonthDataloads] = + useState<AggregatedEnedisMonthlyDataloads>() + const [enedisAnalysisValues, setenedisAnalysisValues] = + useState<EnedisMonthlyAnalysisData>() const [facturePercentage, setFacturePercentage] = useState<number>() const [elecPrice, setElecPrice] = useState<FluidPrice>() const [openInfoModal, setOpenInfoModal] = useState<boolean>(false) @@ -94,10 +91,11 @@ const ElecHalfHourMonthlyAnalysis: React.FC<ElecHalfHourMonthlyAnalysisProps> = if (activateHalfHourLoad) { const emas = new EnedisMonthlyAnalysisDataService(client) const aggegatedDate = analysisDate.minus({ month: 1 }) - const data: EnedisMonthlyAnalysisData[] = await emas.getEnedisMonthlyAnalysisByDate( - aggegatedDate.year, - aggegatedDate.month - ) + const data: EnedisMonthlyAnalysisData[] = + await emas.getEnedisMonthlyAnalysisByDate( + aggegatedDate.year, + aggegatedDate.month + ) if (subscribed && data && data.length) { const aggregatedData = emas.aggregateValuesToDataLoad(data[0]) setenedisAnalysisValues(data[0]) diff --git a/src/components/Analysis/MaxConsumptionCard.spec.tsx b/src/components/Analysis/MaxConsumptionCard.spec.tsx index bf2cf699d..2ddf41589 100644 --- a/src/components/Analysis/MaxConsumptionCard.spec.tsx +++ b/src/components/Analysis/MaxConsumptionCard.spec.tsx @@ -79,26 +79,14 @@ describe('MaxConsumptionCard component', () => { ) expect(wrapper.find('.arrow-next').exists()).toBeTruthy() //navigate next - wrapper - .find('.arrow-next') - .first() - .simulate('click') + wrapper.find('.arrow-next').first().simulate('click') expect(wrapper.find('.fluid').text()).toBe('FLUID.GAS.LABEL') - wrapper - .find('.arrow-next') - .first() - .simulate('click') + wrapper.find('.arrow-next').first().simulate('click') expect(wrapper.find('.fluid').text()).toBe('FLUID.ELECTRICITY.LABEL') //navigate prev - wrapper - .find('.arrow-prev') - .first() - .simulate('click') + wrapper.find('.arrow-prev').first().simulate('click') expect(wrapper.find('.fluid').text()).toBe('FLUID.GAS.LABEL') - wrapper - .find('.arrow-prev') - .first() - .simulate('click') + wrapper.find('.arrow-prev').first().simulate('click') expect(wrapper.find('.fluid').text()).toBe('FLUID.ELECTRICITY.LABEL') }) }) diff --git a/src/components/Analysis/MonthlyAnalysis.tsx b/src/components/Analysis/MonthlyAnalysis.tsx index 9349cf528..4f7287762 100644 --- a/src/components/Analysis/MonthlyAnalysis.tsx +++ b/src/components/Analysis/MonthlyAnalysis.tsx @@ -36,14 +36,12 @@ const MonthlyAnalysis: React.FC<MonthlyAnalysisProps> = ({ PerformanceIndicator[] >([]) const [loadAnalysis, setLoadAnalysis] = useState<boolean>(false) - const [ - aggregatedPerformanceIndicators, - setAggregatedPerformanceIndicators, - ] = useState<PerformanceIndicator>({ - value: 0, - compareValue: 0, - percentageVariation: 0, - }) + const [aggregatedPerformanceIndicators, setAggregatedPerformanceIndicators] = + useState<PerformanceIndicator>({ + value: 0, + compareValue: 0, + percentageVariation: 0, + }) const [isLoaded, setIsLoaded] = useState<boolean>(false) const configService = new ConfigService() const fluidConfig = configService.getFluidConfig() @@ -66,12 +64,13 @@ const MonthlyAnalysis: React.FC<MonthlyAnalysisProps> = ({ endDate: analysisDate.minus({ month: 2 }).endOf('month'), }, } - const fetchedPerformanceIndicators = await consumptionService.getPerformanceIndicators( - periods.timePeriod, - timeStep, - fluidTypes, - periods.comparisonTimePeriod - ) + const fetchedPerformanceIndicators = + await consumptionService.getPerformanceIndicators( + periods.timePeriod, + timeStep, + fluidTypes, + periods.comparisonTimePeriod + ) if (subscribed) { if (fetchedPerformanceIndicators) { setPerformanceIndicators(fetchedPerformanceIndicators) diff --git a/src/components/Challenge/ChallengeCardOnGoing.tsx b/src/components/Challenge/ChallengeCardOnGoing.tsx index 6bdb08685..e1d7fc859 100644 --- a/src/components/Challenge/ChallengeCardOnGoing.tsx +++ b/src/components/Challenge/ChallengeCardOnGoing.tsx @@ -271,10 +271,11 @@ const ChallengeCardOnGoing: React.FC<ChallengeCardOnGoingProps> = ({ <div className={'smallCard duelCard'}> <p className="starCount"> <StyledIcon icon={circleStar} size={30} /> - <span className="blueNumber">{`${userChallenge.progress - .quizProgress + + <span className="blueNumber">{`${ + userChallenge.progress.quizProgress + userChallenge.progress.explorationProgress + - userChallenge.progress.actionProgress} `}</span> + userChallenge.progress.actionProgress + } `}</span> <span>{` / ${userChallenge.target}`}</span> </p> <StyledIcon className="duelLocked" icon={duelLocked} size={60} /> diff --git a/src/components/Challenge/ChallengeCardUnlocked.spec.tsx b/src/components/Challenge/ChallengeCardUnlocked.spec.tsx index f90d18347..22c9a2f9d 100644 --- a/src/components/Challenge/ChallengeCardUnlocked.spec.tsx +++ b/src/components/Challenge/ChallengeCardUnlocked.spec.tsx @@ -68,10 +68,7 @@ describe('ChallengeCardUnlocked component', () => { <ChallengeCardUnlocked userChallenge={userChallengeData[0]} /> </Provider> ) - wrapper - .find('.btn-duel-active') - .first() - .simulate('click') + wrapper.find('.btn-duel-active').first().simulate('click') expect(wrapper.find(ChallengeNoFluidModal).exists()).toBeTruthy() expect(wrapper.find(ChallengeNoFluidModal).prop('open')).toBeTruthy() }) @@ -92,10 +89,7 @@ describe('ChallengeCardUnlocked component', () => { <ChallengeCardUnlocked userChallenge={userChallengeData[0]} /> </Provider> ) - wrapper - .find('.btn-duel-active') - .first() - .simulate('click') + wrapper.find('.btn-duel-active').first().simulate('click') expect(wrapper.find(ChallengeNoFluidModal).exists()).toBeTruthy() expect(wrapper.find(ChallengeNoFluidModal).prop('open')).toBeFalsy() expect(mockStartUserChallenge).toHaveBeenCalledWith(userChallengeData[0]) diff --git a/src/components/Challenge/ChallengeView.tsx b/src/components/Challenge/ChallengeView.tsx index 0b1c7d76c..585f18b1b 100644 --- a/src/components/Challenge/ChallengeView.tsx +++ b/src/components/Challenge/ChallengeView.tsx @@ -31,9 +31,8 @@ const ChallengeView: React.FC = () => { const [touchEnd, setTouchEnd] = useState<number>() const [index, setindex] = useState<number>(0) const [lastChallengeIndex, setlastChallengeIndex] = useState<number>(0) - const [containerTranslation, setcontainerTranslation] = useState<number>( - marginPx - ) + const [containerTranslation, setcontainerTranslation] = + useState<number>(marginPx) const defineHeaderHeight = (height: number) => { setHeaderHeight(height) } diff --git a/src/components/Charts/Bar.spec.tsx b/src/components/Charts/Bar.spec.tsx index 76e3f1a90..84c59fb72 100644 --- a/src/components/Charts/Bar.spec.tsx +++ b/src/components/Charts/Bar.spec.tsx @@ -146,10 +146,7 @@ describe('Bar component test', () => { </svg> </Provider> ) - wrapper - .find('rect') - .first() - .simulate('click') + wrapper.find('rect').first().simulate('click') expect(setSelectedDateSpy).toBeCalledTimes(1) expect(setSelectedDateSpy).toHaveBeenCalledWith( graphData.actualData[0].date diff --git a/src/components/CommonKit/IconButton/StyledIconBorderedButton.tsx b/src/components/CommonKit/IconButton/StyledIconBorderedButton.tsx index eb9e5475c..57dad61b7 100644 --- a/src/components/CommonKit/IconButton/StyledIconBorderedButton.tsx +++ b/src/components/CommonKit/IconButton/StyledIconBorderedButton.tsx @@ -37,7 +37,9 @@ interface StyledIconBorderedButtonProps extends IconButtonProps { children?: React.ReactNode } -const StyledIconBorderedButton: React.ComponentType<StyledIconBorderedButtonProps> = ({ +const StyledIconBorderedButton: React.ComponentType< + StyledIconBorderedButtonProps +> = ({ icon, size = 16, selected = false, diff --git a/src/components/Connection/ConnectionLogin.tsx b/src/components/Connection/ConnectionLogin.tsx index 4ece0f1ea..ae572a9eb 100644 --- a/src/components/Connection/ConnectionLogin.tsx +++ b/src/components/Connection/ConnectionLogin.tsx @@ -18,14 +18,10 @@ const ConnectionLogin: React.FC<ConnectionLoginProps> = ({ const konnectorSlug: string = fluidStatus.connection.konnectorConfig.slug const siteLink: string = fluidStatus.connection.konnectorConfig.siteLink - const [ - openPartenerConnectionModal, - setOpenPartenerConnectionModal, - ] = useState<boolean>(false) - const [ - hasSeenPartnerConnectionModal, - setHasSeenPartnerConnectionModal, - ] = useState<boolean>(false) + const [openPartenerConnectionModal, setOpenPartenerConnectionModal] = + useState<boolean>(false) + const [hasSeenPartnerConnectionModal, setHasSeenPartnerConnectionModal] = + useState<boolean>(false) const togglePartnerConnectionModal = useCallback(() => { setOpenPartenerConnectionModal(prev => !prev) diff --git a/src/components/Connection/ConnectionOAuth.tsx b/src/components/Connection/ConnectionOAuth.tsx index 97e56a077..a87eaa1b7 100644 --- a/src/components/Connection/ConnectionOAuth.tsx +++ b/src/components/Connection/ConnectionOAuth.tsx @@ -24,14 +24,10 @@ const ConnectionOAuth: React.FC<ConnectionOAuthProps> = ({ const client = useClient() const dispatch = useDispatch() - const [ - openPartenerConnectionModal, - setOpenPartenerConnectionModal, - ] = useState<boolean>(false) - const [ - hasSeenPartnerConnectionModal, - setHasSeenPartnerConnectionModal, - ] = useState<boolean>(false) + const [openPartenerConnectionModal, setOpenPartenerConnectionModal] = + useState<boolean>(false) + const [hasSeenPartnerConnectionModal, setHasSeenPartnerConnectionModal] = + useState<boolean>(false) const konnectorSlug: string = fluidStatus.connection.konnectorConfig.slug const siteLink: string = fluidStatus.connection.konnectorConfig.siteLink diff --git a/src/components/Connection/ConnectionResult.tsx b/src/components/Connection/ConnectionResult.tsx index e5e94863b..d24a9512e 100644 --- a/src/components/Connection/ConnectionResult.tsx +++ b/src/components/Connection/ConnectionResult.tsx @@ -48,9 +48,8 @@ const ConnectionResult: React.FC<ConnectionResultProps> = ({ const [konnectorError, setKonnectorError] = useState<string>('') const [status, setStatus] = useState<string>('') const [outDatedDataDays, setOutDatedDataDays] = useState<number | null>(null) - const [openGRDFDeletionModal, setOpenGRDFDeletionModal] = useState<boolean>( - false - ) + const [openGRDFDeletionModal, setOpenGRDFDeletionModal] = + useState<boolean>(false) const toggleGRDFDeletionModal = useCallback(() => { setOpenGRDFDeletionModal(prev => !prev) }, []) @@ -79,9 +78,8 @@ const ConnectionResult: React.FC<ConnectionResultProps> = ({ account.account_type ) for (const _account of accounts) { - const trigger: Trigger | null = await triggerService.getTriggerForAccount( - _account - ) + const trigger: Trigger | null = + await triggerService.getTriggerForAccount(_account) if (trigger) await triggerService.deleteTrigger(trigger) await accountService.deleteAccount(_account) } diff --git a/src/components/Connection/DeleteGRDFAccountModal.spec.tsx b/src/components/Connection/DeleteGRDFAccountModal.spec.tsx index 915201412..a51703894 100644 --- a/src/components/Connection/DeleteGRDFAccountModal.spec.tsx +++ b/src/components/Connection/DeleteGRDFAccountModal.spec.tsx @@ -35,10 +35,7 @@ describe('DeleteGRDFAccountModal component', () => { deleteAccount={mockDelete} /> ) - component - .find(Button) - .at(1) - .simulate('click') + component.find(Button).at(1).simulate('click') expect(mockDelete).toHaveBeenCalledTimes(1) }) }) diff --git a/src/components/Connection/ExpiredConsentModal.spec.tsx b/src/components/Connection/ExpiredConsentModal.spec.tsx index 0f4931663..b52ebe564 100644 --- a/src/components/Connection/ExpiredConsentModal.spec.tsx +++ b/src/components/Connection/ExpiredConsentModal.spec.tsx @@ -58,10 +58,7 @@ describe('ExpiredConsentModal component', () => { /> </Provider> ) - component - .find(Button) - .at(1) - .simulate('click') + component.find(Button).at(1).simulate('click') expect(useDispatchSpy).toHaveBeenCalledTimes(1) expect(mockHistoryPush).toHaveBeenCalledTimes(1) }) diff --git a/src/components/Connection/FormLogin.tsx b/src/components/Connection/FormLogin.tsx index c184fa715..38251f47a 100644 --- a/src/components/Connection/FormLogin.tsx +++ b/src/components/Connection/FormLogin.tsx @@ -88,10 +88,8 @@ const FormLogin: React.FC<FormLoginProps> = ({ target: konnectorSlug, result: 'error', }) - const { - account: _account, - trigger: _trigger, - } = await connectionService.connectNewUser(konnectorSlug, login, password) + const { account: _account, trigger: _trigger } = + await connectionService.connectNewUser(konnectorSlug, login, password) if (!_trigger) { setError(t('konnector_form.error_account_creation')) sendUsageEventError(konnectorSlug) diff --git a/src/components/ConsumptionVisualizer/ConsumptionVisualizer.tsx b/src/components/ConsumptionVisualizer/ConsumptionVisualizer.tsx index 11d886857..11007d24c 100644 --- a/src/components/ConsumptionVisualizer/ConsumptionVisualizer.tsx +++ b/src/components/ConsumptionVisualizer/ConsumptionVisualizer.tsx @@ -41,7 +41,7 @@ const ConsumptionVisualizer: React.FC<ConsumptionVisualizerProps> = ({ } } if (lastDays.length > 0) { - lastDay = lastDays.reduce(function(a, b) { + lastDay = lastDays.reduce(function (a, b) { return a < b ? a : b }) } diff --git a/src/components/ConsumptionVisualizer/DataloadConsumptionVisualizer.spec.tsx b/src/components/ConsumptionVisualizer/DataloadConsumptionVisualizer.spec.tsx index d8ff32d39..74f271ffd 100644 --- a/src/components/ConsumptionVisualizer/DataloadConsumptionVisualizer.spec.tsx +++ b/src/components/ConsumptionVisualizer/DataloadConsumptionVisualizer.spec.tsx @@ -130,12 +130,7 @@ describe('Dataload consumption visualizer component', () => { /> </Provider> ) - expect( - wrapper - .find('.estimated') - .first() - .simulate('click') - ) + expect(wrapper.find('.estimated').first().simulate('click')) }) it('should render multifluid with no compare and navigate to singleFluid page', async () => { const store = mockStore({ @@ -170,10 +165,7 @@ describe('Dataload consumption visualizer component', () => { UsageEventService.addEvent = mockAddEvent //Render Navlinks to fluids - wrapper - .find('.dataloadvisualizer-euro-fluid') - .first() - .simulate('click') + wrapper.find('.dataloadvisualizer-euro-fluid').first().simulate('click') expect(mockAddEvent).toHaveBeenCalled() }) }) diff --git a/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx b/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx index 0297049b0..4181b6a2e 100644 --- a/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx +++ b/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx @@ -48,10 +48,7 @@ describe('DataloadSectionValue component', () => { /> ) expect( - wrapper - .find(DataloadSectionValue) - .first() - .contains('12,00') + wrapper.find(DataloadSectionValue).first().contains('12,00') ).toBeTruthy() expect(wrapper.find('.text-18-normal').text()).toBe( 'FLUID.ELECTRICITY.UNIT' @@ -68,10 +65,7 @@ describe('DataloadSectionValue component', () => { /> ) expect( - wrapper - .find(DataloadSectionValue) - .first() - .contains('1,00') + wrapper.find(DataloadSectionValue).first().contains('1,00') ).toBeTruthy() expect(wrapper.find('.text-18-normal').text()).toBe( 'FLUID.ELECTRICITY.MEGAUNIT' @@ -90,10 +84,7 @@ describe('DataloadSectionValue component', () => { /> ) expect( - wrapper - .find(DataloadSectionValue) - .first() - .contains('12,00') + wrapper.find(DataloadSectionValue).first().contains('12,00') ).toBeTruthy() expect(wrapper.find('.euroUnit').exists()).toBeTruthy() }) @@ -107,10 +98,7 @@ describe('DataloadSectionValue component', () => { /> ) expect( - wrapper - .find(DataloadSectionValue) - .first() - .contains('12,00') + wrapper.find(DataloadSectionValue).first().contains('12,00') ).toBeTruthy() expect(wrapper.find('.euroUnit').exists()).toBeTruthy() expect(wrapper.find('.estimated').exists()).toBeTruthy() diff --git a/src/components/DateNavigator/DateNavigator.spec.tsx b/src/components/DateNavigator/DateNavigator.spec.tsx index 05504108f..bfa2adf66 100644 --- a/src/components/DateNavigator/DateNavigator.spec.tsx +++ b/src/components/DateNavigator/DateNavigator.spec.tsx @@ -62,10 +62,7 @@ describe('DateNavigator component', () => { await new Promise(resolve => setTimeout(resolve)) wrapper.update() }) - wrapper - .find(IconButton) - .first() - .simulate('click') + wrapper.find(IconButton).first().simulate('click') expect(mockUseDispatch).toHaveBeenCalledTimes(2) }) it('should click on right arrow and change date', async () => { @@ -84,10 +81,7 @@ describe('DateNavigator component', () => { await new Promise(resolve => setTimeout(resolve)) wrapper.update() }) - wrapper - .find(IconButton) - .at(1) - .simulate('click') + wrapper.find(IconButton).at(1).simulate('click') expect(mockUseDispatch).toHaveBeenCalledTimes(3) }) @@ -107,10 +101,7 @@ describe('DateNavigator component', () => { await new Promise(resolve => setTimeout(resolve)) wrapper.update() }) - wrapper - .find(IconButton) - .at(0) - .simulate('click') + wrapper.find(IconButton).at(0).simulate('click') expect(mockUseDispatch).toHaveBeenCalledTimes(4) }) it('should be rendered without analysis date and change to next index', async () => { @@ -129,10 +120,7 @@ describe('DateNavigator component', () => { await new Promise(resolve => setTimeout(resolve)) wrapper.update() }) - wrapper - .find(IconButton) - .at(1) - .simulate('click') + wrapper.find(IconButton).at(1).simulate('click') expect(mockUseDispatch).toHaveBeenCalledTimes(5) }) }) diff --git a/src/components/DateNavigator/DateNavigator.tsx b/src/components/DateNavigator/DateNavigator.tsx index 6ab0e3bdd..ff14f1f74 100644 --- a/src/components/DateNavigator/DateNavigator.tsx +++ b/src/components/DateNavigator/DateNavigator.tsx @@ -73,11 +73,12 @@ const DateNavigator: React.FC<DateNavigatorProps> = ({ const handleChangePrevIndex = () => { if (!disablePrev && isKonnectorActive(fluidStatus, FluidType.MULTIFLUID)) { - const increment: number = dateChartService.defineIncrementForPreviousIndex( - currentTimeStep, - selectedDate, - currentIndex - ) + const increment: number = + dateChartService.defineIncrementForPreviousIndex( + currentTimeStep, + selectedDate, + currentIndex + ) if (currentAnalysisDate) { handleClickMove(-1) } else handleClickMove(increment) diff --git a/src/components/Duel/DuelUnlocked.spec.tsx b/src/components/Duel/DuelUnlocked.spec.tsx index cde3182ef..74b23a054 100644 --- a/src/components/Duel/DuelUnlocked.spec.tsx +++ b/src/components/Duel/DuelUnlocked.spec.tsx @@ -88,10 +88,7 @@ describe('DuelUnlocked component', () => { <DuelUnlocked userChallenge={userChallengeData[0]} /> </Provider> ) - wrapper - .find('.button-start') - .find(Button) - .simulate('click') + wrapper.find('.button-start').find(Button).simulate('click') expect(mockUserChallengeUpdateFlag).toHaveBeenCalledWith( userChallengeData[0], UserChallengeUpdateFlag.DUEL_START diff --git a/src/components/Ecogesture/EcogestureEmptyList.spec.tsx b/src/components/Ecogesture/EcogestureEmptyList.spec.tsx index 1093a09a8..c6318f0fc 100644 --- a/src/components/Ecogesture/EcogestureEmptyList.spec.tsx +++ b/src/components/Ecogesture/EcogestureEmptyList.spec.tsx @@ -61,10 +61,7 @@ describe('EcogestureEmptyList component', () => { /> </Provider> ) - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') expect(mockChangeTab).toHaveBeenCalledTimes(1) }) it('should launch ecogesture form', () => { @@ -83,10 +80,7 @@ describe('EcogestureEmptyList component', () => { /> </Provider> ) - wrapper - .find(Button) - .at(1) - .simulate('click') + wrapper.find(Button).at(1).simulate('click') expect(mockHistoryPush).toHaveBeenCalledWith('/ecogesture-form') }) it('should render doing text with empty list on completed selection', () => { @@ -106,12 +100,9 @@ describe('EcogestureEmptyList component', () => { </Provider> ) - expect( - wrapper - .find('.text') - .first() - .text() - ).toBe('ecogesture.emptyList.doing1_done') + expect(wrapper.find('.text').first().text()).toBe( + 'ecogesture.emptyList.doing1_done' + ) }) it('should render objective text with empty list on completed selection', () => { const store = mockStore({ @@ -130,11 +121,8 @@ describe('EcogestureEmptyList component', () => { </Provider> ) - expect( - wrapper - .find('.text') - .first() - .text() - ).toBe('ecogesture.emptyList.obj1_done') + expect(wrapper.find('.text').first().text()).toBe( + 'ecogesture.emptyList.obj1_done' + ) }) }) diff --git a/src/components/Ecogesture/EcogestureInitModal.spec.tsx b/src/components/Ecogesture/EcogestureInitModal.spec.tsx index 298dd9d93..ed59dc9cb 100644 --- a/src/components/Ecogesture/EcogestureInitModal.spec.tsx +++ b/src/components/Ecogesture/EcogestureInitModal.spec.tsx @@ -76,10 +76,7 @@ describe('EcogestureInitModal component', () => { /> </Provider> ) - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') expect(mockHandleClose).toHaveBeenCalledTimes(1) }) it('should close modal and maunch form', async () => { @@ -100,10 +97,7 @@ describe('EcogestureInitModal component', () => { /> </Provider> ) - wrapper - .find(Button) - .at(1) - .simulate('click') + wrapper.find(Button).at(1).simulate('click') expect(mockHandleLaunchForm).toHaveBeenCalledTimes(1) }) }) diff --git a/src/components/Ecogesture/EcogestureList.spec.tsx b/src/components/Ecogesture/EcogestureList.spec.tsx index f56bd2f23..e0ab6d225 100644 --- a/src/components/Ecogesture/EcogestureList.spec.tsx +++ b/src/components/Ecogesture/EcogestureList.spec.tsx @@ -69,15 +69,9 @@ describe('EcogesturesList component', () => { ) await waitForComponentToPaint(wrapper) wrapper.find('.filter-button').simulate('click') - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') expect(wrapper.find('.filter-menu').exists()).toBeTruthy() - wrapper - .find(MenuItem) - .at(1) - .simulate('click') + wrapper.find(MenuItem).at(1).simulate('click') expect(wrapper.find('.ecogestures').text()).toBe('ecogesture.HEATING') }) diff --git a/src/components/Ecogesture/EcogestureView.spec.tsx b/src/components/Ecogesture/EcogestureView.spec.tsx index cc3aa53c2..b62290252 100644 --- a/src/components/Ecogesture/EcogestureView.spec.tsx +++ b/src/components/Ecogesture/EcogestureView.spec.tsx @@ -121,10 +121,7 @@ describe('EcogestureView component', () => { await waitForComponentToPaint(wrapper) expect(wrapper.find(EcogestureInitModal).exists()).toBeTruthy() - wrapper - .find(IconButton) - .first() - .simulate('click') + wrapper.find(IconButton).first().simulate('click') await waitForComponentToPaint(wrapper) expect(updateProfileSpy).toHaveBeenCalledWith({ @@ -166,10 +163,7 @@ describe('EcogestureView component', () => { ) await waitForComponentToPaint(wrapper) - wrapper - .find(Tab) - .first() - .simulate('click') + wrapper.find(Tab).first().simulate('click') mockgetAllEcogestures.mockResolvedValueOnce([]) await waitForComponentToPaint(wrapper) diff --git a/src/components/Ecogesture/EcogestureView.tsx b/src/components/Ecogesture/EcogestureView.tsx index afd4096cc..05f9f3cf7 100644 --- a/src/components/Ecogesture/EcogestureView.tsx +++ b/src/components/Ecogesture/EcogestureView.tsx @@ -77,12 +77,10 @@ const EcogestureView: React.FC = () => { >([]) const [totalViewed, setTotalViewed] = useState<number>(0) const [totalAvailable, setTotalAvailable] = useState<number>(0) - const [openEcogestureInitModal, setOpenEcogestureInitModal] = useState< - boolean - >(!haveSeenEcogestureModal) - const [openEcogestureReinitModal, setOpenEcogestureReinitModal] = useState< - boolean - >(false) + const [openEcogestureInitModal, setOpenEcogestureInitModal] = + useState<boolean>(!haveSeenEcogestureModal) + const [openEcogestureReinitModal, setOpenEcogestureReinitModal] = + useState<boolean>(false) const handleReinitClick = useCallback(() => { setOpenEcogestureReinitModal(true) @@ -159,9 +157,8 @@ const EcogestureView: React.FC = () => { async function loadEcogestures() { const ecogestureService = new EcogestureService(client) const dataAll = await ecogestureService.getAllEcogestures(getSeason()) - const availableList: Ecogesture[] = await ecogestureService.getEcogestureListByProfile( - profileEcogesture - ) + const availableList: Ecogesture[] = + await ecogestureService.getEcogestureListByProfile(profileEcogesture) const filteredList: Ecogesture[] = availableList.filter( (ecogesture: Ecogesture) => ecogesture.viewedInSelection === false ) diff --git a/src/components/Ecogesture/SingleEcogesture.spec.tsx b/src/components/Ecogesture/SingleEcogesture.spec.tsx index ae4e3360e..b70a8f41f 100644 --- a/src/components/Ecogesture/SingleEcogesture.spec.tsx +++ b/src/components/Ecogesture/SingleEcogesture.spec.tsx @@ -107,10 +107,7 @@ describe('SingleEcogesture component', () => { ) await waitForComponentToPaint(wrapper) - wrapper - .find('.doing-btn') - .first() - .simulate('click') + wrapper.find('.doing-btn').first().simulate('click') await waitForComponentToPaint(wrapper) expect(mockupdateEcogesture).toHaveBeenCalledWith(updatedEcogesture) @@ -139,10 +136,7 @@ describe('SingleEcogesture component', () => { ) await waitForComponentToPaint(wrapper) - wrapper - .find('.objective-btn') - .first() - .simulate('click') + wrapper.find('.objective-btn').first().simulate('click') await waitForComponentToPaint(wrapper) expect(mockupdateEcogesture).toHaveBeenCalledWith(updatedEcogesture) }) @@ -168,10 +162,7 @@ describe('SingleEcogesture component', () => { ) await waitForComponentToPaint(wrapper) - wrapper - .find('.toggle-text') - .first() - .simulate('click') + wrapper.find('.toggle-text').first().simulate('click') await waitForComponentToPaint(wrapper) expect(wrapper.find('.toggle-text').text()).toBe( diff --git a/src/components/Ecogesture/SingleEcogesture.tsx b/src/components/Ecogesture/SingleEcogesture.tsx index 9267cccc3..82af5587e 100644 --- a/src/components/Ecogesture/SingleEcogesture.tsx +++ b/src/components/Ecogesture/SingleEcogesture.tsx @@ -47,9 +47,10 @@ const SingleEcogesture: React.FC<SingleEcogestureProps> = ({ const selectionCompleted = location && location.state && location.state.selectionCompleted - const ecogestureService = useMemo(() => new EcogestureService(client), [ - client, - ]) + const ecogestureService = useMemo( + () => new EcogestureService(client), + [client] + ) const { currentChallenge } = useSelector( (state: AppStore) => state.ecolyo.challenge ) @@ -194,8 +195,9 @@ const SingleEcogesture: React.FC<SingleEcogestureProps> = ({ aria-label={t('ecogesture.objective')} onClick={toggleObjective} classes={{ - root: `btn-secondary-negative objective-btn ${isObjective && - 'active'}`, + root: `btn-secondary-negative objective-btn ${ + isObjective && 'active' + }`, label: 'text-15-normal', }} > @@ -212,8 +214,9 @@ const SingleEcogesture: React.FC<SingleEcogestureProps> = ({ aria-label={t('ecogesture.doing')} onClick={toggleDoing} classes={{ - root: `btn-secondary-negative doing-btn ${isDoing && - 'active'}`, + root: `btn-secondary-negative doing-btn ${ + isDoing && 'active' + }`, label: 'text-15-normal', }} > diff --git a/src/components/EcogestureForm/EcogestureFormEquipment.spec.tsx b/src/components/EcogestureForm/EcogestureFormEquipment.spec.tsx index 536dcb381..c98ae7093 100644 --- a/src/components/EcogestureForm/EcogestureFormEquipment.spec.tsx +++ b/src/components/EcogestureForm/EcogestureFormEquipment.spec.tsx @@ -80,10 +80,7 @@ describe('EcogestureFormEquipment component', () => { </Provider> ) await waitForComponentToPaint(wrapper) - wrapper - .find(Button) - .at(1) - .simulate('click') + wrapper.find(Button).at(1).simulate('click') expect(mockUseDispatch).toHaveBeenCalledTimes(2) }) it('should select equipment and unselect it', async () => { @@ -105,29 +102,13 @@ describe('EcogestureFormEquipment component', () => { </Provider> ) await waitForComponentToPaint(wrapper) - wrapper - .find('.item-eq') - .first() - .simulate('change') + wrapper.find('.item-eq').first().simulate('change') await waitForComponentToPaint(wrapper) - expect( - wrapper - .find('.item-eq') - .first() - .hasClass('checked') - ).toBeTruthy - wrapper - .find('.checked') - .first() - .simulate('change') + expect(wrapper.find('.item-eq').first().hasClass('checked')).toBeTruthy + wrapper.find('.checked').first().simulate('change') await waitForComponentToPaint(wrapper) - expect( - wrapper - .find('.item-eq') - .first() - .hasClass('checked') - ).toBeFalsy() + expect(wrapper.find('.item-eq').first().hasClass('checked')).toBeFalsy() }) it('should click on disabled back button', async () => { @@ -148,10 +129,7 @@ describe('EcogestureFormEquipment component', () => { </Provider> ) await waitForComponentToPaint(wrapper) - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') await waitForComponentToPaint(wrapper) expect(wrapper.find('.icons-container').exists()).toBeTruthy() diff --git a/src/components/EcogestureForm/EcogestureFormSingleChoice.spec.tsx b/src/components/EcogestureForm/EcogestureFormSingleChoice.spec.tsx index 09853bbc8..f86f26f4d 100644 --- a/src/components/EcogestureForm/EcogestureFormSingleChoice.spec.tsx +++ b/src/components/EcogestureForm/EcogestureFormSingleChoice.spec.tsx @@ -70,10 +70,7 @@ describe('EcogestureFormSingleChoice component', () => { </Provider> ) await waitForComponentToPaint(wrapper) - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') expect(mockHandlePreviousStep).toHaveBeenCalledTimes(0) }) @@ -91,15 +88,9 @@ describe('EcogestureFormSingleChoice component', () => { </Provider> ) await waitForComponentToPaint(wrapper) - wrapper - .find('input') - .first() - .simulate('change') + wrapper.find('input').first().simulate('change') await waitForComponentToPaint(wrapper) - wrapper - .find(Button) - .at(1) - .simulate('click') + wrapper.find(Button).at(1).simulate('click') expect(mockHandleNextStep).toHaveBeenCalledTimes(1) }) @@ -117,10 +108,7 @@ describe('EcogestureFormSingleChoice component', () => { </Provider> ) await waitForComponentToPaint(wrapper) - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') expect(mockHandlePreviousStep).toHaveBeenCalledTimes(1) }) it('should keep previous answer', async () => { @@ -137,11 +125,6 @@ describe('EcogestureFormSingleChoice component', () => { </Provider> ) await waitForComponentToPaint(wrapper) - expect( - wrapper - .find('input') - .first() - .hasClass('checked-input') - ).toBe(true) + expect(wrapper.find('input').first().hasClass('checked-input')).toBe(true) }) }) diff --git a/src/components/EcogestureForm/EcogestureFormView.spec.tsx b/src/components/EcogestureForm/EcogestureFormView.spec.tsx index 7dfa7f922..0a86e6bb3 100644 --- a/src/components/EcogestureForm/EcogestureFormView.spec.tsx +++ b/src/components/EcogestureForm/EcogestureFormView.spec.tsx @@ -85,15 +85,9 @@ describe('EcogestureFormView component', () => { </Provider> ) await waitForComponentToPaint(wrapper) - wrapper - .find('input') - .first() - .simulate('change') + wrapper.find('input').first().simulate('change') await waitForComponentToPaint(wrapper) - wrapper - .find(Button) - .at(1) - .simulate('click') + wrapper.find(Button).at(1).simulate('click') await waitForComponentToPaint(wrapper) expect(wrapper.find('.ecogesture-form-single').exists()).toBeTruthy() }) @@ -105,22 +99,13 @@ describe('EcogestureFormView component', () => { ) //go first to next step await waitForComponentToPaint(wrapper) - wrapper - .find('input') - .first() - .simulate('change') + wrapper.find('input').first().simulate('change') await waitForComponentToPaint(wrapper) console.log(wrapper.debug()) - wrapper - .find(Button) - .at(1) - .simulate('click') + wrapper.find(Button).at(1).simulate('click') await waitForComponentToPaint(wrapper) //then go back - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') expect(wrapper.find('.ecogesture-form-single').exists()).toBeTruthy() }) }) diff --git a/src/components/EcogestureForm/EcogestureFormView.tsx b/src/components/EcogestureForm/EcogestureFormView.tsx index cb07519ce..23dda8090 100644 --- a/src/components/EcogestureForm/EcogestureFormView.tsx +++ b/src/components/EcogestureForm/EcogestureFormView.tsx @@ -49,9 +49,8 @@ const EcogestureFormView: React.FC = () => { shouldOpenModal !== 'false' ? true : false ) const [viewedStep, setViewedStep] = useState<number>(-1) - const [profileEcogesture, setProfileEcogesture] = useState<ProfileEcogesture>( - curProfileEcogesture - ) + const [profileEcogesture, setProfileEcogesture] = + useState<ProfileEcogesture>(curProfileEcogesture) const setNextStep = useCallback( (_profileEcogesture: ProfileEcogesture) => { setProfileEcogesture(_profileEcogesture) @@ -61,9 +60,8 @@ const EcogestureFormView: React.FC = () => { if (nextStep > viewedStep) { setViewedStep(nextStep) } - const _answerType: ProfileEcogestureAnswer = ProfileEcogestureFormService.getAnswerForStep( - nextStep - ) + const _answerType: ProfileEcogestureAnswer = + ProfileEcogestureFormService.getAnswerForStep(nextStep) setAnswerType(_answerType) setStep(nextStep) }, @@ -75,9 +73,8 @@ const EcogestureFormView: React.FC = () => { const pefs = new ProfileEcogestureFormService(_profileEcogesture) const previousStep: EcogestureStepForm = pefs.getPreviousFormStep(step) setIsLoading(true) - const _answerType: ProfileEcogestureAnswer = ProfileEcogestureFormService.getAnswerForStep( - previousStep - ) + const _answerType: ProfileEcogestureAnswer = + ProfileEcogestureFormService.getAnswerForStep(previousStep) setAnswerType(_answerType) setStep(previousStep) }, @@ -85,9 +82,8 @@ const EcogestureFormView: React.FC = () => { ) useEffect(() => { - const _answerType: ProfileEcogestureAnswer = ProfileEcogestureFormService.getAnswerForStep( - step - ) + const _answerType: ProfileEcogestureAnswer = + ProfileEcogestureFormService.getAnswerForStep(step) setAnswerType(_answerType) setIsLoading(false) }, [step]) diff --git a/src/components/EcogestureForm/EcogestureLaunchFormModal.spec.tsx b/src/components/EcogestureForm/EcogestureLaunchFormModal.spec.tsx index 33e0bbaa3..c41160d25 100644 --- a/src/components/EcogestureForm/EcogestureLaunchFormModal.spec.tsx +++ b/src/components/EcogestureForm/EcogestureLaunchFormModal.spec.tsx @@ -32,10 +32,7 @@ describe('EcogestureLaunchFormModal component', () => { handleCloseClick={mockHandleClose} /> ) - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') expect(mockHandleClose).toHaveBeenCalledTimes(1) }) }) diff --git a/src/components/EcogestureForm/EquipmentIcon.spec.tsx b/src/components/EcogestureForm/EquipmentIcon.spec.tsx index 8e341372e..701193a4d 100644 --- a/src/components/EcogestureForm/EquipmentIcon.spec.tsx +++ b/src/components/EcogestureForm/EquipmentIcon.spec.tsx @@ -38,11 +38,6 @@ describe('EcogestureFormSingleChoice component', () => { <EquipmentIcon equipment={EquipmentType.BOILER} isChecked={true} /> ) await waitForComponentToPaint(wrapper) - expect( - wrapper - .find('.checked') - .first() - .exists() - ).toBeTruthy() + expect(wrapper.find('.checked').first().exists()).toBeTruthy() }) }) diff --git a/src/components/EcogestureSelection/EcogestureSelection.tsx b/src/components/EcogestureSelection/EcogestureSelection.tsx index 870a7719f..4af2bd057 100644 --- a/src/components/EcogestureSelection/EcogestureSelection.tsx +++ b/src/components/EcogestureSelection/EcogestureSelection.tsx @@ -26,18 +26,17 @@ const EcogestureSelection: React.FC = () => { const [ecogestureList, setEcogestureList] = useState<Ecogesture[]>([]) const [totalViewed, setTotalViewed] = useState<number>(0) const [totalAvailable, setTotalAvailable] = useState<number>(0) - const [ - openEcogestureSelectionModal, - setOpenEcogestureSelectionModal, - ] = useState(false) + const [openEcogestureSelectionModal, setOpenEcogestureSelectionModal] = + useState(false) const defineHeaderHeight = useCallback((height: number) => { setHeaderHeight(height) }, []) - const ecogestureService = useMemo(() => new EcogestureService(client), [ - client, - ]) + const ecogestureService = useMemo( + () => new EcogestureService(client), + [client] + ) const profileEcogesture: ProfileEcogesture = useSelector( (state: AppStore) => state.ecolyo.profileEcogesture ) @@ -54,14 +53,13 @@ const EcogestureSelection: React.FC = () => { const validateChoice = useCallback( async (objective: boolean, doing: boolean) => { - const updatedEcogesture: Ecogesture = await ecogestureService.updateEcogesture( - { + const updatedEcogesture: Ecogesture = + await ecogestureService.updateEcogesture({ ...ecogestureList[indexEcogesture], objective: objective, doing: doing, viewedInSelection: true, - } - ) + }) const updatedList: Ecogesture[] = ecogestureList updatedList[indexEcogesture] = updatedEcogesture setEcogestureList(updatedList) @@ -72,9 +70,8 @@ const EcogestureSelection: React.FC = () => { const restartSelection = useCallback(async () => { setIsLoading(true) - const availableList: Ecogesture[] = await ecogestureService.getEcogestureListByProfile( - profileEcogesture - ) + const availableList: Ecogesture[] = + await ecogestureService.getEcogestureListByProfile(profileEcogesture) const filteredList: Ecogesture[] = availableList.filter( (ecogesture: Ecogesture) => ecogesture.viewedInSelection === false ) @@ -88,9 +85,8 @@ const EcogestureSelection: React.FC = () => { useEffect(() => { let subscribed = true async function getFilteredList() { - const availableList: Ecogesture[] = await ecogestureService.getEcogestureListByProfile( - profileEcogesture - ) + const availableList: Ecogesture[] = + await ecogestureService.getEcogestureListByProfile(profileEcogesture) const filteredList: Ecogesture[] = availableList.filter( (ecogesture: Ecogesture) => ecogesture.viewedInSelection === false ) diff --git a/src/components/EcogestureSelection/EcogestureSelectionDetail.spec.tsx b/src/components/EcogestureSelection/EcogestureSelectionDetail.spec.tsx index 73075d03b..b3503365c 100644 --- a/src/components/EcogestureSelection/EcogestureSelectionDetail.spec.tsx +++ b/src/components/EcogestureSelection/EcogestureSelectionDetail.spec.tsx @@ -51,10 +51,7 @@ describe('EcogestureSelectionDetail component', () => { validate={mockValidate} /> ) - wrapper - .find(Button) - .at(0) - .simulate('click') + wrapper.find(Button).at(0).simulate('click') await waitForComponentToPaint(wrapper) expect(mockValidate).toHaveBeenCalledWith(true, false) }) @@ -67,10 +64,7 @@ describe('EcogestureSelectionDetail component', () => { validate={mockValidate} /> ) - wrapper - .find(Button) - .at(1) - .simulate('click') + wrapper.find(Button).at(1).simulate('click') await waitForComponentToPaint(wrapper) expect(mockValidate).toHaveBeenCalledWith(false, true) }) @@ -83,10 +77,7 @@ describe('EcogestureSelectionDetail component', () => { validate={mockValidate} /> ) - wrapper - .find(Button) - .at(2) - .simulate('click') + wrapper.find(Button).at(2).simulate('click') await waitForComponentToPaint(wrapper) expect(mockValidate).toHaveBeenCalledWith(false, false) }) diff --git a/src/components/EcogestureSelection/EcogestureSelectionRestart.spec.tsx b/src/components/EcogestureSelection/EcogestureSelectionRestart.spec.tsx index 58b468538..3f1835b68 100644 --- a/src/components/EcogestureSelection/EcogestureSelectionRestart.spec.tsx +++ b/src/components/EcogestureSelection/EcogestureSelectionRestart.spec.tsx @@ -39,10 +39,7 @@ describe('EcogestureSelectionRestart component', () => { const wrapper = mount( <EcogestureSelectionRestart listLength={10} restart={mockRestart} /> ) - wrapper - .find(Button) - .at(0) - .simulate('click') + wrapper.find(Button).at(0).simulate('click') expect(mockHistoryPush).toHaveBeenCalledWith('/ecogestures?tab=0') }) @@ -50,10 +47,7 @@ describe('EcogestureSelectionRestart component', () => { const wrapper = mount( <EcogestureSelectionRestart listLength={10} restart={mockRestart} /> ) - wrapper - .find(Button) - .at(1) - .simulate('click') + wrapper.find(Button).at(1).simulate('click') expect(mockRestart).toHaveBeenCalledTimes(1) }) }) diff --git a/src/components/Exploration/ExplorationFinished.spec.tsx b/src/components/Exploration/ExplorationFinished.spec.tsx index acf9914d8..76557e2c0 100644 --- a/src/components/Exploration/ExplorationFinished.spec.tsx +++ b/src/components/Exploration/ExplorationFinished.spec.tsx @@ -58,9 +58,6 @@ describe('ExplorationFinished', () => { <ExplorationFinished userChallenge={userChallengeData[0]} /> </Provider> ) - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') }) }) diff --git a/src/components/Exploration/ExplorationOngoing.spec.tsx b/src/components/Exploration/ExplorationOngoing.spec.tsx index 58298416b..5a5405363 100644 --- a/src/components/Exploration/ExplorationOngoing.spec.tsx +++ b/src/components/Exploration/ExplorationOngoing.spec.tsx @@ -52,16 +52,10 @@ describe('ExplorationOngoing component', () => { </Provider> ) expect( - wrapper - .find('.exploration-explanation > div') - .first() - .text() + wrapper.find('.exploration-explanation > div').first().text() ).toEqual(userChallengeData[1].exploration.description) expect( - wrapper - .find('.exploration-explanation > div') - .last() - .text() + wrapper.find('.exploration-explanation > div').last().text() ).toEqual(userChallengeData[1].exploration.complementary_description) expect(wrapper.find('.button-start').exists()).toBeTruthy() }) diff --git a/src/components/FAQ/FAQContent.tsx b/src/components/FAQ/FAQContent.tsx index 2574e4d7d..e510abed5 100644 --- a/src/components/FAQ/FAQContent.tsx +++ b/src/components/FAQ/FAQContent.tsx @@ -20,13 +20,11 @@ const FAQContent: React.FC = () => { const [expanded, setExpanded] = useState<string | false>(false) const [faqData, setFaqData] = useState<FAQSection[]>([]) - const handleChange = (panel: string) => ( - event: React.ChangeEvent<{}>, - isExpanded: boolean - ) => { - event.preventDefault() - setExpanded(isExpanded ? panel : false) - } + const handleChange = + (panel: string) => (event: React.ChangeEvent<{}>, isExpanded: boolean) => { + event.preventDefault() + setExpanded(isExpanded ? panel : false) + } useEffect(() => { let subscribed = true diff --git a/src/components/Feedback/FeedbackModal.spec.tsx b/src/components/Feedback/FeedbackModal.spec.tsx index 31650c119..3a5a63748 100644 --- a/src/components/Feedback/FeedbackModal.spec.tsx +++ b/src/components/Feedback/FeedbackModal.spec.tsx @@ -131,10 +131,7 @@ describe('FeedbackModal functionnalities', () => { ], } - wrapper - .find('div.fb-selector-item') - .first() - .simulate('click') + wrapper.find('div.fb-selector-item').first().simulate('click') wrapper.find('#idFeedbackDescription').simulate('change', { target: { value: 'La description', @@ -169,10 +166,7 @@ describe('FeedbackModal functionnalities', () => { value: 'La description', }, }) - wrapper - .find('.modal-paper-close-button') - .first() - .simulate('click') + wrapper.find('.modal-paper-close-button').first().simulate('click') expect(handleFeedbackModalClose).toHaveBeenCalledTimes(1) setTimeout(() => { expect(wrapper.find('#idFeedbackDescription').prop('value')).toBe('') @@ -197,11 +191,6 @@ describe('FeedbackModal functionnalities', () => { const readAsDataURLSpy = jest.spyOn(FileReader.prototype, 'readAsDataURL') wrapper.find('#folder').simulate('change', { target: { files: [file] } }) expect(readAsDataURLSpy).toBeCalledWith(file) - expect( - wrapper - .find('.removeUploaded') - .first() - .simulate('click') - ) + expect(wrapper.find('.removeUploaded').first().simulate('click')) }) }) diff --git a/src/components/FluidChart/FluidChart.tsx b/src/components/FluidChart/FluidChart.tsx index 161f7e01e..e24c47f47 100644 --- a/src/components/FluidChart/FluidChart.tsx +++ b/src/components/FluidChart/FluidChart.tsx @@ -63,9 +63,8 @@ const FluidChart: React.FC<FluidChartProps> = ({ ) } if (currentTimeStep === TimeStep.HALF_AN_HOUR && activateHalfHourLoad) { - isEnedisConsentValid = await consumptionService.checkEnedisHalHourConsent( - selectedDate - ) + isEnedisConsentValid = + await consumptionService.checkEnedisHalHourConsent(selectedDate) } if (subscribed) { if (!activateHalfHourLoad) { diff --git a/src/components/GCU/GCUContent.spec.tsx b/src/components/GCU/GCUContent.spec.tsx index 70d90112c..7b79865de 100644 --- a/src/components/GCU/GCUContent.spec.tsx +++ b/src/components/GCU/GCUContent.spec.tsx @@ -8,7 +8,7 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => { return { t: (str: string) => { if (str === 'gcu.content.part9_4_content') { - return "test <a href=\"link.com\">link</a>fin test" + return 'test <a href="link.com">link</a>fin test' } else { return str } diff --git a/src/components/Header/CozyBar.spec.tsx b/src/components/Header/CozyBar.spec.tsx index 2e612a093..16c35eb66 100644 --- a/src/components/Header/CozyBar.spec.tsx +++ b/src/components/Header/CozyBar.spec.tsx @@ -55,11 +55,7 @@ describe('CozyBar component', () => { </Provider> ) expect(wrapper.find('BarLeft')).toHaveLength(1) - wrapper - .find('BarLeft') - .find('.cv-button') - .first() - .simulate('click') + wrapper.find('BarLeft').find('.cv-button').first().simulate('click') expect(mockGoBack).toHaveBeenCalled() }) @@ -76,11 +72,7 @@ describe('CozyBar component', () => { </Provider> ) const updateModalSpy = jest.spyOn(ModalAction, 'updateModalIsFeedbacksOpen') - wrapper - .find('BarRight') - .find('.cv-button') - .first() - .simulate('click') + wrapper.find('BarRight').find('.cv-button').first().simulate('click') expect(updateModalSpy).toHaveBeenCalledWith(true) }) diff --git a/src/components/Header/Header.spec.tsx b/src/components/Header/Header.spec.tsx index 5e59a3993..3aab69e60 100644 --- a/src/components/Header/Header.spec.tsx +++ b/src/components/Header/Header.spec.tsx @@ -55,12 +55,7 @@ describe('Header component', () => { <Header textKey={'KEY'} setHeaderHeight={mocksetHeaderHeight} /> </Provider> ) - expect( - wrapper - .find('.header-text') - .first() - .text() - ).toEqual('KEY') + expect(wrapper.find('.header-text').first().text()).toEqual('KEY') }) it('should display title and back button when desktopTitle key provided and displayBackArrow is true', () => { @@ -78,17 +73,9 @@ describe('Header component', () => { /> </Provider> ) + expect(wrapper.find('.header-text-desktop').first().text()).toEqual('KEY') expect( - wrapper - .find('.header-text-desktop') - .first() - .text() - ).toEqual('KEY') - expect( - wrapper - .find(IconButton) - .find('.header-back-button') - .first() + wrapper.find(IconButton).find('.header-back-button').first() ).toHaveLength(1) }) diff --git a/src/components/Home/ConsumptionView.tsx b/src/components/Home/ConsumptionView.tsx index 9902d21d2..ac64219d3 100644 --- a/src/components/Home/ConsumptionView.tsx +++ b/src/components/Home/ConsumptionView.tsx @@ -49,9 +49,8 @@ const ConsumptionView: React.FC<ConsumptionViewProps> = ({ const [headerHeight, setHeaderHeight] = useState<number>(0) const [active, setActive] = useState<boolean>(false) - const [openExpiredConsentModal, setopenExpiredConsentModal] = useState< - boolean - >(true) + const [openExpiredConsentModal, setopenExpiredConsentModal] = + useState<boolean>(true) const [consentExpiredFluids, setconsentExpiredFluids] = useState<FluidType[]>( [] ) @@ -59,10 +58,9 @@ const ConsumptionView: React.FC<ConsumptionViewProps> = ({ const updatekey = fluidType !== FluidType.MULTIFLUID && fluidStatus[fluidType].lastDataDate - ? `${fluidStatus[ - fluidType - ].lastDataDate!.toLocaleString()} + ${fluidStatus[fluidType].status + - fluidType}` + ? `${fluidStatus[fluidType].lastDataDate!.toLocaleString()} + ${ + fluidStatus[fluidType].status + fluidType + }` : '' const lastDataDateKey = fluidType !== FluidType.MULTIFLUID && fluidStatus[fluidType].lastDataDate diff --git a/src/components/Home/FluidButton.tsx b/src/components/Home/FluidButton.tsx index 39cae3cf2..c0e14b19c 100644 --- a/src/components/Home/FluidButton.tsx +++ b/src/components/Home/FluidButton.tsx @@ -115,9 +115,9 @@ const FluidButton: React.FC<FluidButtonProps> = ({ ) )} <div - className={`fluid-title ${FluidType[ - fluidType - ].toLowerCase()} ${isActive && 'active'} text-14-normal`} + className={`fluid-title ${FluidType[fluidType].toLowerCase()} ${ + isActive && 'active' + } text-14-normal`} > {t('FLUID.' + FluidType[fluidType] + '.LABEL')} </div> diff --git a/src/components/Konnector/KonnectorViewerCard.tsx b/src/components/Konnector/KonnectorViewerCard.tsx index b23c5f5fd..c3f19abf0 100644 --- a/src/components/Konnector/KonnectorViewerCard.tsx +++ b/src/components/Konnector/KonnectorViewerCard.tsx @@ -102,9 +102,10 @@ const KonnectorViewerCard: React.FC<KonnectorViewerCardProps> = ({ (state: AppStore) => state.ecolyo.challenge ) const fluidService = useMemo(() => new FluidService(client), [client]) - const partnersInfoService = useMemo(() => new PartnersInfoService(client), [ - client, - ]) + const partnersInfoService = useMemo( + () => new PartnersInfoService(client), + [client] + ) /* eslint-disable @typescript-eslint/no-non-null-assertion */ const lastDataDate = @@ -124,7 +125,8 @@ const KonnectorViewerCard: React.FC<KonnectorViewerCardProps> = ({ const updateGlobalFluidStatus = useCallback(async (): Promise< FluidStatus[] > => { - const _updatedFluidStatus: FluidStatus[] = await fluidService.getFluidStatus() + const _updatedFluidStatus: FluidStatus[] = + await fluidService.getFluidStatus() setUpdatedFluidStatus(_updatedFluidStatus) const refDate: DateTime = DateTime.fromISO('0001-01-01') let _lastDataDate: DateTime | null = DateTime.fromISO('0001-01-01') @@ -147,10 +149,8 @@ const KonnectorViewerCard: React.FC<KonnectorViewerCardProps> = ({ currentChallenge.duel.state === UserDuelState.ONGOING ) { const challengeService = new ChallengeService(client) - const { - updatedUserChallenge, - dataloads, - } = await challengeService.initChallengeDuelProgress(currentChallenge) + const { updatedUserChallenge, dataloads } = + await challengeService.initChallengeDuelProgress(currentChallenge) dispatch(setChallengeConsumption(updatedUserChallenge, dataloads)) // Check is duel is done and display notification const { isDone } = await challengeService.isChallengeDone( @@ -165,12 +165,10 @@ const KonnectorViewerCard: React.FC<KonnectorViewerCardProps> = ({ await refreshChallengeState() const _updatedFluidStatus = await updateGlobalFluidStatus() if (_updatedFluidStatus.length > 0) { - const partnersInfo: - | PartnersInfo - | undefined = await partnersInfoService.getPartnersInfo() - const updatedFluidStatus: FluidStatus[] = await fluidService.getFluidStatus( - partnersInfo - ) + const partnersInfo: PartnersInfo | undefined = + await partnersInfoService.getPartnersInfo() + const updatedFluidStatus: FluidStatus[] = + await fluidService.getFluidStatus(partnersInfo) dispatch(setFluidStatus(updatedFluidStatus)) } setActive(false) @@ -206,12 +204,10 @@ const KonnectorViewerCard: React.FC<KonnectorViewerCardProps> = ({ ) } if (updatedFluidStatus.length > 0) { - const partnersInfo: - | PartnersInfo - | undefined = await partnersInfoService.getPartnersInfo() - const _updatedFluidStatus: FluidStatus[] = await fluidService.getFluidStatus( - partnersInfo - ) + const partnersInfo: PartnersInfo | undefined = + await partnersInfoService.getPartnersInfo() + const _updatedFluidStatus: FluidStatus[] = + await fluidService.getFluidStatus(partnersInfo) dispatch(setFluidStatus(_updatedFluidStatus)) } } diff --git a/src/components/Konnector/KonnectorViewerList.spec.tsx b/src/components/Konnector/KonnectorViewerList.spec.tsx index c830ad75d..b87e6632f 100644 --- a/src/components/Konnector/KonnectorViewerList.spec.tsx +++ b/src/components/Konnector/KonnectorViewerList.spec.tsx @@ -52,10 +52,7 @@ describe('KonnectorViewerList component', () => { <KonnectorViewerList /> </Provider> ) - wrapper - .find('.connection-card') - .first() - .simulate('click') + wrapper.find('.connection-card').first().simulate('click') expect(mockHistoryPush).toHaveBeenCalled() }) }) diff --git a/src/components/Navbar/Navbar.spec.tsx b/src/components/Navbar/Navbar.spec.tsx index 441ab3945..07be998ff 100644 --- a/src/components/Navbar/Navbar.spec.tsx +++ b/src/components/Navbar/Navbar.spec.tsx @@ -54,18 +54,8 @@ describe('Navbar component', () => { </BrowserRouter> </Provider> ) - expect( - wrapper - .find('.nb-notif') - .first() - .text() - ).toEqual('1') - expect( - wrapper - .find('.nb-notif') - .last() - .text() - ).toEqual('1') + expect(wrapper.find('.nb-notif').first().text()).toEqual('1') + expect(wrapper.find('.nb-notif').last().text()).toEqual('1') }) it('should be rendered correctly without notifications', () => { diff --git a/src/components/Onboarding/WelcomeModal.spec.tsx b/src/components/Onboarding/WelcomeModal.spec.tsx index 9be659c49..9c46bca76 100644 --- a/src/components/Onboarding/WelcomeModal.spec.tsx +++ b/src/components/Onboarding/WelcomeModal.spec.tsx @@ -108,10 +108,7 @@ describe('WelcomeModal component', () => { <WelcomeModal open={true} /> </Provider> ) - component - .find(Button) - .first() - .simulate('click') + component.find(Button).first().simulate('click') expect(mockSendMail).toBeCalled() expect(updateProfileSpy).toHaveBeenCalledWith({ isFirstConnection: false, @@ -132,10 +129,7 @@ describe('WelcomeModal component', () => { <WelcomeModal open={true} /> </Provider> ) - component - .find(IconButton) - .first() - .simulate('click') + component.find(IconButton).first().simulate('click') expect(mockSendMail).toBeCalled() expect(updateProfileSpy).toHaveBeenCalledWith({ isFirstConnection: false, diff --git a/src/components/Options/ProfileTypeOptions.spec.tsx b/src/components/Options/ProfileTypeOptions.spec.tsx index 6b3690ace..e9e76356b 100644 --- a/src/components/Options/ProfileTypeOptions.spec.tsx +++ b/src/components/Options/ProfileTypeOptions.spec.tsx @@ -52,10 +52,7 @@ describe('ProfileTypeOptions component', () => { expect(wrapper.find(StyledCard).exists()).toBeTruthy() expect(wrapper.find(StyledIcon).exists()).toBeTruthy() expect(wrapper.find(profileIcon)).toBeTruthy() - wrapper - .find('.profile-link') - .first() - .simulate('click') + wrapper.find('.profile-link').first().simulate('click') }) it('should be rendered when user complete profile type form', () => { const profileTypeCompleted = { ...profileData } diff --git a/src/components/Options/ProfileTypeOptions.tsx b/src/components/Options/ProfileTypeOptions.tsx index dea8c9317..639467f22 100644 --- a/src/components/Options/ProfileTypeOptions.tsx +++ b/src/components/Options/ProfileTypeOptions.tsx @@ -89,8 +89,9 @@ const ProfileTypeOptions: React.FC = () => { {profileType.constructionYear && ( <div className="value"> {t( - `profile_type.construction_year.${'text_' + - profileType.constructionYear}` + `profile_type.construction_year.${ + 'text_' + profileType.constructionYear + }` )} </div> )} @@ -128,8 +129,9 @@ const ProfileTypeOptions: React.FC = () => { {profileType.warmingFluid == null ? t('profile_type.warming_fluid.no_fluid_text') : t( - `profile_type.warming_fluid.${profileType.warmingFluid + - '_text'}` + `profile_type.warming_fluid.${ + profileType.warmingFluid + '_text' + }` )} </div> {(profileType.hasInstalledVentilation === @@ -171,8 +173,9 @@ const ProfileTypeOptions: React.FC = () => { {profileType.warmingFluid !== null && profileType.heating === IndividualOrCollective.INDIVIDUAL ? t( - `profile_type.hot_water_fluid.${profileType.hotWaterFluid + - '_text'}` + `profile_type.hot_water_fluid.${ + profileType.hotWaterFluid + '_text' + }` ) : profileType.heating === IndividualOrCollective.INDIVIDUAL diff --git a/src/components/Options/ReportOptions.spec.tsx b/src/components/Options/ReportOptions.spec.tsx index fc6cac748..f97b6ddad 100644 --- a/src/components/Options/ReportOptions.spec.tsx +++ b/src/components/Options/ReportOptions.spec.tsx @@ -55,10 +55,7 @@ describe('ReportOptions component', () => { <ReportOptions /> </Provider> ) - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') expect(updateProfileSpy).toBeCalledTimes(1) expect(updateProfileSpy).toHaveBeenCalledWith({ sendAnalysisNotification: false, @@ -73,10 +70,7 @@ describe('ReportOptions component', () => { <ReportOptions /> </Provider> ) - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') expect(updateProfileSpy).toBeCalledTimes(1) expect(updateProfileSpy).toHaveBeenCalledWith({ sendAnalysisNotification: true, @@ -94,12 +88,7 @@ describe('ReportOptions component', () => { </Provider> ) expect(wrapper.find(StyledSwitch)).toHaveLength(1) - expect( - wrapper - .find(StyledSwitch) - .first() - .props().checked - ).toBeFalsy() + expect(wrapper.find(StyledSwitch).first().props().checked).toBeFalsy() }) it('should update the profile with sendConsumptionAlert to true', () => { diff --git a/src/components/Options/ReportOptions.tsx b/src/components/Options/ReportOptions.tsx index 5a74cb990..0a5778ad3 100644 --- a/src/components/Options/ReportOptions.tsx +++ b/src/components/Options/ReportOptions.tsx @@ -56,9 +56,7 @@ const ReportOptions: React.FC = () => { let subscribed = true async function getMaxLoadData() { const timePeriod: TimePeriod = { - startDate: DateTime.now() - .minus({ month: 6 }) - .startOf('month'), + startDate: DateTime.now().minus({ month: 6 }).startOf('month'), endDate: DateTime.now(), } const consumptionService = new ConsumptionDataManager(client) diff --git a/src/components/PartnerConnectionStepsModal/PartnerConnectionStepsModal.spec.tsx b/src/components/PartnerConnectionStepsModal/PartnerConnectionStepsModal.spec.tsx index 07dc5f128..c8b94ee62 100644 --- a/src/components/PartnerConnectionStepsModal/PartnerConnectionStepsModal.spec.tsx +++ b/src/components/PartnerConnectionStepsModal/PartnerConnectionStepsModal.spec.tsx @@ -52,10 +52,7 @@ describe('PartnerConnectionStepsModal component', () => { handleEndSteps={mockHandleEndSteps} /> ) - component - .find(IconButton) - .first() - .simulate('click') + component.find(IconButton).first().simulate('click') expect(mockHandleCloseClick).toBeCalled() }) @@ -69,10 +66,7 @@ describe('PartnerConnectionStepsModal component', () => { handleEndSteps={mockHandleEndSteps} /> ) - component - .find(Button) - .last() - .simulate('click') + component.find(Button).last().simulate('click') const step: string = component .find('.partners-connection-step-progress') .first() @@ -90,23 +84,14 @@ describe('PartnerConnectionStepsModal component', () => { handleEndSteps={mockHandleEndSteps} /> ) - component - .find(Button) - .last() - .simulate('click') - component - .find(Button) - .last() - .simulate('click') + component.find(Button).last().simulate('click') + component.find(Button).last().simulate('click') const step: string = component .find('.partners-connection-step-progress') .first() .text() expect(step).toEqual('3 / 3') - component - .find(Button) - .last() - .simulate('click') + component.find(Button).last().simulate('click') expect(mockHandleEndSteps).toBeCalled() }) }) diff --git a/src/components/PartnerConnectionStepsModal/PartnerConnectionStepsModal.tsx b/src/components/PartnerConnectionStepsModal/PartnerConnectionStepsModal.tsx index 70988ddd0..a5f41c520 100644 --- a/src/components/PartnerConnectionStepsModal/PartnerConnectionStepsModal.tsx +++ b/src/components/PartnerConnectionStepsModal/PartnerConnectionStepsModal.tsx @@ -65,8 +65,9 @@ const PartnerConnectionStepsModal = ({ <Icon icon={CloseIcon} size={16} /> </IconButton> <div className="partners-connection-step-content"> - <div className="partners-connection-step-progress">{`${stepIndex + - 1} / ${steps.length}`}</div> + <div className="partners-connection-step-progress">{`${ + stepIndex + 1 + } / ${steps.length}`}</div> <StepDetail step={steps[stepIndex]} /> </div> <div className="partners-connection-step-navigation"> diff --git a/src/components/PerformanceIndicator/PerformanceIndicatorContent.tsx b/src/components/PerformanceIndicator/PerformanceIndicatorContent.tsx index 443800160..e9df3d07b 100644 --- a/src/components/PerformanceIndicator/PerformanceIndicatorContent.tsx +++ b/src/components/PerformanceIndicator/PerformanceIndicatorContent.tsx @@ -24,7 +24,9 @@ interface PerformanceIndicatorContentProps { analysisDate?: DateTime } -const PerformanceIndicatorContent: React.FC<PerformanceIndicatorContentProps> = ({ +const PerformanceIndicatorContent: React.FC< + PerformanceIndicatorContentProps +> = ({ performanceIndicator, fluidLackOfData = [], analysisDate, diff --git a/src/components/ProfileType/FormNavigation.spec.tsx b/src/components/ProfileType/FormNavigation.spec.tsx index 01d0dc8bb..fbb34ae60 100644 --- a/src/components/ProfileType/FormNavigation.spec.tsx +++ b/src/components/ProfileType/FormNavigation.spec.tsx @@ -39,14 +39,8 @@ describe('FormNavigation component', () => { /> </Provider> ) - wrapper - .find(Button) - .at(0) - .simulate('click') - wrapper - .find(Button) - .at(1) - .simulate('click') + wrapper.find(Button).at(0).simulate('click') + wrapper.find(Button).at(1).simulate('click') expect(wrapper.find('profile-navigation')).toBeTruthy() expect(wrapper.find(Button)).toBeTruthy() expect(mockhandlePrevious.mock.calls.length).toEqual(1) diff --git a/src/components/ProfileType/ProfileTypeFinished.spec.tsx b/src/components/ProfileType/ProfileTypeFinished.spec.tsx index 60f540a18..3f4955141 100644 --- a/src/components/ProfileType/ProfileTypeFinished.spec.tsx +++ b/src/components/ProfileType/ProfileTypeFinished.spec.tsx @@ -57,10 +57,7 @@ describe('ProfileTypeFinished component', () => { <ProfileTypeFinished profileType={mockProfileType} /> </Provider> ) - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') expect(mockHistoryPush).toHaveBeenCalledWith('/ecogesture-selection') }) }) diff --git a/src/components/ProfileType/ProfileTypeFinished.tsx b/src/components/ProfileType/ProfileTypeFinished.tsx index be6a82b0c..24832b694 100644 --- a/src/components/ProfileType/ProfileTypeFinished.tsx +++ b/src/components/ProfileType/ProfileTypeFinished.tsx @@ -49,9 +49,8 @@ const ProfileTypeFinished: React.FC<ProfileTypeFinishedProps> = ({ useEffect(() => { async function checkForExistingProfileType() { - const consistentProfileType: ProfileType = ProfileTypeService.checkConsistency( - profileType - ) + const consistentProfileType: ProfileType = + ProfileTypeService.checkConsistency(profileType) const chosenPeriod: TimePeriod = { startDate: profileType.updateDate.setZone('utc', { keepLocalTime: true, @@ -61,9 +60,8 @@ const ProfileTypeFinished: React.FC<ProfileTypeFinishedProps> = ({ }), } const profileTypeEntityService = new ProfileTypeEntityService(client) - const myProfileTypes: - | ProfileType[] - | null = await profileTypeEntityService.getAllProfileTypes(chosenPeriod) + const myProfileTypes: ProfileType[] | null = + await profileTypeEntityService.getAllProfileTypes(chosenPeriod) if (myProfileTypes !== null) { const destroyPT = await profileTypeEntityService.deleteProfileTypes( myProfileTypes diff --git a/src/components/ProfileType/ProfileTypeFormDateSelection.tsx b/src/components/ProfileType/ProfileTypeFormDateSelection.tsx index 05b3b77af..9b85807d0 100644 --- a/src/components/ProfileType/ProfileTypeFormDateSelection.tsx +++ b/src/components/ProfileType/ProfileTypeFormDateSelection.tsx @@ -29,7 +29,9 @@ interface SelectionMonth { value: string } -const ProfileTypeFormDateSelection: React.FC<ProfileTypeFormDateSelectionProps> = ({ +const ProfileTypeFormDateSelection: React.FC< + ProfileTypeFormDateSelectionProps +> = ({ step, viewedStep, profileType, @@ -41,9 +43,7 @@ const ProfileTypeFormDateSelection: React.FC<ProfileTypeFormDateSelectionProps> const { t } = useI18n() const [selectedMonth, setSelectedMonth] = useState<any>({ label: DateTime.now().toLocaleString({ month: 'long' }), - value: DateTime.now() - .month.toString() - .padStart(2, '0'), // Date.getMonth starts at 0 + value: DateTime.now().month.toString().padStart(2, '0'), // Date.getMonth starts at 0 }) const [selectedYear, setSelectedYear] = useState<number>(DateTime.now().year) const [answer, setAnswer] = useState<ProfileTypeAnswerChoices>('') diff --git a/src/components/ProfileType/ProfileTypeFormMultiChoice.tsx b/src/components/ProfileType/ProfileTypeFormMultiChoice.tsx index 93b0da660..57ea92b70 100644 --- a/src/components/ProfileType/ProfileTypeFormMultiChoice.tsx +++ b/src/components/ProfileType/ProfileTypeFormMultiChoice.tsx @@ -42,11 +42,11 @@ const ProfileTypeFormMultiChoice: React.FC<ProfileTypeFormMultiChoiceProps> = ({ if (value === 'none' && !tempAnswer.includes(value)) { tempAnswer = [value] } else if (tempAnswer.includes(value)) { - remove(tempAnswer, function(n) { + remove(tempAnswer, function (n) { return n === 'none' || n === value }) } else { - remove(tempAnswer, function(n) { + remove(tempAnswer, function (n) { return n === 'none' }) tempAnswer.push(value) diff --git a/src/components/ProfileType/ProfileTypeFormNumberSelection.tsx b/src/components/ProfileType/ProfileTypeFormNumberSelection.tsx index 9f8ffeabe..2979bb172 100644 --- a/src/components/ProfileType/ProfileTypeFormNumberSelection.tsx +++ b/src/components/ProfileType/ProfileTypeFormNumberSelection.tsx @@ -20,7 +20,9 @@ interface ProfileTypeFormNumberSelectionProps { isProfileTypeComplete: boolean } -const ProfileTypeFormNumberSelection: React.FC<ProfileTypeFormNumberSelectionProps> = ({ +const ProfileTypeFormNumberSelection: React.FC< + ProfileTypeFormNumberSelectionProps +> = ({ step, viewedStep, profileType, diff --git a/src/components/ProfileType/ProfileTypeFormSingleChoice.tsx b/src/components/ProfileType/ProfileTypeFormSingleChoice.tsx index 0c6265ad5..d39461b16 100644 --- a/src/components/ProfileType/ProfileTypeFormSingleChoice.tsx +++ b/src/components/ProfileType/ProfileTypeFormSingleChoice.tsx @@ -21,7 +21,9 @@ interface ProfileTypeFormSingleChoiceProps { isProfileTypeComplete: boolean } -const ProfileTypeFormSingleChoice: React.FC<ProfileTypeFormSingleChoiceProps> = ({ +const ProfileTypeFormSingleChoice: React.FC< + ProfileTypeFormSingleChoiceProps +> = ({ step, viewedStep, profileType, diff --git a/src/components/ProfileType/ProfileTypeView.tsx b/src/components/ProfileType/ProfileTypeView.tsx index 7a64b883e..49de9edb4 100644 --- a/src/components/ProfileType/ProfileTypeView.tsx +++ b/src/components/ProfileType/ProfileTypeView.tsx @@ -97,10 +97,11 @@ const ProfileTypeView: React.FC = () => { ...profileType, }) } - const nextStep: ProfileTypeStepForm = profileTypeFormService.getNextFormStep( - step, - !profile.isProfileTypeCompleted - ) + const nextStep: ProfileTypeStepForm = + profileTypeFormService.getNextFormStep( + step, + !profile.isProfileTypeCompleted + ) setIsLoading(true) if (nextStep > viewedStep) { setViewedStep(nextStep) @@ -120,9 +121,8 @@ const ProfileTypeView: React.FC = () => { (_profileType: ProfileType) => { setProfileType(_profileType) const profileTypeFormService = new ProfileTypeFormService(_profileType) - const previousStep: ProfileTypeStepForm = profileTypeFormService.getPreviousFormStep( - step - ) + const previousStep: ProfileTypeStepForm = + profileTypeFormService.getPreviousFormStep(step) setIsLoading(true) setStep(previousStep) }, @@ -206,9 +206,8 @@ const ProfileTypeView: React.FC = () => { if (profile.isProfileTypeCompleted) { setProfileType(curProfileType) } - const _answerType: ProfileTypeAnswer = ProfileTypeFormService.getAnswerForStep( - step - ) + const _answerType: ProfileTypeAnswer = + ProfileTypeFormService.getAnswerForStep(step) setAnswerType(_answerType) setIsLoading(false) }, [step, profile, curProfileType]) diff --git a/src/components/Quiz/QuizBegin.spec.tsx b/src/components/Quiz/QuizBegin.spec.tsx index e48e0119a..87db1ca28 100644 --- a/src/components/Quiz/QuizBegin.spec.tsx +++ b/src/components/Quiz/QuizBegin.spec.tsx @@ -43,10 +43,7 @@ describe('QuizBegin component', () => { </Provider> ) expect(wrapper.find(StyledIcon).exists()).toBeTruthy() - wrapper - .find('.button-start') - .find(Button) - .simulate('click') + wrapper.find('.button-start').find(Button).simulate('click') expect(mockUserChallengeUpdateFlag).toHaveBeenCalledWith( userChallengeData[0], UserChallengeUpdateFlag.QUIZ_START diff --git a/src/components/Quiz/QuizBegin.tsx b/src/components/Quiz/QuizBegin.tsx index ef2fe161e..c543f5809 100644 --- a/src/components/Quiz/QuizBegin.tsx +++ b/src/components/Quiz/QuizBegin.tsx @@ -24,10 +24,11 @@ const QuizBegin: React.FC<QuizBeginProps> = ({ const dispatch = useDispatch() const launchQuiz = async () => { const challengeService: ChallengeService = new ChallengeService(client) - const userChallengeUpdated: UserChallenge = await challengeService.updateUserChallenge( - userChallenge, - UserChallengeUpdateFlag.QUIZ_START - ) + const userChallengeUpdated: UserChallenge = + await challengeService.updateUserChallenge( + userChallenge, + UserChallengeUpdateFlag.QUIZ_START + ) dispatch(updateUserChallengeList(userChallengeUpdated)) } diff --git a/src/components/Quiz/QuizCustomQuestionContent.tsx b/src/components/Quiz/QuizCustomQuestionContent.tsx index 1f883ae3d..bd42f8cb1 100644 --- a/src/components/Quiz/QuizCustomQuestionContent.tsx +++ b/src/components/Quiz/QuizCustomQuestionContent.tsx @@ -54,11 +54,12 @@ const QuizCustomQuestionContent: React.FC<QuizCustomQuestionContent> = ({ userChallenge.quiz, result[0].isTrue ) - const userChallengeUpdated: UserChallenge = await challengeService.updateUserChallenge( - userChallenge, - UserChallengeUpdateFlag.QUIZ_UPDATE, - quizUpdated - ) + const userChallengeUpdated: UserChallenge = + await challengeService.updateUserChallenge( + userChallenge, + UserChallengeUpdateFlag.QUIZ_UPDATE, + quizUpdated + ) dispatch(updateUserChallengeList(userChallengeUpdated)) } } @@ -69,10 +70,11 @@ const QuizCustomQuestionContent: React.FC<QuizCustomQuestionContent> = ({ const finishQuiz = async () => { setOpenModal(false) - const userChallengeUpdated: UserChallenge = await challengeService.updateUserChallenge( - userChallenge, - UserChallengeUpdateFlag.QUIZ_DONE - ) + const userChallengeUpdated: UserChallenge = + await challengeService.updateUserChallenge( + userChallenge, + UserChallengeUpdateFlag.QUIZ_DONE + ) await UsageEventService.addEvent(client, { type: UsageEventType.QUIZ_END_EVENT, startDate: userChallenge.quiz.startDate, diff --git a/src/components/Quiz/QuizFinish.tsx b/src/components/Quiz/QuizFinish.tsx index b3dd91a16..7306c22ea 100644 --- a/src/components/Quiz/QuizFinish.tsx +++ b/src/components/Quiz/QuizFinish.tsx @@ -29,19 +29,21 @@ const QuizFinish: React.FC<QuizFinishProps> = ({ ) const retryQuiz = useCallback(async () => { - const userChallengeUpdated: UserChallenge = await challengeService.updateUserChallenge( - userChallenge, - UserChallengeUpdateFlag.QUIZ_RESET - ) + const userChallengeUpdated: UserChallenge = + await challengeService.updateUserChallenge( + userChallenge, + UserChallengeUpdateFlag.QUIZ_RESET + ) dispatch(updateUserChallengeList(userChallengeUpdated)) }, [dispatch, userChallenge, challengeService]) const goBack = async () => { - const userChallengeUpdated: UserChallenge = await challengeService.updateUserChallenge( - userChallenge, - UserChallengeUpdateFlag.QUIZ_UPDATE, - userChallenge.quiz - ) + const userChallengeUpdated: UserChallenge = + await challengeService.updateUserChallenge( + userChallenge, + UserChallengeUpdateFlag.QUIZ_UPDATE, + userChallenge.quiz + ) dispatch(updateUserChallengeList(userChallengeUpdated)) history.push('/challenges') } diff --git a/src/components/Quiz/QuizQuestion.tsx b/src/components/Quiz/QuizQuestion.tsx index bc1d6bed8..689dfb025 100644 --- a/src/components/Quiz/QuizQuestion.tsx +++ b/src/components/Quiz/QuizQuestion.tsx @@ -23,9 +23,8 @@ const QuizQuestion: React.FC<QuizQuestion> = ({ const [isCustomQuest, setIsCustomQuest] = useState<boolean>( !questionsIsLocked ) - const [customQuestionLoading, setCustomQuestionLoading] = useState<boolean>( - false - ) + const [customQuestionLoading, setCustomQuestionLoading] = + useState<boolean>(false) const client: Client = useClient() const { fluidTypes } = useSelector((state: AppStore) => state.ecolyo.global) const history = useHistory() @@ -38,10 +37,11 @@ const QuizQuestion: React.FC<QuizQuestion> = ({ let subscribed = true async function loadCustomQuestion() { const quizService: QuizService = new QuizService(client) - const customQuestion: QuestionEntity = await quizService.getCustomQuestion( - userChallenge.quiz.customQuestion, - fluidTypes - ) + const customQuestion: QuestionEntity = + await quizService.getCustomQuestion( + userChallenge.quiz.customQuestion, + fluidTypes + ) if (subscribed) { setQuestion(customQuestion) setCustomQuestionLoading(false) diff --git a/src/components/Quiz/QuizQuestionContent.spec.tsx b/src/components/Quiz/QuizQuestionContent.spec.tsx index f443f7554..ef3ebff54 100644 --- a/src/components/Quiz/QuizQuestionContent.spec.tsx +++ b/src/components/Quiz/QuizQuestionContent.spec.tsx @@ -84,10 +84,7 @@ describe('QuizQuestionContent component', () => { </Provider> ) - wrapper - .find('.btn-back') - .first() - .simulate('click') + wrapper.find('.btn-back').first().simulate('click') expect(mockHistoryPush).toHaveBeenCalledWith('/challenges') }) }) diff --git a/src/components/Quiz/QuizQuestionContent.tsx b/src/components/Quiz/QuizQuestionContent.tsx index c9e2e7ead..cbd096f86 100644 --- a/src/components/Quiz/QuizQuestionContent.tsx +++ b/src/components/Quiz/QuizQuestionContent.tsx @@ -31,9 +31,8 @@ const QuizQuestionContent: React.FC<QuizQuestionContent> = ({ const [userChoice, setUserChoice] = useState<string>('') const [openModal, setOpenModal] = useState<boolean>(false) const [answerIndex, setAnswerIndex] = useState<number>(0) - const [questionIndex, setQuestionIndex] = useState<number>( - questionIndexLocked - ) + const [questionIndex, setQuestionIndex] = + useState<number>(questionIndexLocked) const client: Client = useClient() const dispatch = useDispatch() @@ -55,11 +54,12 @@ const QuizQuestionContent: React.FC<QuizQuestionContent> = ({ result[0].isTrue, questionIndex ) - const userChallengeUpdated: UserChallenge = await challengeService.updateUserChallenge( - userChallenge, - UserChallengeUpdateFlag.QUIZ_UPDATE, - quizUpdated - ) + const userChallengeUpdated: UserChallenge = + await challengeService.updateUserChallenge( + userChallenge, + UserChallengeUpdateFlag.QUIZ_UPDATE, + quizUpdated + ) dispatch(updateUserChallengeList(userChallengeUpdated)) } diff --git a/src/components/Routes/Routes.tsx b/src/components/Routes/Routes.tsx index 2ef690160..0df72fa29 100644 --- a/src/components/Routes/Routes.tsx +++ b/src/components/Routes/Routes.tsx @@ -14,21 +14,21 @@ import EcogestureSelection from 'components/EcogestureSelection/EcogestureSelect const ConsumptionView = lazy(() => import('components/Home/ConsumptionView')) -const EcogestureView = lazy(() => - import('components/Ecogesture/EcogestureView') +const EcogestureView = lazy( + () => import('components/Ecogesture/EcogestureView') ) -const SingleEcogesture = lazy(() => - import('components/Ecogesture/SingleEcogesture') +const SingleEcogesture = lazy( + () => import('components/Ecogesture/SingleEcogesture') ) const OptionsView = lazy(() => import('components/Options/OptionsView')) const FAQView = lazy(() => import('components/FAQ/FAQView')) -const LegalNoticeView = lazy(() => - import('components/LegalNotice/LegalNoticeView') +const LegalNoticeView = lazy( + () => import('components/LegalNotice/LegalNoticeView') ) const GCUView = lazy(() => import('components/GCU/GCUView')) const AnalysisView = lazy(() => import('components/Analysis/AnalysisView')) -const ProfileTypeView = lazy(() => - import('components/ProfileType/ProfileTypeView') +const ProfileTypeView = lazy( + () => import('components/ProfileType/ProfileTypeView') ) interface RouteProps { diff --git a/src/components/Splash/SplashRoot.tsx b/src/components/Splash/SplashRoot.tsx index 8a7c4db88..9beb6cac6 100644 --- a/src/components/Splash/SplashRoot.tsx +++ b/src/components/Splash/SplashRoot.tsx @@ -125,7 +125,8 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => { ) //init Terms - const termsStatus: TermsStatus = await initializationService.initConsent() + const termsStatus: TermsStatus = + await initializationService.initConsent() if (subscribed) dispatch(updateTermValidation(termsStatus)) // Init fluidPrices @@ -134,7 +135,8 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => { // Init profile and update ecogestures, challenges, analysis const profile = await initializationService.initProfile() const profileType = await initializationService.initProfileType() - const profileEcogesture = await initializationService.initProfileEcogesture() + const profileEcogesture = + await initializationService.initProfileEcogesture() if (subscribed && profile) { setValidExploration(UserExplorationID.EXPLORATION007) const [ @@ -184,9 +186,8 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => { } } // Init Challenge - const userChallengeList = await initializationService.initUserChallenges( - fluidStatus - ) + const userChallengeList = + await initializationService.initUserChallenges(fluidStatus) if (subscribed) { dispatch(setUserChallengeList(userChallengeList)) const filteredCurrentOngoingChallenge = userChallengeList.filter( @@ -207,9 +208,10 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => { UserActionState.ONGOING ) { const actionService = new ActionService(client) - const updatedUserChallenge: UserChallenge | null = await actionService.isActionDone( - filteredCurrentOngoingChallenge[0] - ) + const updatedUserChallenge: UserChallenge | null = + await actionService.isActionDone( + filteredCurrentOngoingChallenge[0] + ) if (updatedUserChallenge) { dispatch(updateUserChallengeList(updatedUserChallenge)) } @@ -229,12 +231,10 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => { filteredCurrentDuelChallenge[0] && filteredCurrentDuelChallenge[0].duel.state === UserDuelState.ONGOING ) { - const { - updatedUserChallenge, - dataloads, - } = await initializationService.initDuelProgress( - filteredCurrentDuelChallenge[0] - ) + const { updatedUserChallenge, dataloads } = + await initializationService.initDuelProgress( + filteredCurrentDuelChallenge[0] + ) if (subscribed) { dispatch(setChallengeConsumption(updatedUserChallenge, dataloads)) // Check is duel is done and display notification @@ -251,18 +251,18 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => { await UsageEventService.addEvent(client, { type: UsageEventType.CONNECTION_EVENT, result: profile.isFirstConnection ? 'firstConnection' : undefined, - context: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( - navigator.userAgent - ) - ? 'mobile' - : 'desktop', + context: + /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( + navigator.userAgent + ) + ? 'mobile' + : 'desktop', }) } // Check partnersInfo from backoffice - const partnersInfo: - | PartnersInfo - | undefined = await partnersInfoService.getPartnersInfo() + const partnersInfo: PartnersInfo | undefined = + await partnersInfoService.getPartnersInfo() // Get last partnersIssueDate const today = DateTime.local() @@ -275,9 +275,8 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => { // If notification is activated and konnector is connected, set FluidStatus to PARTNER_ISSUE if (partnersInfo && partnersInfo.notification_activated) { const fluidService = new FluidService(client) - const _updatedFluidStatus: FluidStatus[] = await fluidService.getFluidStatus( - partnersInfo - ) + const _updatedFluidStatus: FluidStatus[] = + await fluidService.getFluidStatus(partnersInfo) let isConcernedByPartnerIssue = false for (const fluid of _updatedFluidStatus) { if (fluid.status === FluidState.PARTNER_ISSUE) diff --git a/src/components/Splash/SplashScreenError.spec.tsx b/src/components/Splash/SplashScreenError.spec.tsx index 0ea4a2791..2d9af53b8 100644 --- a/src/components/Splash/SplashScreenError.spec.tsx +++ b/src/components/Splash/SplashScreenError.spec.tsx @@ -37,10 +37,7 @@ describe('SplashScreenError component', () => { const component = mount( <SplashScreenError error={InitStepsErrors.CONSENT_ERROR} /> ) - component - .find(Button) - .first() - .simulate('click') + component.find(Button).first().simulate('click') expect(window.location.reload).toHaveBeenCalled() }) }) diff --git a/src/components/Terms/TermsView.spec.tsx b/src/components/Terms/TermsView.spec.tsx index 8aa6a6651..d3bcf1fa2 100644 --- a/src/components/Terms/TermsView.spec.tsx +++ b/src/components/Terms/TermsView.spec.tsx @@ -60,32 +60,14 @@ describe('TermsView component', () => { .find('input') .at(0) .simulate('change', { target: { checked: true } }) - expect( - wrapper - .find('input') - .at(0) - .props().checked - ).toEqual(true) + expect(wrapper.find('input').at(0).props().checked).toEqual(true) wrapper .find('input') .at(1) .simulate('change', { target: { checked: true } }) - expect( - wrapper - .find('input') - .at(1) - .props().checked - ).toEqual(true) - expect( - wrapper - .find(Button) - .first() - .hasClass('disabled') - ).toBeFalsy() - wrapper - .find(Button) - .first() - .simulate('click') + expect(wrapper.find('input').at(1).props().checked).toEqual(true) + expect(wrapper.find(Button).first().hasClass('disabled')).toBeFalsy() + wrapper.find(Button).first().simulate('click') expect(mockUseDispatch).toHaveBeenCalledTimes(3) }) it('should be rendered correctly', () => { @@ -115,17 +97,9 @@ describe('TermsView component', () => { <TermsView /> </Provider> ) - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') - expect( - wrapper - .find(Button) - .first() - .hasClass('disabled') - ).toBeTruthy() + expect(wrapper.find(Button).first().hasClass('disabled')).toBeTruthy() expect(mockUpdateProfile).toHaveBeenCalledTimes(0) }) }) diff --git a/src/components/Terms/TermsView.tsx b/src/components/Terms/TermsView.tsx index 6de439369..ad193b4bd 100644 --- a/src/components/Terms/TermsView.tsx +++ b/src/components/Terms/TermsView.tsx @@ -21,13 +21,11 @@ const TermsView: React.FC = () => { const dispatch = useDispatch() const history = useHistory() const [GCUValidation, setGCUValidation] = useState<boolean>(false) - const [dataConsentValidation, setDataConsentValidation] = useState<boolean>( - false - ) + const [dataConsentValidation, setDataConsentValidation] = + useState<boolean>(false) const [openCGUModal, setOpenCGUModal] = useState<boolean>(false) - const [openLegalNoticeModal, setOpenLegalNoticeModal] = useState<boolean>( - false - ) + const [openLegalNoticeModal, setOpenLegalNoticeModal] = + useState<boolean>(false) const { termsStatus } = useSelector((state: AppStore) => state.ecolyo.global) const toggleCGUModal = () => { diff --git a/src/components/TimeStepSelector/TimeStepSelector.spec.tsx b/src/components/TimeStepSelector/TimeStepSelector.spec.tsx index bba282e95..472e416ab 100644 --- a/src/components/TimeStepSelector/TimeStepSelector.spec.tsx +++ b/src/components/TimeStepSelector/TimeStepSelector.spec.tsx @@ -55,18 +55,8 @@ describe('TimeStepSelector component', () => { <TimeStepSelector fluidType={FluidType.WATER} /> </Provider> ) - expect( - wrapper - .find('.circle') - .at(3) - .exists() - ).toBeTruthy() - expect( - wrapper - .find('.circle') - .at(4) - .exists() - ).toBeFalsy() + expect(wrapper.find('.circle').at(3).exists()).toBeTruthy() + expect(wrapper.find('.circle').at(4).exists()).toBeFalsy() expect(wrapper).toMatchSnapshot() }) @@ -82,18 +72,8 @@ describe('TimeStepSelector component', () => { <TimeStepSelector fluidType={FluidType.ELECTRICITY} /> </Provider> ) - expect( - wrapper - .find('.circle') - .at(4) - .exists() - ).toBeTruthy() - expect( - wrapper - .find('.circle') - .at(5) - .exists() - ).toBeFalsy() + expect(wrapper.find('.circle').at(4).exists()).toBeTruthy() + expect(wrapper.find('.circle').at(5).exists()).toBeFalsy() }) it('should define next TimeStep and dispatch it', () => { @@ -108,10 +88,7 @@ describe('TimeStepSelector component', () => { <TimeStepSelector fluidType={FluidType.WATER} /> </Provider> ) - wrapper - .find('#day') - .first() - .simulate('click') + wrapper.find('#day').first().simulate('click') expect(setCurrentTimeStepSpy).toBeCalledTimes(1) expect(setCurrentTimeStepSpy).toHaveBeenCalledWith(TimeStep.DAY) expect(setCurrentIndexSpy).toBeCalledTimes(1) @@ -128,10 +105,7 @@ describe('TimeStepSelector component', () => { <TimeStepSelector fluidType={FluidType.WATER} /> </Provider> ) - wrapper - .find(Button) - .first() - .simulate('click') + wrapper.find(Button).first().simulate('click') expect(setCurrentTimeStepSpy).toBeCalledTimes(1) expect(setCurrentTimeStepSpy).toHaveBeenCalledWith(TimeStep.WEEK) expect(setCurrentIndexSpy).toBeCalledTimes(2) diff --git a/src/components/TimeStepSelector/TimeStepSelector.tsx b/src/components/TimeStepSelector/TimeStepSelector.tsx index 27db0e30d..75e9b9ef5 100644 --- a/src/components/TimeStepSelector/TimeStepSelector.tsx +++ b/src/components/TimeStepSelector/TimeStepSelector.tsx @@ -91,8 +91,9 @@ const TimeStepSelector: React.FC<TimeStepSelectorProps> = ({ </Button> <div className={'timestep-container'}> <ul - className={`timestep-bar ${fluidType === FluidType.ELECTRICITY && - 'elec-bar'}`} + className={`timestep-bar ${ + fluidType === FluidType.ELECTRICITY && 'elec-bar' + }`} > {timeStepArray.map((step, key) => { return ( diff --git a/src/components/TotalConsumption/TotalConsumption.spec.tsx b/src/components/TotalConsumption/TotalConsumption.spec.tsx index 2d0f7e449..b8f32bd0a 100644 --- a/src/components/TotalConsumption/TotalConsumption.spec.tsx +++ b/src/components/TotalConsumption/TotalConsumption.spec.tsx @@ -74,12 +74,7 @@ describe('TotalConsumption component', () => { component.update() }) - expect( - component - .find('.euro-value') - .first() - .text() - ).toEqual('22,77') + expect(component.find('.euro-value').first().text()).toEqual('22,77') }) it('should format multifluid value', async () => { const component = mount( @@ -95,12 +90,7 @@ describe('TotalConsumption component', () => { component.update() }) - expect( - component - .find('.euro-value') - .first() - .text() - ).toEqual('130,84') + expect(component.find('.euro-value').first().text()).toEqual('130,84') }) it('should display ----- when half an hour electricity data is not activated', async () => { const emptyData: Dataload[] = [] @@ -117,11 +107,6 @@ describe('TotalConsumption component', () => { component.update() }) - expect( - component - .find('.euro-value') - .first() - .text() - ).toEqual('-----') + expect(component.find('.euro-value').first().text()).toEqual('-----') }) }) diff --git a/src/migrations/migration.data.ts b/src/migrations/migration.data.ts index 2065ff866..d9ed8ddc3 100644 --- a/src/migrations/migration.data.ts +++ b/src/migrations/migration.data.ts @@ -36,7 +36,7 @@ export const migrations: Migration[] = [ releaseNotes: null, docTypes: PROFILETYPE_DOCTYPE, run: async (_client: Client, docs: any[]): Promise<ProfileType[]> => { - docs.sort(function(a, b) { + docs.sort(function (a, b) { const c = DateTime.fromISO(a.cozyMetadata.createdAt, { zone: 'utc', }) diff --git a/src/services/account.service.ts b/src/services/account.service.ts index 17f756396..9c86319a2 100644 --- a/src/services/account.service.ts +++ b/src/services/account.service.ts @@ -58,9 +58,8 @@ export default class AccountService { // eslint-disable-next-line @typescript-eslint/camelcase .where({ account_type: type }) // .indexFields(['account_type']) - const { - data: accounts, - }: QueryResult<Account[]> = await this._client.query(query) + const { data: accounts }: QueryResult<Account[]> = + await this._client.query(query) if (accounts.length > 1) { // If several account are found we will used trigger date to select the older const triggerService = new TriggerService(this._client) @@ -107,9 +106,8 @@ export default class AccountService { // eslint-disable-next-line @typescript-eslint/camelcase .where({ account_type: type }) // .indexFields(['account_type']) - const { - data: accounts, - }: QueryResult<Account[]> = await this._client.query(query) + const { data: accounts }: QueryResult<Account[]> = + await this._client.query(query) return accounts } catch (err) { console.error(`Error: GetAccountsByType: ${err}`) diff --git a/src/services/action.service.ts b/src/services/action.service.ts index 70643ede1..2383d7f14 100644 --- a/src/services/action.service.ts +++ b/src/services/action.service.ts @@ -26,8 +26,10 @@ export default class ActionService { * @returns {Promise<Ecogesture[]>} */ public async getAvailableActionList(): Promise<Ecogesture[]> { - const userChallenges: UserChallenge[] = await this._challengeService.getAllUserChallengeEntities() - const ecogestures: Ecogesture[] = await this._ecogestureService.getAllEcogestures() + const userChallenges: UserChallenge[] = + await this._challengeService.getAllUserChallengeEntities() + const ecogestures: Ecogesture[] = + await this._ecogestureService.getAllEcogestures() const actionsListIds: string[] = ecogestures .filter(ecogesture => ecogesture.action === true) .map(action => action._id) @@ -45,9 +47,8 @@ export default class ActionService { } }) } - const actionsList: Ecogesture[] = await this._ecogestureService.getEcogesturesByIds( - actionsListIds - ) + const actionsList: Ecogesture[] = + await this._ecogestureService.getEcogesturesByIds(actionsListIds) return actionsList } @@ -220,10 +221,11 @@ export default class ActionService { const progress = -startDate.startOf('day').diffNow('days').days if (progress >= duration) { const challengeService = new ChallengeService(this._client) - const userChallenge: UserChallenge = await challengeService.updateUserChallenge( - currentChallenge, - UserChallengeUpdateFlag.ACTION_NOTIFICATION - ) + const userChallenge: UserChallenge = + await challengeService.updateUserChallenge( + currentChallenge, + UserChallengeUpdateFlag.ACTION_NOTIFICATION + ) return userChallenge } else return null } else return null diff --git a/src/services/challenge.service.spec.ts b/src/services/challenge.service.spec.ts index 4af58ec04..da5d176ae 100644 --- a/src/services/challenge.service.spec.ts +++ b/src/services/challenge.service.spec.ts @@ -58,8 +58,10 @@ jest.mock('./exploration.service', () => { return jest.fn(() => { return { getExplorationEntityById: mockGetExplorationEntityById, - parseExplorationEntityToUserExploration: mockParseExplorationEntityToUserExploration, - getUserExplorationfromExplorationEntities: mockGetUserExplorationfromExplorationEntities, + parseExplorationEntityToUserExploration: + mockParseExplorationEntityToUserExploration, + getUserExplorationfromExplorationEntities: + mockGetUserExplorationfromExplorationEntities, } }) }) @@ -70,7 +72,8 @@ jest.mock('./consumption.service', () => { return jest.fn(() => { return { getGraphData: mockGetGraphData, - calculatePerformanceIndicatorValue: mockCalculatePerformanceIndicatorValue, + calculatePerformanceIndicatorValue: + mockCalculatePerformanceIndicatorValue, } }) }) @@ -87,9 +90,8 @@ describe('Challenge service', () => { describe('unLockCurrentUserChallenge method', () => { it('should return all user challenge', () => { - const result = challengeService.unLockCurrentUserChallenge( - userChallengeData - ) + const result = + challengeService.unLockCurrentUserChallenge(userChallengeData) expect(result).toEqual(userChallengeData) }) it('should return the challenge unlocked', () => { @@ -626,11 +628,12 @@ describe('Challenge service', () => { mockParseExplorationEntityToUserExploration.mockReturnValue( userExploration1 ) - const result = await challengeService.loopVerificationExplorationCondition( - userChallengeExplo1OnGoing, - allChallengeEntityData, - fluidStatusData - ) + const result = + await challengeService.loopVerificationExplorationCondition( + userChallengeExplo1OnGoing, + allChallengeEntityData, + fluidStatusData + ) expect(result).toEqual(userChallengeExplo1OnGoing) }) it('should return updated userChallenge with condition-validated exploration', async () => { @@ -639,11 +642,12 @@ describe('Challenge service', () => { userExploration4 ) - const result = await challengeService.loopVerificationExplorationCondition( - userChallengeExplo4, - allChallengeEntityData, - fluidStatusData - ) + const result = + await challengeService.loopVerificationExplorationCondition( + userChallengeExplo4, + allChallengeEntityData, + fluidStatusData + ) expect(result).toEqual(userChallengeExplo4) }) it('should return updated userChallenge with new exploration when condition is invalid', async () => { @@ -651,11 +655,12 @@ describe('Challenge service', () => { mockParseExplorationEntityToUserExploration.mockReturnValue( userExploration4_0 ) - const result = await challengeService.loopVerificationExplorationCondition( - userChallengeExplo4, - allChallengeEntityData, - fluidStatusData - ) + const result = + await challengeService.loopVerificationExplorationCondition( + userChallengeExplo4, + allChallengeEntityData, + fluidStatusData + ) expect(result).toEqual(userChallengeExplo4_0) }) }) diff --git a/src/services/challenge.service.ts b/src/services/challenge.service.ts index 6fc4b25a3..ddcac6f74 100644 --- a/src/services/challenge.service.ts +++ b/src/services/challenge.service.ts @@ -260,17 +260,19 @@ export default class ChallengeService { ): Promise<UserChallenge[]> { const explorationService = new ExplorationService(this._client) for (const explorationRelation of explorationEntityRelation) { - const exploration: UserExploration = explorationService.getUserExplorationfromExplorationEntities( - explorationEntities || [], - explorationRelation._id - ) - const userChallenge = await this.getUpdatedUserChallengeIfExplorationConditionIsValid( - exploration, - challenge, - duel, - quiz, - fluidStatus - ) + const exploration: UserExploration = + explorationService.getUserExplorationfromExplorationEntities( + explorationEntities || [], + explorationRelation._id + ) + const userChallenge = + await this.getUpdatedUserChallengeIfExplorationConditionIsValid( + exploration, + challenge, + duel, + quiz, + fluidStatus + ) if (userChallenge) { buildList.push(userChallenge) break @@ -298,12 +300,12 @@ export default class ChallengeService { const explorationService = new ExplorationService(this._client) let updatedUserChallenge: UserChallenge = { ...userChallenge } for (const relation of relationsArray.data) { - const newExploEntity = await explorationService.getExplorationEntityById( - relation._id - ) - const newUserExplo: UserExploration = explorationService.parseExplorationEntityToUserExploration( - newExploEntity - ) + const newExploEntity = + await explorationService.getExplorationEntityById(relation._id) + const newUserExplo: UserExploration = + explorationService.parseExplorationEntityToUserExploration( + newExploEntity + ) if (newExploEntity.fluid_condition.length > 0) { const isConditionValid = await this.isExplorationConditionVerified( newExploEntity, @@ -354,16 +356,15 @@ export default class ChallengeService { ) const { included: explorationEntities, - }: QueryResult< - ChallengeEntity[], - ExplorationEntity[] - > = await this._client.query(querySeasonEntityIncludeExploration) + }: QueryResult<ChallengeEntity[], ExplorationEntity[]> = + await this._client.query(querySeasonEntityIncludeExploration) const { included: quizEntities, }: QueryResult<ChallengeEntity[], QuizEntity[]> = await this._client.query( querySeasonEntityIncludeQuiz ) - const userChallengeList: UserChallenge[] = await this.getAllUserChallengeEntities() + const userChallengeList: UserChallenge[] = + await this.getAllUserChallengeEntities() const duelService = new DuelService(this._client) const quizService = new QuizService(this._client) const explorationService = new ExplorationService(this._client) @@ -382,10 +383,11 @@ export default class ChallengeService { ) //Only one exploration relation if (relationEntities.explorationEntityRelation.length === 1) { - const exploration: UserExploration = explorationService.getUserExplorationfromExplorationEntities( - explorationEntities || [], - relationEntities.explorationEntityRelation[0]._id - ) + const exploration: UserExploration = + explorationService.getUserExplorationfromExplorationEntities( + explorationEntities || [], + relationEntities.explorationEntityRelation[0]._id + ) const userChallenge = this.parseChallengeEntityToUserChallenge( challenge, duel, @@ -456,9 +458,8 @@ export default class ChallengeService { */ public async getAllChallengeEntities(): Promise<ChallengeEntity[]> { const query: QueryDefinition = Q(CHALLENGE_DOCTYPE) - const { - data: challenges, - }: QueryResult<ChallengeEntity[]> = await this._client.query(query) + const { data: challenges }: QueryResult<ChallengeEntity[]> = + await this._client.query(query) return challenges } @@ -487,9 +488,8 @@ export default class ChallengeService { */ public async getAllUserChallengeEntities(): Promise<UserChallenge[]> { const query: QueryDefinition = Q(USERCHALLENGE_DOCTYPE) - const { - data: userChallengeEntities, - }: QueryResult<UserChallengeEntity[]> = await this._client.query(query) + const { data: userChallengeEntities }: QueryResult<UserChallengeEntity[]> = + await this._client.query(query) const userChallenges: UserChallenge[] = userChallengeEntities.map( userChallengeEntity => this.parseUserChallengeEntityToUserChallenge(userChallengeEntity) @@ -523,10 +523,11 @@ export default class ChallengeService { userConsumption: userConsumption, }, } - const updatedUserChallenge: UserChallenge = await this.updateUserChallenge( - _userChallenge, - UserChallengeUpdateFlag.DUEL_CONSUMPTION - ) + const updatedUserChallenge: UserChallenge = + await this.updateUserChallenge( + _userChallenge, + UserChallengeUpdateFlag.DUEL_CONSUMPTION + ) return { updatedUserChallenge, dataloads } } catch (error) { console.log( @@ -562,9 +563,8 @@ export default class ChallengeService { USERCHALLENGE_DOCTYPE, userChallenge ) - const updatedUserChallenge: UserChallenge = this.parseUserChallengeEntityToUserChallenge( - updatedUserChallengeEntity - ) + const updatedUserChallenge: UserChallenge = + this.parseUserChallengeEntityToUserChallenge(updatedUserChallengeEntity) return updatedUserChallenge } catch (error) { console.log('Challenge service error on startUserChallenge : ', error) @@ -709,9 +709,10 @@ export default class ChallengeService { } break case UserChallengeUpdateFlag.EXPLORATION_NOTIFICATION: - updatedExploration = await explorationService.awaitNotificationUserExploration( - userChallenge.exploration - ) + updatedExploration = + await explorationService.awaitNotificationUserExploration( + userChallenge.exploration + ) updatedUserChallenge = { ...userChallenge, exploration: updatedExploration, @@ -766,14 +767,10 @@ export default class ChallengeService { break } try { - const { - data: userChallengeEntity, - }: QueryResult<UserChallengeEntity> = await this._client.save( - updatedUserChallenge - ) - const result: UserChallenge = this.parseUserChallengeEntityToUserChallenge( - userChallengeEntity - ) + const { data: userChallengeEntity }: QueryResult<UserChallengeEntity> = + await this._client.save(updatedUserChallenge) + const result: UserChallenge = + this.parseUserChallengeEntityToUserChallenge(userChallengeEntity) return result } catch (error) { console.log('Update user challenge error : ', error) diff --git a/src/services/consumption.service.spec.ts b/src/services/consumption.service.spec.ts index c5eb07f53..21583ae60 100644 --- a/src/services/consumption.service.spec.ts +++ b/src/services/consumption.service.spec.ts @@ -508,9 +508,10 @@ describe('Consumption service', () => { } mockClient.query.mockResolvedValueOnce(data) - const result = await consumptionDataManager.getFirstDataDateFromDoctypeWithPrice( - ENEDIS_MINUTE_DOCTYPE - ) + const result = + await consumptionDataManager.getFirstDataDateFromDoctypeWithPrice( + ENEDIS_MINUTE_DOCTYPE + ) expect(result).toEqual(data.data[0]) }) }) diff --git a/src/services/consumption.service.ts b/src/services/consumption.service.ts index 107b36b21..2706147c0 100644 --- a/src/services/consumption.service.ts +++ b/src/services/consumption.service.ts @@ -57,22 +57,24 @@ export default class ConsumptionDataManager { compareTimePeriod?: TimePeriod, isHome?: boolean ): Promise<Datachart | null> { - const InputisValid: boolean = this._consumptionValidatorService.ValidateGetGraphData( - timePeriod, - timeStep, - fluidTypes, - compareTimePeriod - ) - if (!InputisValid) return null - if (fluidTypes.length === 1 && !isHome) { - const fluidType: FluidType = fluidTypes[0] - // running the query - const fetchedData: Datachart | null = await this.fetchSingleFluidGraphData( + const InputisValid: boolean = + this._consumptionValidatorService.ValidateGetGraphData( timePeriod, timeStep, - fluidType, + fluidTypes, compareTimePeriod ) + if (!InputisValid) return null + if (fluidTypes.length === 1 && !isHome) { + const fluidType: FluidType = fluidTypes[0] + // running the query + const fetchedData: Datachart | null = + await this.fetchSingleFluidGraphData( + timePeriod, + timeStep, + fluidType, + compareTimePeriod + ) // formatting data const formattedData: Datachart | null = this.formatGraphDataManager( @@ -108,9 +110,8 @@ export default class ConsumptionDataManager { chartFluid: fluidType, }) } - const aggregatedData: Datachart | null = this.aggregateGraphData( - toBeAgreggatedData - ) + const aggregatedData: Datachart | null = + this.aggregateGraphData(toBeAgreggatedData) return aggregatedData } else return null } @@ -152,9 +153,7 @@ export default class ConsumptionDataManager { fluidTypes: FluidType ): Promise<Dataload[] | null> { const timePeriod = { - startDate: DateTime.now() - .plus({ days: -3 }) - .startOf('day'), + startDate: DateTime.now().plus({ days: -3 }).startOf('day'), endDate: DateTime.now(), } @@ -199,9 +198,8 @@ export default class ConsumptionDataManager { graphData.actualData ) if (graphData.actualData[0].price) - performanceIndicator.price = this.calculatePerformanceIndicatorPrice( - graphData.actualData - ) + performanceIndicator.price = + this.calculatePerformanceIndicatorPrice(graphData.actualData) } if ( @@ -213,10 +211,11 @@ export default class ConsumptionDataManager { graphData.comparisonData ) performanceIndicator.compareValue = comparisonSumValue - performanceIndicator.percentageVariation = this.calculatePerformanceIndicatorVariationPercentage( - performanceIndicator.value || 0, - comparisonSumValue - ) + performanceIndicator.percentageVariation = + this.calculatePerformanceIndicatorVariationPercentage( + performanceIndicator.value || 0, + comparisonSumValue + ) } performanceIndicators[fluidType] = performanceIndicator @@ -302,24 +301,26 @@ export default class ConsumptionDataManager { ): Datachart | null { if (!data) return null - const formattedActualData: Dataload[] = this._consumptionFormatterService.formatGraphData( - data.actualData, - timePeriod, - timeStep, - fluidType, - fluidStatus - ) - - let formattedComparisonData: Dataload[] | null = null - if (compareTimePeriod) - formattedComparisonData = this._consumptionFormatterService.formatGraphData( - data.comparisonData ? data.comparisonData : [], - compareTimePeriod, + const formattedActualData: Dataload[] = + this._consumptionFormatterService.formatGraphData( + data.actualData, + timePeriod, timeStep, fluidType, fluidStatus ) + let formattedComparisonData: Dataload[] | null = null + if (compareTimePeriod) + formattedComparisonData = + this._consumptionFormatterService.formatGraphData( + data.comparisonData ? data.comparisonData : [], + compareTimePeriod, + timeStep, + fluidType, + fluidStatus + ) + const result: Datachart = { actualData: formattedActualData, comparisonData: formattedComparisonData, @@ -490,9 +491,10 @@ export default class ConsumptionDataManager { if (singleFluidCharts[0].chartData.actualData[i]) { // Define the aggregated state - const aggregatedDataloadState: DataloadState = this._consumptionFormatterService.defineAggregatedDataloadState( - tempAggregatedState - ) + const aggregatedDataloadState: DataloadState = + this._consumptionFormatterService.defineAggregatedDataloadState( + tempAggregatedState + ) const acutaldataLoad: Dataload = { date: singleFluidCharts[0].chartData.actualData[i].date, value: agreggatedConvertedValue, @@ -509,9 +511,10 @@ export default class ConsumptionDataManager { singleFluidCharts[0].chartData.comparisonData[i] ) { // Define the aggregated state - const aggregatedComparisonDataloadState: DataloadState = this._consumptionFormatterService.defineAggregatedDataloadState( - tempComparisonAggregatedState - ) + const aggregatedComparisonDataloadState: DataloadState = + this._consumptionFormatterService.defineAggregatedDataloadState( + tempComparisonAggregatedState + ) const comparisondataLoad: Dataload = { date: singleFluidCharts[0].chartData.comparisonData[i].date, value: comparisonAgreggatedConvertedValue, @@ -598,9 +601,8 @@ export default class ConsumptionDataManager { public async saveDoc( consumptionDoc: DataloadEntity ): Promise<DataloadEntity> { - const { - data: savedDoc, - }: QueryResult<DataloadEntity> = await this._client.save(consumptionDoc) + const { data: savedDoc }: QueryResult<DataloadEntity> = + await this._client.save(consumptionDoc) return savedDoc } @@ -612,11 +614,8 @@ export default class ConsumptionDataManager { public async saveDocs( consumptionDocs: DataloadEntity[] ): Promise<DataloadEntity[]> { - const { - data: savedDocs, - }: QueryResult<DataloadEntity[]> = await this._client.saveAll( - consumptionDocs - ) + const { data: savedDocs }: QueryResult<DataloadEntity[]> = + await this._client.saveAll(consumptionDocs) return savedDocs } diff --git a/src/services/consumptionFormatter.service.spec.ts b/src/services/consumptionFormatter.service.spec.ts index 2a27a7681..293661219 100644 --- a/src/services/consumptionFormatter.service.spec.ts +++ b/src/services/consumptionFormatter.service.spec.ts @@ -506,12 +506,13 @@ describe('ConsumptionFormatter service', () => { ...data, state: DataloadState.COMING, } - const result: Dataload = consumptionFormatterService.defineDataloadState( - data, - FluidType.ELECTRICITY, - TimeStep.DAY, - fluidStatus[FluidType.ELECTRICITY] - ) + const result: Dataload = + consumptionFormatterService.defineDataloadState( + data, + FluidType.ELECTRICITY, + TimeStep.DAY, + fluidStatus[FluidType.ELECTRICITY] + ) expect(result).toEqual(expectedResult) }) it('case GAS with date >= today-5', () => { @@ -523,12 +524,13 @@ describe('ConsumptionFormatter service', () => { ...data, state: DataloadState.COMING, } - const result: Dataload = consumptionFormatterService.defineDataloadState( - data, - FluidType.GAS, - TimeStep.DAY, - fluidStatus[FluidType.GAS] - ) + const result: Dataload = + consumptionFormatterService.defineDataloadState( + data, + FluidType.GAS, + TimeStep.DAY, + fluidStatus[FluidType.GAS] + ) expect(result).toEqual(expectedResult) }) it('case WATER with date >= today-5', () => { @@ -540,12 +542,13 @@ describe('ConsumptionFormatter service', () => { ...data, state: DataloadState.COMING, } - const result: Dataload = consumptionFormatterService.defineDataloadState( - data, - FluidType.WATER, - TimeStep.DAY, - fluidStatus[FluidType.WATER] - ) + const result: Dataload = + consumptionFormatterService.defineDataloadState( + data, + FluidType.WATER, + TimeStep.DAY, + fluidStatus[FluidType.WATER] + ) expect(result).toEqual(expectedResult) }) }) @@ -601,12 +604,13 @@ describe('ConsumptionFormatter service', () => { ...data, state: DataloadState.MISSING, } - const result: Dataload = consumptionFormatterService.defineDataloadState( - data, - FluidType.ELECTRICITY, - TimeStep.DAY, - fluidStatus[FluidType.ELECTRICITY] - ) + const result: Dataload = + consumptionFormatterService.defineDataloadState( + data, + FluidType.ELECTRICITY, + TimeStep.DAY, + fluidStatus[FluidType.ELECTRICITY] + ) expect(result).toEqual(expectedResult) }) it('case GAS with date <= today-5', () => { @@ -618,12 +622,13 @@ describe('ConsumptionFormatter service', () => { ...data, state: DataloadState.MISSING, } - const result: Dataload = consumptionFormatterService.defineDataloadState( - data, - FluidType.GAS, - TimeStep.DAY, - fluidStatus[FluidType.GAS] - ) + const result: Dataload = + consumptionFormatterService.defineDataloadState( + data, + FluidType.GAS, + TimeStep.DAY, + fluidStatus[FluidType.GAS] + ) expect(result).toEqual(expectedResult) }) it('case WATER with date <= today-5', () => { @@ -635,12 +640,13 @@ describe('ConsumptionFormatter service', () => { ...data, state: DataloadState.MISSING, } - const result: Dataload = consumptionFormatterService.defineDataloadState( - data, - FluidType.WATER, - TimeStep.DAY, - fluidStatus[FluidType.WATER] - ) + const result: Dataload = + consumptionFormatterService.defineDataloadState( + data, + FluidType.WATER, + TimeStep.DAY, + fluidStatus[FluidType.WATER] + ) expect(result).toEqual(expectedResult) }) }) @@ -653,9 +659,10 @@ describe('ConsumptionFormatter service', () => { DataloadState.HOLE, DataloadState.VALID, ] - const result: DataloadState = consumptionFormatterService.defineAggregatedDataloadState( - dataloadStateArray - ) + const result: DataloadState = + consumptionFormatterService.defineAggregatedDataloadState( + dataloadStateArray + ) expect(result).toEqual(DataloadState.AGGREGATED_WITH_HOLE_OR_MISSING) }) it('should return AGGREGATED_WITH_HOLE_OR_MISSING because of MISSING data', () => { @@ -664,9 +671,10 @@ describe('ConsumptionFormatter service', () => { DataloadState.MISSING, DataloadState.VALID, ] - const result: DataloadState = consumptionFormatterService.defineAggregatedDataloadState( - dataloadStateArray - ) + const result: DataloadState = + consumptionFormatterService.defineAggregatedDataloadState( + dataloadStateArray + ) expect(result).toEqual(DataloadState.AGGREGATED_WITH_HOLE_OR_MISSING) }) it('should return AGGREGATED_WITH_COMING because of UPCOMING data', () => { @@ -675,9 +683,10 @@ describe('ConsumptionFormatter service', () => { DataloadState.UPCOMING, DataloadState.VALID, ] - const result: DataloadState = consumptionFormatterService.defineAggregatedDataloadState( - dataloadStateArray - ) + const result: DataloadState = + consumptionFormatterService.defineAggregatedDataloadState( + dataloadStateArray + ) expect(result).toEqual(DataloadState.AGGREGATED_WITH_COMING) }) it('should return AGGREGATED_WITH_COMING because of COMING data', () => { @@ -686,9 +695,10 @@ describe('ConsumptionFormatter service', () => { DataloadState.COMING, DataloadState.VALID, ] - const result: DataloadState = consumptionFormatterService.defineAggregatedDataloadState( - dataloadStateArray - ) + const result: DataloadState = + consumptionFormatterService.defineAggregatedDataloadState( + dataloadStateArray + ) expect(result).toEqual(DataloadState.AGGREGATED_WITH_COMING) }) it('should return AGGREGATED_WITH_EMPTY because of EMPTY data', () => { @@ -697,9 +707,10 @@ describe('ConsumptionFormatter service', () => { DataloadState.EMPTY, DataloadState.VALID, ] - const result: DataloadState = consumptionFormatterService.defineAggregatedDataloadState( - dataloadStateArray - ) + const result: DataloadState = + consumptionFormatterService.defineAggregatedDataloadState( + dataloadStateArray + ) expect(result).toEqual(DataloadState.AGGREGATED_WITH_EMPTY) }) it('should return AGGREGATED_VALID', () => { @@ -708,9 +719,10 @@ describe('ConsumptionFormatter service', () => { DataloadState.VALID, DataloadState.VALID, ] - const result: DataloadState = consumptionFormatterService.defineAggregatedDataloadState( - dataloadStateArray - ) + const result: DataloadState = + consumptionFormatterService.defineAggregatedDataloadState( + dataloadStateArray + ) expect(result).toEqual(DataloadState.AGGREGATED_VALID) }) it('should return AGGREGATED_HOLE_OR_MISSING', () => { @@ -719,9 +731,10 @@ describe('ConsumptionFormatter service', () => { DataloadState.MISSING, DataloadState.MISSING, ] - const result: DataloadState = consumptionFormatterService.defineAggregatedDataloadState( - dataloadStateArray - ) + const result: DataloadState = + consumptionFormatterService.defineAggregatedDataloadState( + dataloadStateArray + ) expect(result).toEqual(DataloadState.AGGREGATED_HOLE_OR_MISSING) }) it('should return AGGREGATED_COMING', () => { @@ -730,9 +743,10 @@ describe('ConsumptionFormatter service', () => { DataloadState.COMING, DataloadState.COMING, ] - const result: DataloadState = consumptionFormatterService.defineAggregatedDataloadState( - dataloadStateArray - ) + const result: DataloadState = + consumptionFormatterService.defineAggregatedDataloadState( + dataloadStateArray + ) expect(result).toEqual(DataloadState.AGGREGATED_COMING) }) it('should return AGGREGATED_EMPTY', () => { @@ -741,9 +755,10 @@ describe('ConsumptionFormatter service', () => { DataloadState.EMPTY, DataloadState.EMPTY, ] - const result: DataloadState = consumptionFormatterService.defineAggregatedDataloadState( - dataloadStateArray - ) + const result: DataloadState = + consumptionFormatterService.defineAggregatedDataloadState( + dataloadStateArray + ) expect(result).toEqual(DataloadState.AGGREGATED_EMPTY) }) }) diff --git a/src/services/dateChart.service.ts b/src/services/dateChart.service.ts index 6bb1f0f67..6552c7e26 100644 --- a/src/services/dateChart.service.ts +++ b/src/services/dateChart.service.ts @@ -307,7 +307,8 @@ export default class DateChartService { fluidType: FluidType ): number | null { if (date && fluidType !== FluidType.MULTIFLUID) { - const fluidConfig: Array<FluidConfig> = new ConfigService().getFluidConfig() + const fluidConfig: Array<FluidConfig> = + new ConfigService().getFluidConfig() const today = DateTime.local().setZone('utc', { keepLocalTime: true, }) diff --git a/src/services/duel.service.ts b/src/services/duel.service.ts index 82bf4af52..817eac1b6 100644 --- a/src/services/duel.service.ts +++ b/src/services/duel.service.ts @@ -117,9 +117,8 @@ export default class DuelService { */ public async getAllDuelEntities(): Promise<DuelEntity[]> { const query: QueryDefinition = Q(DUEL_DOCTYPE) - const { - data: dueles, - }: QueryResult<DuelEntity[]> = await this._client.query(query) + const { data: dueles }: QueryResult<DuelEntity[]> = + await this._client.query(query) return dueles } @@ -192,9 +191,8 @@ export default class DuelService { ): Promise<UserDuel> { const consumptionService = new ConsumptionService(this._client) const performanceService = new PerformanceService() - const fluidTypes: Array<FluidType> = this.getFluidTypesFromStatus( - fluidStatus - ) + const fluidTypes: Array<FluidType> = + this.getFluidTypesFromStatus(fluidStatus) // Get last period with all days known const period: TimePeriod | false = await this.getValidPeriod( fluidStatus, @@ -203,14 +201,14 @@ export default class DuelService { ) if (period !== false) { // Fetch performance data - const fetchLastValidData: Array<PerformanceIndicator> = await consumptionService.getPerformanceIndicators( - period, - TimeStep.DAY, - fluidTypes - ) - const maxData: PerformanceIndicator = performanceService.aggregatePerformanceIndicators( - fetchLastValidData - ) + const fetchLastValidData: Array<PerformanceIndicator> = + await consumptionService.getPerformanceIndicators( + period, + TimeStep.DAY, + fluidTypes + ) + const maxData: PerformanceIndicator = + performanceService.aggregatePerformanceIndicators(fetchLastValidData) // Set the threshold let updatedThreshold: number if (maxData && maxData.value && maxData.value > 0) { diff --git a/src/services/ecogesture.service.ts b/src/services/ecogesture.service.ts index 0de5cd9e3..393699d1b 100644 --- a/src/services/ecogesture.service.ts +++ b/src/services/ecogesture.service.ts @@ -30,18 +30,16 @@ export default class EcogestureService { query = query.where({}).sortBy([{ season: 'desc' }]) } - const { - data: ecogestures, - }: QueryResult<Ecogesture[]> = await this._client.query(query) + const { data: ecogestures }: QueryResult<Ecogesture[]> = + await this._client.query(query) if (seasonFilter && seasonFilter !== Season.NONE) { - const { - data: ecogesturesWithSeason, - }: QueryResult<Ecogesture[]> = await this._client.query( - Q(ECOGESTURE_DOCTYPE) - .where({ season: { $eq: seasonFilter } }) - .sortBy([{ season: 'asc' }]) - ) + const { data: ecogesturesWithSeason }: QueryResult<Ecogesture[]> = + await this._client.query( + Q(ECOGESTURE_DOCTYPE) + .where({ season: { $eq: seasonFilter } }) + .sortBy([{ season: 'asc' }]) + ) return [...ecogesturesWithSeason, ...ecogestures] } return ecogestures @@ -54,9 +52,8 @@ export default class EcogestureService { */ public async getEcogesturesByIds(ids: string[]): Promise<Ecogesture[]> { const query: QueryDefinition = Q(ECOGESTURE_DOCTYPE).getByIds(ids) - const { - data: ecogestures, - }: QueryResult<Ecogesture[]> = await this._client.query(query) + const { data: ecogestures }: QueryResult<Ecogesture[]> = + await this._client.query(query) return ecogestures } @@ -202,9 +199,8 @@ export default class EcogestureService { * @returns {Ecogesture} Udpated Ecogesture */ public async updateEcogesture(ecogesture: Ecogesture): Promise<Ecogesture> { - const { - data: updatedEcogesture, - }: QueryResult<Ecogesture> = await this._client.save(ecogesture) + const { data: updatedEcogesture }: QueryResult<Ecogesture> = + await this._client.save(ecogesture) return updatedEcogesture } } diff --git a/src/services/exploration.service.spec.ts b/src/services/exploration.service.spec.ts index d75145f08..8979264f2 100644 --- a/src/services/exploration.service.spec.ts +++ b/src/services/exploration.service.spec.ts @@ -82,9 +82,10 @@ describe('Exploration service', () => { describe('parseExplorationEntityToUserExploration method', () => { it('should return the userExploration from a explorationEntity', () => { - const result = explorationService.parseExplorationEntityToUserExploration( - explorationEntity - ) + const result = + explorationService.parseExplorationEntityToUserExploration( + explorationEntity + ) const mockUpdatedExploration: UserExploration = { ...explorationEntity, progress: 0, @@ -97,10 +98,11 @@ describe('Exploration service', () => { describe('getUserExplorationfromExplorationEntities method', () => { it('should return the userExploration from a explorationEntity', () => { const searchId = 'EXPLORATION001' - const result = explorationService.getUserExplorationfromExplorationEntities( - allExplorationEntities, - searchId - ) + const result = + explorationService.getUserExplorationfromExplorationEntities( + allExplorationEntities, + searchId + ) const updatedUserExploration = { ...UserExplorationUnlocked, date: result.date, diff --git a/src/services/exploration.service.ts b/src/services/exploration.service.ts index 84f916c3f..0fc57ff75 100644 --- a/src/services/exploration.service.ts +++ b/src/services/exploration.service.ts @@ -24,9 +24,8 @@ export default class ExplorationService { */ public async getAllExplorationEntities(): Promise<ExplorationEntity[]> { const query: QueryDefinition = Q(EXPLORATION_DOCTYPE) - const { - data: explorations, - }: QueryResult<ExplorationEntity[]> = await this._client.query(query) + const { data: explorations }: QueryResult<ExplorationEntity[]> = + await this._client.query(query) return explorations } @@ -93,9 +92,8 @@ export default class ExplorationService { if (explorationEntityIndex >= 0) { const explorationEntity: ExplorationEntity = explorationEntityList[explorationEntityIndex] - exploration = this.parseExplorationEntityToUserExploration( - explorationEntity - ) + exploration = + this.parseExplorationEntityToUserExploration(explorationEntity) } } return exploration diff --git a/src/services/fluid.service.spec.ts b/src/services/fluid.service.spec.ts index af2a1acff..062014b5c 100644 --- a/src/services/fluid.service.spec.ts +++ b/src/services/fluid.service.spec.ts @@ -552,16 +552,12 @@ describe('FLuid service', () => { { fluidType: FluidType.ELECTRICITY, status: FluidState.DONE, - firstDataDate: DateTime.local() - .minus({ day: 31 }) - .setZone('utc', { - keepLocalTime: true, - }), - lastDataDate: DateTime.local() - .minus({ day: 1 }) - .setZone('utc', { - keepLocalTime: true, - }), + firstDataDate: DateTime.local().minus({ day: 31 }).setZone('utc', { + keepLocalTime: true, + }), + lastDataDate: DateTime.local().minus({ day: 1 }).setZone('utc', { + keepLocalTime: true, + }), connection: { konnector: konnectorsData[0], account: accountsData[0], @@ -710,9 +706,8 @@ describe('FLuid service', () => { }, }, ] - const result: FluidType[] = await fluidService.getFluidsConcernedByPartnerIssue( - mockFluidStatus - ) + const result: FluidType[] = + await fluidService.getFluidsConcernedByPartnerIssue(mockFluidStatus) expect(result).toEqual([FluidType.ELECTRICITY]) }) it('should return the fluids concerned by partnerIssue', async () => { diff --git a/src/services/fluid.service.ts b/src/services/fluid.service.ts index 5569acc91..c77248305 100644 --- a/src/services/fluid.service.ts +++ b/src/services/fluid.service.ts @@ -90,70 +90,64 @@ export default class FluidService { ): Promise<FluidStatus[]> => { const fluidConfig = new ConfigService().getFluidConfig() const accountService = new AccountService(this._client) - const [ - elecAccount, - waterAccount, - gasAccount, - ]: (Account | null)[] = await Promise.all([ - accountService.getAccountByType( - fluidConfig[FluidType.ELECTRICITY].konnectorConfig.slug - ), - accountService.getAccountByType( - fluidConfig[FluidType.WATER].konnectorConfig.slug - ), - accountService.getAccountByType( - fluidConfig[FluidType.GAS].konnectorConfig.slug - ), - ]) + const [elecAccount, waterAccount, gasAccount]: (Account | null)[] = + await Promise.all([ + accountService.getAccountByType( + fluidConfig[FluidType.ELECTRICITY].konnectorConfig.slug + ), + accountService.getAccountByType( + fluidConfig[FluidType.WATER].konnectorConfig.slug + ), + accountService.getAccountByType( + fluidConfig[FluidType.GAS].konnectorConfig.slug + ), + ]) const konnectorService = new KonnectorService(this._client) - const [ - elecKonnector, - waterKonnector, - gasKonnector, - ]: (Konnector | null)[] = await Promise.all([ - konnectorService.getKonnector( - fluidConfig[FluidType.ELECTRICITY].konnectorConfig.slug - ), + const [elecKonnector, waterKonnector, gasKonnector]: (Konnector | null)[] = + await Promise.all([ + konnectorService.getKonnector( + fluidConfig[FluidType.ELECTRICITY].konnectorConfig.slug + ), - konnectorService.getKonnector( - fluidConfig[FluidType.WATER].konnectorConfig.slug - ), - konnectorService.getKonnector( - fluidConfig[FluidType.GAS].konnectorConfig.slug - ), - ]) + konnectorService.getKonnector( + fluidConfig[FluidType.WATER].konnectorConfig.slug + ), + konnectorService.getKonnector( + fluidConfig[FluidType.GAS].konnectorConfig.slug + ), + ]) const triggerService = new TriggerService(this._client) - const [ - elecTrigger, - waterTrigger, - gasTrigger, - ]: (Trigger | null)[] = await Promise.all([ - elecAccount && elecKonnector - ? triggerService.getTrigger(elecAccount, elecKonnector) - : null, - waterAccount && waterKonnector - ? triggerService.getTrigger(waterAccount, waterKonnector) - : null, - gasAccount && gasKonnector - ? triggerService.getTrigger(gasAccount, gasKonnector) - : null, - ]) + const [elecTrigger, waterTrigger, gasTrigger]: (Trigger | null)[] = + await Promise.all([ + elecAccount && elecKonnector + ? triggerService.getTrigger(elecAccount, elecKonnector) + : null, + waterAccount && waterKonnector + ? triggerService.getTrigger(waterAccount, waterKonnector) + : null, + gasAccount && gasKonnector + ? triggerService.getTrigger(gasAccount, gasKonnector) + : null, + ]) const consumptionService = new ConsumptionService(this._client) - const [ - elecStatus, - waterStatus, - gasStatus, - ]: (TriggerState | null)[] = await Promise.all([ - elecTrigger ? triggerService.fetchTriggerState(elecTrigger) : null, - waterTrigger ? triggerService.fetchTriggerState(waterTrigger) : null, - gasTrigger ? triggerService.fetchTriggerState(gasTrigger) : null, - ]) - const firstDataDates: (DateTime | null)[] = await consumptionService.fetchAllFirstDateData( - [FluidType.ELECTRICITY, FluidType.WATER, FluidType.GAS] - ) - const lastDataDates: (DateTime | null)[] = await consumptionService.fetchAllLastDateData( - [FluidType.ELECTRICITY, FluidType.WATER, FluidType.GAS] - ) + const [elecStatus, waterStatus, gasStatus]: (TriggerState | null)[] = + await Promise.all([ + elecTrigger ? triggerService.fetchTriggerState(elecTrigger) : null, + waterTrigger ? triggerService.fetchTriggerState(waterTrigger) : null, + gasTrigger ? triggerService.fetchTriggerState(gasTrigger) : null, + ]) + const firstDataDates: (DateTime | null)[] = + await consumptionService.fetchAllFirstDateData([ + FluidType.ELECTRICITY, + FluidType.WATER, + FluidType.GAS, + ]) + const lastDataDates: (DateTime | null)[] = + await consumptionService.fetchAllLastDateData([ + FluidType.ELECTRICITY, + FluidType.WATER, + FluidType.GAS, + ]) const result: FluidStatus[] = [ { fluidType: FluidType.ELECTRICITY, diff --git a/src/services/fluidsPrices.service.ts b/src/services/fluidsPrices.service.ts index 48d95edb3..c4c4c3615 100644 --- a/src/services/fluidsPrices.service.ts +++ b/src/services/fluidsPrices.service.ts @@ -19,9 +19,8 @@ export default class FluidPricesService { public async getAllPrices(): Promise<FluidPrice[]> { const query: QueryDefinition = Q(FLUIDPRICES_DOCTYPE).limitBy(900) //TODO : handle case of 1000+ entries in doctype - const { - data: fluidsPrices, - }: QueryResult<FluidPrice[]> = await this._client.query(query) + const { data: fluidsPrices }: QueryResult<FluidPrice[]> = + await this._client.query(query) return fluidsPrices } @@ -46,9 +45,8 @@ export default class FluidPricesService { .sortBy([{ startDate: 'desc' }]) .limitBy(1) - const { - data: fluidsPrices, - }: QueryResult<FluidPrice[]> = await this._client.query(query) + const { data: fluidsPrices }: QueryResult<FluidPrice[]> = + await this._client.query(query) return fluidsPrices[0] } @@ -63,9 +61,8 @@ export default class FluidPricesService { .sortBy([{ fluidType: 'asc' }]) .limitBy(3) - const { - data: fluidsPrices, - }: QueryResult<FluidPrice[]> = await this._client.query(query) + const { data: fluidsPrices }: QueryResult<FluidPrice[]> = + await this._client.query(query) // If some data is missing, recover it using default config if (fluidsPrices.length !== 3) { @@ -138,12 +135,8 @@ export default class FluidPricesService { */ public async createPrice(newPrice: FluidPrice): Promise<FluidPrice | null> { try { - const { - data: createdPrice, - }: QueryResult<FluidPrice> = await this._client.create( - FLUIDPRICES_DOCTYPE, - newPrice - ) + const { data: createdPrice }: QueryResult<FluidPrice> = + await this._client.create(FLUIDPRICES_DOCTYPE, newPrice) return createdPrice } catch (error) { console.log('Error creating new createdPrice: ', error) @@ -161,12 +154,11 @@ export default class FluidPricesService { doc: FluidPrice, attributes: Partial<FluidPrice> ): Promise<FluidPrice | null> { - const { - data: fluidPrice, - }: QueryResult<FluidPrice | null> = await this._client.save({ - ...doc, - ...attributes, - }) + const { data: fluidPrice }: QueryResult<FluidPrice | null> = + await this._client.save({ + ...doc, + ...attributes, + }) if (fluidPrice) { return fluidPrice } diff --git a/src/services/initialization.service.ts b/src/services/initialization.service.ts index 78e02c12a..d154d1f88 100644 --- a/src/services/initialization.service.ts +++ b/src/services/initialization.service.ts @@ -215,7 +215,8 @@ export default class InitializationService { public async initProfileEcogesture(): Promise<ProfileEcogesture | null> { const profileEcogestureService = new ProfileEcogestureService(this._client) try { - const loadedProfileEcogesture = await profileEcogestureService.getProfileEcogesture() + const loadedProfileEcogesture = + await profileEcogestureService.getProfileEcogesture() log.info('[Initialization] ProfileEcogesture loaded') return loadedProfileEcogesture } catch (error) { @@ -353,7 +354,8 @@ export default class InitializationService { const challengeHash = hashFile(challengeEntityData) const challengeService = new ChallengeService(this._client) // Populate data if none challengeEntity exists - const loadedChallengeEntity = await challengeService.getAllChallengeEntities() + const loadedChallengeEntity = + await challengeService.getAllChallengeEntities() if ( !loadedChallengeEntity || (loadedChallengeEntity && loadedChallengeEntity.length === 0) @@ -555,7 +557,8 @@ export default class InitializationService { const explorationHash = hashFile(explorationEntityData) const explorationService = new ExplorationService(this._client) // Populate data if none explorationEntity exists - const loadedExplorationEntity = await explorationService.getAllExplorationEntities() + const loadedExplorationEntity = + await explorationService.getAllExplorationEntities() if ( !loadedExplorationEntity || (loadedExplorationEntity && loadedExplorationEntity.length === 0) @@ -619,9 +622,7 @@ export default class InitializationService { } } - public async initAnalysis( - profile: Profile - ): Promise<{ + public async initAnalysis(profile: Profile): Promise<{ monthlyAnalysisDate: DateTime haveSeenLastAnalysis: boolean }> { @@ -728,18 +729,14 @@ export default class InitializationService { * sucess return: UserChallenge, Dataload[] * failure throw error */ - public async initDuelProgress( - userChallenge: UserChallenge - ): Promise<{ + public async initDuelProgress(userChallenge: UserChallenge): Promise<{ updatedUserChallenge: UserChallenge dataloads: Dataload[] }> { const challengeService = new ChallengeService(this._client) try { - const { - updatedUserChallenge, - dataloads, - } = await challengeService.initChallengeDuelProgress(userChallenge) + const { updatedUserChallenge, dataloads } = + await challengeService.initChallengeDuelProgress(userChallenge) return { updatedUserChallenge, dataloads } } catch (error) { this._setinitStepError(InitStepsErrors.CHALLENGES_ERROR) diff --git a/src/services/konnector.service.ts b/src/services/konnector.service.ts index 37f1ad531..5b16ad539 100644 --- a/src/services/konnector.service.ts +++ b/src/services/konnector.service.ts @@ -14,9 +14,8 @@ export default class KonnectorService { const query: QueryDefinition = Q(KONNECTORS_DOCTYPE).where({ _id: KONNECTORS_DOCTYPE + '/' + id, }) - const { - data: konnector, - }: QueryResult<Konnector[]> = await this._client.query(query) + const { data: konnector }: QueryResult<Konnector[]> = + await this._client.query(query) return konnector[0] ? konnector[0] : null } diff --git a/src/services/partnersInfo.service.spec.ts b/src/services/partnersInfo.service.spec.ts index 69aaaade2..07f198a26 100644 --- a/src/services/partnersInfo.service.spec.ts +++ b/src/services/partnersInfo.service.spec.ts @@ -14,9 +14,8 @@ describe('PartnersInfo service', () => { const partnersInfoService = new PartnersInfoService(mockClient) it('should return partnersInfo', async () => { - const result: - | PartnersInfo - | undefined = await partnersInfoService.getPartnersInfo() + const result: PartnersInfo | undefined = + await partnersInfoService.getPartnersInfo() expect(result).toEqual(undefined) }) it('should return an error', async () => { diff --git a/src/services/performanceIndicator.service.spec.ts b/src/services/performanceIndicator.service.spec.ts index c3cac0a58..cb046dd2a 100644 --- a/src/services/performanceIndicator.service.spec.ts +++ b/src/services/performanceIndicator.service.spec.ts @@ -28,9 +28,10 @@ describe('performanceIndicator service', () => { compareValue: 7.84615, percentageVariation: 0.26191826564620857, } - let result = performanceIndicatorService.aggregatePerformanceIndicators( - performanceIndicator - ) + let result = + performanceIndicatorService.aggregatePerformanceIndicators( + performanceIndicator + ) expect(result).toEqual(expectedResult) //Only two values @@ -51,9 +52,10 @@ describe('performanceIndicator service', () => { compareValue: 5.26785, percentageVariation: 0.6454720616570329, } - result = performanceIndicatorService.aggregatePerformanceIndicators( - performanceIndicator - ) + result = + performanceIndicatorService.aggregatePerformanceIndicators( + performanceIndicator + ) expect(result).toEqual(expectedResult) //lack of value for one @@ -79,9 +81,10 @@ describe('performanceIndicator service', () => { percentageVariation: 0.48368308023680406, value: 4.0511, } - result = performanceIndicatorService.aggregatePerformanceIndicators( - performanceIndicator - ) + result = + performanceIndicatorService.aggregatePerformanceIndicators( + performanceIndicator + ) expect(result).toEqual(expectedResult) //lack of compareValue for one @@ -107,9 +110,10 @@ describe('performanceIndicator service', () => { compareValue: 0, percentageVariation: -Infinity, } - result = performanceIndicatorService.aggregatePerformanceIndicators( - performanceIndicator - ) + result = + performanceIndicatorService.aggregatePerformanceIndicators( + performanceIndicator + ) expect(result).toEqual(expectedResult) //Only one with no compared value @@ -125,9 +129,10 @@ describe('performanceIndicator service', () => { compareValue: 0, percentageVariation: -Infinity, } - result = performanceIndicatorService.aggregatePerformanceIndicators( - performanceIndicator - ) + result = + performanceIndicatorService.aggregatePerformanceIndicators( + performanceIndicator + ) expect(result).toEqual(expectedResult) //Only one with no value @@ -143,9 +148,10 @@ describe('performanceIndicator service', () => { compareValue: 2.61, percentageVariation: 1, } - result = performanceIndicatorService.aggregatePerformanceIndicators( - performanceIndicator - ) + result = + performanceIndicatorService.aggregatePerformanceIndicators( + performanceIndicator + ) expect(result).toEqual(expectedResult) }) }) diff --git a/src/services/profile.service.ts b/src/services/profile.service.ts index 32a7c72ca..cee6ea384 100644 --- a/src/services/profile.service.ts +++ b/src/services/profile.service.ts @@ -58,12 +58,11 @@ export default class ProfileService { const { data: [doc], }: QueryResult<ProfileEntity[]> = await this._client.query(query.limitBy(1)) - const { - data: profileEntity, - }: QueryResult<ProfileEntity | null> = await this._client.save({ - ...doc, - ...attributes, - }) + const { data: profileEntity }: QueryResult<ProfileEntity | null> = + await this._client.save({ + ...doc, + ...attributes, + }) if (profileEntity) { return this.parseProfileEntityToProfile(profileEntity) } diff --git a/src/services/profileEcogesture.service.ts b/src/services/profileEcogesture.service.ts index 6913923db..37d5b0e85 100644 --- a/src/services/profileEcogesture.service.ts +++ b/src/services/profileEcogesture.service.ts @@ -37,12 +37,11 @@ export default class ProfileEcogestureService { query.limitBy(1) ) if (doc) { - const { - data: profileEcogesture, - }: QueryResult<ProfileEcogesture | null> = await this._client.save({ - ...doc, - ...attributes, - }) + const { data: profileEcogesture }: QueryResult<ProfileEcogesture | null> = + await this._client.save({ + ...doc, + ...attributes, + }) if (profileEcogesture) return profileEcogesture } return null diff --git a/src/services/profileType.service.spec.ts b/src/services/profileType.service.spec.ts index 68c0cb574..d13bb7b4a 100644 --- a/src/services/profileType.service.spec.ts +++ b/src/services/profileType.service.spec.ts @@ -52,21 +52,24 @@ describe('ProfileType service', () => { describe('calculateWarmingEstimatedConsumption', () => { it('should calculate the Warming Estimated Consumption', () => { - const estimatedConsumption = profileTypeService.calculateWarmingEstimatedConsumption() + const estimatedConsumption = + profileTypeService.calculateWarmingEstimatedConsumption() expect(estimatedConsumption).toEqual(mockEstimatedConsumption) }) it('should calculate the Warming Corrected Consumption', () => { - const correctedConsumption = profileTypeService.calculateWarmingCorrectedConsumption( - mockEstimatedConsumption - ) + const correctedConsumption = + profileTypeService.calculateWarmingCorrectedConsumption( + mockEstimatedConsumption + ) expect(correctedConsumption).toEqual(mockCorrectedConsumption) }) it('should calculate the Warming Month Consumption', async () => { - const monthConsumption = await profileTypeService.calculateWarmingMonthConsumption( - mockCorrectedConsumption, - 3 - ) + const monthConsumption = + await profileTypeService.calculateWarmingMonthConsumption( + mockCorrectedConsumption, + 3 + ) expect(monthConsumption).toEqual(mockMonthConsumption) }) it('should get the heating consumption', async () => { @@ -146,9 +149,8 @@ describe('ProfileType service', () => { DateTime.now().year ) - const monthCookingConsumption = _profileTypeService.getMonthCookingConsumption( - 1 - ) + const monthCookingConsumption = + _profileTypeService.getMonthCookingConsumption(1) expect(monthCookingConsumption).toEqual(mockMonthCookingConsumption) }) }) @@ -160,9 +162,8 @@ describe('ProfileType service', () => { DateTime.now().year ) - const monthElectricSpecificConsumption = _profileTypeService.getMonthElectricSpecificConsumption( - 1 - ) + const monthElectricSpecificConsumption = + _profileTypeService.getMonthElectricSpecificConsumption(1) expect(monthElectricSpecificConsumption).toEqual( mockMonthElectricSpecificConsumption ) @@ -175,9 +176,8 @@ describe('ProfileType service', () => { mockClient, DateTime.now().year ) - const monthColdWaterConsumption = _profileTypeService.getMonthColdWaterConsumption( - 1 - ) + const monthColdWaterConsumption = + _profileTypeService.getMonthColdWaterConsumption(1) expect(monthColdWaterConsumption).toEqual(mockMonthColdWaterConsumption) }) }) diff --git a/src/services/profileType.service.ts b/src/services/profileType.service.ts index 5ce0179da..23a52afcc 100644 --- a/src/services/profileType.service.ts +++ b/src/services/profileType.service.ts @@ -66,17 +66,17 @@ export default class ProfileTypeService { public calculateWarmingCorrectedConsumption( estimatedConsumption: number ): number { - const outsideFacingWalls: OutsideFacingWalls = this.profileType - .outsideFacingWalls + const outsideFacingWalls: OutsideFacingWalls = + this.profileType.outsideFacingWalls const housingType: HousingType = this.profileType.housingType const floor: Floor = this.profileType.floor const constructionYear: ConstructionYear = this.profileType.constructionYear - const individualInsulationWork: IndividualInsulationWork[] = this - .profileType.individualInsulationWork - const hasInstalledVentilation: ThreeChoicesAnswer = this.profileType - .hasInstalledVentilation - const hasReplacedHeater: ThreeChoicesAnswer = this.profileType - .hasReplacedHeater + const individualInsulationWork: IndividualInsulationWork[] = + this.profileType.individualInsulationWork + const hasInstalledVentilation: ThreeChoicesAnswer = + this.profileType.hasInstalledVentilation + const hasReplacedHeater: ThreeChoicesAnswer = + this.profileType.hasReplacedHeater const heating = this.profileType.heating //Apply corrections @@ -199,9 +199,8 @@ export default class ProfileTypeService { */ public async getMonthHeating(month: number): Promise<number> { const estimatedConsumption = this.calculateWarmingEstimatedConsumption() - const correctedConsumption = this.calculateWarmingCorrectedConsumption( - estimatedConsumption - ) + const correctedConsumption = + this.calculateWarmingCorrectedConsumption(estimatedConsumption) const monthConsumption = await this.calculateWarmingMonthConsumption( correctedConsumption, month @@ -420,10 +419,8 @@ export default class ProfileTypeService { fluidType: FluidType, month: number ): Promise<FluidForecast> { - const detailsMonthlyForecast: DetailsMonthlyForecast = await this.getDetailsMonthlyForecast( - fluidType, - month - ) + const detailsMonthlyForecast: DetailsMonthlyForecast = + await this.getDetailsMonthlyForecast(fluidType, month) let fluidLoad = 0 Object.values(detailsMonthlyForecast).forEach(load => { diff --git a/src/services/profileTypeEntity.service.ts b/src/services/profileTypeEntity.service.ts index f736f6a17..d05966216 100644 --- a/src/services/profileTypeEntity.service.ts +++ b/src/services/profileTypeEntity.service.ts @@ -135,12 +135,11 @@ export default class ProfileTypeEntityService { const { data: [doc], }: QueryResult<ProfileType[]> = await this._client.query(query.limitBy(1)) - const { - data: profileTypeEntity, - }: QueryResult<ProfileType | null> = await this._client.save({ - ...doc, - ...attributes, - }) + const { data: profileTypeEntity }: QueryResult<ProfileType | null> = + await this._client.save({ + ...doc, + ...attributes, + }) if (profileTypeEntity) { return this.parseProfileTypeEntityToProfileType(profileTypeEntity) } diff --git a/src/services/queryRunner.service.spec.ts b/src/services/queryRunner.service.spec.ts index 6a33687dd..d31b29f14 100644 --- a/src/services/queryRunner.service.spec.ts +++ b/src/services/queryRunner.service.spec.ts @@ -1139,14 +1139,12 @@ describe('queryRunner service', () => { skip: 0, } mockClient.query.mockResolvedValue(mockQueryResult) - const result: - | number - | Dataload - | null = await queryRunner.fetchFluidMaxData( - mockTimePeriod, - TimeStep.DAY, - FluidType.ELECTRICITY - ) + const result: number | Dataload | null = + await queryRunner.fetchFluidMaxData( + mockTimePeriod, + TimeStep.DAY, + FluidType.ELECTRICITY + ) expect(result).toBe(30.33) }) @@ -1174,14 +1172,12 @@ describe('queryRunner service', () => { mockClient.query .mockResolvedValueOnce(mockQueryResult) .mockResolvedValueOnce(mockQueryResult2) - const result: - | number - | Dataload - | null = await queryRunner.fetchFluidMaxData( - mockTimePeriod, - TimeStep.HALF_AN_HOUR, - FluidType.ELECTRICITY - ) + const result: number | Dataload | null = + await queryRunner.fetchFluidMaxData( + mockTimePeriod, + TimeStep.HALF_AN_HOUR, + FluidType.ELECTRICITY + ) expect(result).toBe(7.82) }) @@ -1209,14 +1205,12 @@ describe('queryRunner service', () => { mockClient.query .mockResolvedValueOnce(mockQueryResult) .mockResolvedValueOnce(mockQueryResult2) - const result: - | number - | Dataload - | null = await queryRunner.fetchFluidMaxData( - mockTimePeriod, - TimeStep.HALF_AN_HOUR, - FluidType.ELECTRICITY - ) + const result: number | Dataload | null = + await queryRunner.fetchFluidMaxData( + mockTimePeriod, + TimeStep.HALF_AN_HOUR, + FluidType.ELECTRICITY + ) expect(result).toBe(0) }) @@ -1230,14 +1224,12 @@ describe('queryRunner service', () => { }), } mockClient.query.mockRejectedValue(new Error()) - const result: - | number - | Dataload - | null = await queryRunner.fetchFluidMaxData( - mockTimePeriod, - TimeStep.DAY, - FluidType.ELECTRICITY - ) + const result: number | Dataload | null = + await queryRunner.fetchFluidMaxData( + mockTimePeriod, + TimeStep.DAY, + FluidType.ELECTRICITY + ) expect(result).toBeNull() }) @@ -1250,14 +1242,8 @@ describe('queryRunner service', () => { zone: 'utc', }), } - const result: - | number - | Dataload - | null = await queryRunner.fetchFluidMaxData( - mockTimePeriod, - TimeStep.DAY, - 99 - ) + const result: number | Dataload | null = + await queryRunner.fetchFluidMaxData(mockTimePeriod, TimeStep.DAY, 99) expect(result).toBeNull() }) @@ -1270,14 +1256,12 @@ describe('queryRunner service', () => { zone: 'utc', }), } - const result: - | number - | Dataload - | null = await queryRunner.fetchFluidMaxData( - mockTimePeriod, - 99, - FluidType.ELECTRICITY - ) + const result: number | Dataload | null = + await queryRunner.fetchFluidMaxData( + mockTimePeriod, + 99, + FluidType.ELECTRICITY + ) expect(result).toBeNull() }) }) diff --git a/src/services/queryRunner.service.ts b/src/services/queryRunner.service.ts index 1fae7902e..2a380c9cf 100644 --- a/src/services/queryRunner.service.ts +++ b/src/services/queryRunner.service.ts @@ -26,37 +26,8 @@ export default class QueryRunner { private readonly _max_limit = 1000 private readonly _default_months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] private readonly _default_days = [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, ] private readonly _client: Client diff --git a/src/services/quiz.service.ts b/src/services/quiz.service.ts index 06f8bec93..e67f12d15 100644 --- a/src/services/quiz.service.ts +++ b/src/services/quiz.service.ts @@ -148,14 +148,12 @@ export default class QuizService { const userQuestions: UserQuestion[] = [] quiz.questions.forEach(question => { - const userQuestion: UserQuestion = this.parseQuestionEntityToQuestion( - question - ) + const userQuestion: UserQuestion = + this.parseQuestionEntityToQuestion(question) userQuestions.push(userQuestion) }) - const userCustomQuestion: UserCustomQuestion = this.parseCustomQuestionEntityToCustomQuestion( - quiz.customQuestion - ) + const userCustomQuestion: UserCustomQuestion = + this.parseCustomQuestionEntityToCustomQuestion(quiz.customQuestion) const userQuiz: UserQuiz = { id: quiz.id, @@ -311,11 +309,12 @@ export default class QuizService { } if (customQuestionEntity.type === CustomQuestionType.DATE) { //Interval - const intervalAsnwer: IntervalAnswer = await this.getMaxLoadOnLastInterval( - customQuestionEntity.timeStep, - finalInterval, - useFluidType - ) + const intervalAsnwer: IntervalAnswer = + await this.getMaxLoadOnLastInterval( + customQuestionEntity.timeStep, + finalInterval, + useFluidType + ) answers = this.getAnswersForInterval( intervalAsnwer.date, customQuestionEntity.timeStep, diff --git a/src/services/terms.service.ts b/src/services/terms.service.ts index 2fea47dfd..11b578dd1 100644 --- a/src/services/terms.service.ts +++ b/src/services/terms.service.ts @@ -79,9 +79,8 @@ export default class TermsService { }), version: config.termsVersion, } - const { - data: createdTerm, - }: QueryResult<Term> = await this._client.create(TERMS_DOCTYPE, newTerm) + const { data: createdTerm }: QueryResult<Term> = + await this._client.create(TERMS_DOCTYPE, newTerm) return createdTerm } catch (error) { console.log('Error creating new term: ', error) diff --git a/src/services/triggers.service.spec.ts b/src/services/triggers.service.spec.ts index 4bf034287..46ff93de2 100644 --- a/src/services/triggers.service.spec.ts +++ b/src/services/triggers.service.spec.ts @@ -103,9 +103,8 @@ describe('TriggerService service', () => { }, } mockClient.getStackClient().fetchJSON.mockResolvedValueOnce(mockResult) - const result: TriggerState | null = await triggerService.fetchTriggerState( - triggersData[0] - ) + const result: TriggerState | null = + await triggerService.fetchTriggerState(triggersData[0]) expect(result).toEqual(triggerStateData) }) @@ -115,9 +114,8 @@ describe('TriggerService service', () => { data: { attributes: { current_state: null } }, } mockClient.getStackClient().fetchJSON.mockResolvedValueOnce(mockResult) - const result: TriggerState | null = await triggerService.fetchTriggerState( - triggersData[0] - ) + const result: TriggerState | null = + await triggerService.fetchTriggerState(triggersData[0]) expect(result).toBe(null) }) diff --git a/src/services/usageEvent.service.ts b/src/services/usageEvent.service.ts index 09f5bb929..429718650 100644 --- a/src/services/usageEvent.service.ts +++ b/src/services/usageEvent.service.ts @@ -140,9 +140,8 @@ export default class UsageEventService { const query: QueryDefinition = Q(USAGEEVENT_DOCTYPE) .where(filterParams) .sortBy([{ eventDate: desc ? 'desc' : 'asc' }]) - const { - data: usageEventEntities, - }: QueryResult<UsageEventEntity[]> = await client.query(query) + const { data: usageEventEntities }: QueryResult<UsageEventEntity[]> = + await client.query(query) const usageEvents: UsageEvent[] = usageEventEntities.map( (usageEventEntity: UsageEventEntity) => { return this.parseUsageEventEntityToUsageEvent(usageEventEntity) diff --git a/src/store/chart/chart.reducer.ts b/src/store/chart/chart.reducer.ts index 9830e6568..51e15ffb1 100644 --- a/src/store/chart/chart.reducer.ts +++ b/src/store/chart/chart.reducer.ts @@ -13,11 +13,9 @@ import { TimeStep } from 'enum/timeStep.enum' import { DateTime } from 'luxon' const initialState: ChartState = { - selectedDate: DateTime.local() - .endOf('minute') - .setZone('utc', { - keepLocalTime: true, - }), + selectedDate: DateTime.local().endOf('minute').setZone('utc', { + keepLocalTime: true, + }), currentTimeStep: TimeStep.WEEK, currentIndex: 0, currentDatachart: { actualData: [], comparisonData: null }, diff --git a/src/store/profileEcogesture/profileEcogesture.actions.ts b/src/store/profileEcogesture/profileEcogesture.actions.ts index ccf17080f..67379dd86 100644 --- a/src/store/profileEcogesture/profileEcogesture.actions.ts +++ b/src/store/profileEcogesture/profileEcogesture.actions.ts @@ -39,9 +39,8 @@ export function updateProfileEcogesture(upd: Partial<ProfileEcogesture>): any { { client }: { client: Client } ) => { const profileEcogestureService = new ProfileEcogestureService(client) - const updatedProfileEcogesture = await profileEcogestureService.updateProfileEcogesture( - upd - ) + const updatedProfileEcogesture = + await profileEcogestureService.updateProfileEcogesture(upd) if (updatedProfileEcogesture) { dispatch(updateProfileEcogestureSuccess(updatedProfileEcogesture)) } diff --git a/src/targets/browser/index.tsx b/src/targets/browser/index.tsx index 93fcbc519..d1e86be12 100644 --- a/src/targets/browser/index.tsx +++ b/src/targets/browser/index.tsx @@ -98,7 +98,7 @@ document.addEventListener('DOMContentLoaded', () => init()) // excludes Chrome, Edge, and all Android browsers that include the Safari name in their user agent const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent) if (!isSafari && 'serviceWorker' in navigator) { - window.addEventListener('load', function() { + window.addEventListener('load', function () { navigator.serviceWorker .register('/serviceWorker.js') .then(reg => console.log('service worker registered', reg.scope)) diff --git a/src/targets/services/aggregatorUsageEvents.ts b/src/targets/services/aggregatorUsageEvents.ts index 02e6098c0..c1cc3e14f 100644 --- a/src/targets/services/aggregatorUsageEvents.ts +++ b/src/targets/services/aggregatorUsageEvents.ts @@ -83,7 +83,7 @@ const sendIndicator = async ( const reduceEvents = ( events: UsageEvent[] ): { [key: string]: UsageEvent[] } => { - return events.reduce(function( + return events.reduce(function ( acc: { [key: string]: UsageEvent[] }, @@ -195,8 +195,9 @@ const calculSessionTime = async (events: UsageEvent[], client: Client) => { events[index - 1].type !== UsageEventType.CONNECTION_EVENT ) { const endDate = events[index - 1].eventDate - const duration = endDate.diff(startSessionDate, ['seconds']).toObject() - .seconds + const duration = endDate + .diff(startSessionDate, ['seconds']) + .toObject().seconds const sessionIndicator: Indicator = { createdBy: 'ecolyo', measureName: DaccEvent.SESSION_DURATION, @@ -220,8 +221,9 @@ const calculSessionTime = async (events: UsageEvent[], client: Client) => { } else if (index === events.length - 1) { if (startSessionDate) { const endDate = event.eventDate - const duration = endDate.diff(startSessionDate, ['seconds']).toObject() - .seconds + const duration = endDate + .diff(startSessionDate, ['seconds']) + .toObject().seconds const sessionIndicator: Indicator = { createdBy: 'ecolyo', measureName: DaccEvent.SESSION_DURATION, @@ -278,12 +280,10 @@ const calculPeriodBetweenChallenge = async ( (event: UsageEvent) => event.type === UsageEventType.CHALLENGE_LAUNCH_EVENT ) if (challengeLaunchEvents.length > 0) { - const allEndedChallengeEvents: UsageEvent[] = await UsageEventService.getEvents( - client, - { + const allEndedChallengeEvents: UsageEvent[] = + await UsageEventService.getEvents(client, { type: UsageEventType.CHALLENGE_END_EVENT, - } - ) + }) for (const event of challengeLaunchEvents) { if (event.target && event.target !== 'CHALLENGE0001') { const challengeId: number = toNumber( @@ -292,16 +292,18 @@ const calculPeriodBetweenChallenge = async ( const prevChallengeId = `CHALLENGE${(challengeId - 1) .toString() .padStart(4, '0')}` - const previousEndedChallengeIndex: number = allEndedChallengeEvents.findIndex( - (endedEvent: UsageEvent) => endedEvent.target === prevChallengeId - ) + const previousEndedChallengeIndex: number = + allEndedChallengeEvents.findIndex( + (endedEvent: UsageEvent) => endedEvent.target === prevChallengeId + ) if (previousEndedChallengeIndex > -1) { const periodChallengeIndicator: Indicator = { createdBy: 'ecolyo', measureName: DaccEvent.EVENT_DURATION, - startDate: allEndedChallengeEvents[ - previousEndedChallengeIndex - ].eventDate.toISODate(), + startDate: + allEndedChallengeEvents[ + previousEndedChallengeIndex + ].eventDate.toISODate(), value: event.eventDate.diff( allEndedChallengeEvents[previousEndedChallengeIndex].eventDate ).seconds, @@ -491,12 +493,13 @@ const getConsumptionValue = async ( endDate: analysisDate.minus({ month: 2 }).endOf('month'), }, } - const fetchedPerformanceIndicators = await consumptionService.getPerformanceIndicators( - periods.timePeriod, - TimeStep.MONTH, - fluidType, - periods.comparisonTimePeriod - ) + const fetchedPerformanceIndicators = + await consumptionService.getPerformanceIndicators( + periods.timePeriod, + TimeStep.MONTH, + fluidType, + periods.comparisonTimePeriod + ) return fetchedPerformanceIndicators } @@ -699,9 +702,7 @@ const sendHalfHourConsumption = async (client: Client) => { const data = await consumptionService.getLastHourData( client, - DateTime.local() - .minus({ month: 1 }) - .startOf('month').month + DateTime.local().minus({ month: 1 }).startOf('month').month ) const halfHourConsumption: Indicator = { @@ -740,14 +741,8 @@ const sendKonnectorEvents = async (client: Client) => { target: slug, result: 'success', eventDate: { - $lte: today - .endOf('month') - .minus({ month: 1 }) - .toString(), - $gte: today - .startOf('month') - .minus({ month: 1 }) - .toString(), + $lte: today.endOf('month').minus({ month: 1 }).toString(), + $gte: today.startOf('month').minus({ month: 1 }).toString(), }, }, true @@ -795,11 +790,8 @@ const sendKonnectorEvents = async (client: Client) => { } } - const allConnectionEvents: UsageEvent[] = await UsageEventService.getEvents( - client, - query, - true - ) + const allConnectionEvents: UsageEvent[] = + await UsageEventService.getEvents(client, query, true) const konnectorSuccess: Indicator = { createdBy: 'ecolyo', @@ -841,14 +833,8 @@ const sendKonnectorAttemptsMonthly = async (client: Client) => { type: UsageEventType.KONNECTOR_ATTEMPT_EVENT, target: slug, eventDate: { - $lte: today - .endOf('month') - .minus({ month: 1 }) - .toString(), - $gte: today - .startOf('month') - .minus({ month: 1 }) - .toString(), + $lte: today.endOf('month').minus({ month: 1 }).toString(), + $gte: today.startOf('month').minus({ month: 1 }).toString(), }, }, true diff --git a/src/targets/services/monthlyReportNotification.ts b/src/targets/services/monthlyReportNotification.ts index 6ba377a2a..5783eb072 100644 --- a/src/targets/services/monthlyReportNotification.ts +++ b/src/targets/services/monthlyReportNotification.ts @@ -42,12 +42,13 @@ const getConsumptionValue = async ( endDate: analysisDate.minus({ month: 2 }).endOf('month'), }, } - const fetchedPerformanceIndicators = await consumptionService.getPerformanceIndicators( - periods.timePeriod, - TimeStep.MONTH, - fluidType, - periods.comparisonTimePeriod - ) + const fetchedPerformanceIndicators = + await consumptionService.getPerformanceIndicators( + periods.timePeriod, + TimeStep.MONTH, + fluidType, + periods.comparisonTimePeriod + ) return fetchedPerformanceIndicators } @@ -178,9 +179,7 @@ const monthlyReportNotification = async ({ // Init mail token for user in case he don't have one if (!userProfil.mailToken || userProfil.mailToken === '') { - const token: string = require('crypto') - .randomBytes(48) - .toString('hex') + const token: string = require('crypto').randomBytes(48).toString('hex') try { await upm.updateProfile({ diff --git a/yarn.lock b/yarn.lock index 098e802da..879271ba6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13037,12 +13037,7 @@ prettier@1.18.2: resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea" integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw== -prettier@^1.19.1: - version "1.19.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" - integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== - -prettier@^2.5.1, prettier@^2.6.2: +prettier@^2.5.1, prettier@^2.6.2, prettier@^2.7.1: version "2.7.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== @@ -14366,9 +14361,9 @@ ripemd160@^2.0.0, ripemd160@^2.0.1: inherits "^2.0.1" rooks@^5.11.2: - version "5.11.5" - resolved "https://registry.yarnpkg.com/rooks/-/rooks-5.11.5.tgz#2644061a972c3d579c035331caaf60ebc809dc2d" - integrity sha512-ZArBm3K0Oosm02vuzQ9LDAJEnNDyKvr7z72tC77RWw3YNs4X+OMRlEKd0qWqo/irfnI3wph51wZ2rdVSuz3wEg== + version "5.11.6" + resolved "https://registry.yarnpkg.com/rooks/-/rooks-5.11.6.tgz#8ea93262f950f775bd131212b6167755e49162f4" + integrity sha512-qS6tlO2E28pwOu6/Pj98FKqbpvDAGyphAuFuqff8cS/7byf7SZlfCLievpzeWWj/v9Y5FGFYHbia10OlH+cJ0w== dependencies: lodash.debounce "^4.0.8" raf "^3.4.1" -- GitLab