diff --git a/.prettierrc b/.prettierrc index 83d4731a79ba8b5d27114e9fc0db0364bb03103a..08012e88dcedff56c24e3231c56b7e2210c8e2ff 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 2f63cf00fded0c81b07470d715bfd7c00b5006c3..b22cbe5066d29f9b56e08614ea271e52bc4b44f9 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 e8430a43bcc4d0ced37f1fca94cda4144f1e1a6b..d3294a161e28b0e80e8c050b281e93ec1f33fdf8 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 6076a3da0e25a1f2d8154568c956f4299409e794..afc9734f174bb23432660f46ee6ea36c767192dd 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 f59cfe61f12856fbc63e7b227ac25c43b6907ff1..748320be93efa459470c709d50a7bf510d8fc61a 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 2e909dad7f9bdfa7a3e8898539ea843f654b23d9..b5d5731bdc542a3abaa662515a8017512ef672e5 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 8e072fd7050f4e12771b6c805bead56d6d36db4f..29c27a23afa20af6ac35660e2bc30ae6d2616f19 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 cfc32d6fab7eafc6d80647902f6b6340b9b14ccc..4ae600afff45ff7b75fab5642e23d72ef8f07755 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 b5a9a0ed8c7944b0efbf34990b9fcaedfb7a85af..ddf95e7df910db9b83eba2e7430c300b6679b027 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 cb7a95266822e7f06bf4e2741315ca009bffb6dc..5253eaa6765133bc1ceb5f83ddb1ccb1039e30a8 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 1fbcf4bebf43199fbc9de40997bfd2ca7b796c4d..fb9eea498122754f72d2df482be6a41e06e0fc77 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 2a589da8f8f2ba16c067c01a98b870934a6d1fba..83fc2cfc6267fbc864b647591648d6e986906d36 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 6bc0b0db5935c6e8819af0705eef162c299a126a..866717ba5f698741665112769fdf6a01f0506f24 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 405dd753585707d8d499dfbe006da307c0bbe4df..e3830ee19ffd749cd38e36aa9123d00774f2a706 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 2b44b6209c4fd0b89e34212345f1eca13e96f1a5..efd24091194803c39bbc3b6813ce30bdb31e5a79 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 9ca28b01cd1cfcda03f8c091b997801b7a216dde..5e427339814e260898b1689f616628e4e9236927 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 299d2a4da67c4bdb964de2cc7608efca9c4dc1fe..02cfa8bca48d4c991fbeafdef5040fc8fb59bf77 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 3103495adc6741030fbe8755bca0c85e119020ea..644dcd3fab609c92cc504179649b0d3e17b07b38 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 bf2cf699dd5406776c9e7904849120c106294235..2ddf41589a393cecfcbc066aae5d5efaff276123 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 9349cf5284c3193003ea010af02042a8d2ecb846..4f7287762b7246b6a910a68bf6a061dadefa2b96 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 6bdb08685301b261b2f427e43df06265098d97f9..e1d7fc85945363e8bf894d4ef0ce7340cfd66b8e 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 f90d1834703b5f467bfe866b9afa1fd83b6168f1..22c9a2f9d376cfc4da5c088bf102268b51593210 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 0b1c7d76c21944b23b22e47d80bf9e35fcad4221..585f18b1b92b6cb4bae8bbf8eb50ddcb52c01b9d 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 76e3f1a904e5acacd18d15a52192dead5ad2b7fb..84c59fb729c26951e627bb8e16e6abb5d99494f6 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 eb9e5475c382904a1e30df7680c9c07f0545b744..57dad61b73ea1055620af3b7fbe9f44bd13f956c 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 4ece0f1ea3cd76e608f429e5423707d45538486b..ae572a9ebc7ab629c580e9fd61e014ec51b825ed 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 97e56a07737753752f745f554fb45e74db0accda..a87eaa1b76daa3a7a29db8c549421105b9b7a26a 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 e5e94863b03e0a687dbb1d88b052d31dad6967e0..d24a9512e494e5546809e58163c9570284330b65 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 915201412ac71bf8bea5f7d2554752b6671fdbc2..a517038943eb0573b83e3a2c183a8c20874a8007 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 0f4931663ffa367e3b71262e2502828180057af7..b52ebe5644ccd1d9d1152c00cb57763d9339c2e8 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 c184fa7155e7936461b9487879ddf58e7829c9d5..38251f47a1f45160ba09fc5ce83354b676a330a8 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 11d88685726a9b85c7e6aa98dad3b06a19564283..11007d24c1da41a0801b87ef401646ba4c4a66a6 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 d8ff32d39c3499893d0e514f1a7188d12306ed1c..74f271ffd71581b9e202aff8bcb5fa1fc0637989 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 0297049b01392e1e2713f8f5d6f504349070b92e..4181b6a2ebccde40cdd799e5df89b08349f84fcf 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 05504108fbfba0ac81ca663d93355979fbf46bc5..bfa2adf669b49e918aaea35a329ded17f0b74871 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 6ab0e3bdd0851dc9d436848b507626bcbefd9d12..ff14f1f74173d11f91fc91a5861725c5eaf6dd88 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 cde3182efe7e14ba7dbc605b92c323c60b2911b3..74b23a0543a853eac78a4ee6f0b2d967ec14ab56 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 1093a09a8df46b210f413ec0e7e223b13c53ada5..c6318f0fc9b76f936c2da157e13bfcd5374f3814 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 298dd9d9330ba76d3dc56029d2361bd98ff31a7b..ed59dc9cb4583e1bfa5df52f01ea136e99926d84 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 f56bd2f2352d1207de14f95851f41a095c44d8b7..e0ab6d225753f18c4b336200e5e58ed41beece17 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 cc3aa53c2f1d236f4b98e0b595046c4f2fa0c2e5..b62290252e0b1148e071f4dc42d6e3272a9412f9 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 afd4096cc011e072107f3918ecff3dfc69cf08e2..05f9f3cf7953ef73a7f3b1e53021c0aea41dff43 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 ae4e3360ee6982f4c34bbc59f26ad5c20eebfa3a..b70a8f41f32171d533b46b873cf88b5f394aed6b 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 9267cccc37994269bccc4368aadfc3a63d02acc2..82af5587ee2d8c667ba8b8a93a01af78c27dbb9e 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 536dcb3817aa92add426165d4cde497eb1c7d746..c98ae70938cafcd87d014c33995974e2612d4290 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 09853bbc8a422791d0904b682afb394fb5d7b993..f86f26f4ded285cbc6c24755055ace4a1eadd8e2 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 7dfa7f922b5d8feaaf630112efdb69031dce99f6..0a86e6bb37e37c13ddb29c0a45c33bf6c259d453 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 cb07519ce15b54b21fb914f1e883c49c65011351..23dda80906d54d6babef45b41a01ca1238e0eba7 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 33e0bbaa3353ddc921f2c51f812acf57a768c02b..c41160d25732bac5a45416d1128c9ff9a16fecaf 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 8e341372ed4226b931de772f7b08f05bcbb777bc..701193a4d9f3d7b9c13cf22844b955380c97abbe 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 870a7719f2f41255ae25139eed4697dbca61b211..4af2bd0578095060417717d47a94cc0d67bb2df6 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 73075d03ba3a7864e6656e41eb7440d061da4124..b3503365c5ff2d2eed4b8b788b18af26c627cdb8 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 58b4685381bb323a08acf5c0f7511f03049e464d..3f1835b689348d93c3cb1b3fbf6fbcafe910c761 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 acf9914d843657e48536ba121d006d7daa61b0e5..76557e2c0346a38cfd1fb4147e14b9cd7d10b104 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 58298416b24af5ea215c12f0f7c65d583819e51a..5a54053636e6bbeb64667845e781126b71c0c759 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 2574e4d7dd61161629e2bd1ec0adf64e2326707e..e510abed50c1cae5f10496562cc7e5907348ccd5 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 31650c119d1e0ea221dbed1d74ceccd2a8a0b089..3a5a63748ee16066ca0b263c49899a9950e8fe59 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 161f7e01e7b5e6fdc1cc399f60c994cff1f2f79c..e24c47f472b1d04c783a36a042affd8fa4c6c2f2 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 70d90112c326f5312d29f9162f591a0466f1e81c..7b79865dec3e577616cd4c72a26ad0416f8d6dc4 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 2e612a0935dcd2cfe5913544793da432a8a3fd3a..16c35eb6696054095afc56adc62c93e317a4289f 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 5e59a39939b69721ba9c81c757ca166267182c7d..3aab69e60e9d74357fee306a45a6702effc59c42 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 9902d21d2fabe01e8dcc6c2cb11b177bb86e967e..ac64219d36b8a0a79c44dc362d81e60942594350 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 39cae3cf2cd42eab8bf2871af6ed3a0c6b5290ff..c0e14b19c0704659906fdda1954122bf0dde4693 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 b23c5f5fd9534baa80596c20522d52bca48f3222..c3f19abf018095c5df960ba48c8c7fdd5185c324 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 c830ad75ddc00145c4e353c7cb01fa9cb1fa78b6..b87e6632f3191d4c3158e0cb5ac0659408ecc138 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 441ab394586a86fa504c7edafedb5ccffa583130..07be998ffe070da06a074117d7a28b891c5e0bd8 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 9be659c49a17cfdd18097956870a6f3a710e9a07..9c46bca76a57a7ca522fc35693d1ef3aadab36fd 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 6b3690acebe086c380791263f529030f28367ae6..e9e76356b6fd67b89366fe4504cc1e67421adc9f 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 dea8c9317f72766a0a96237a947e22192d091127..639467f227a40ea43aeef30f4959f982ee1b093c 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 fc6cac7487ab47e31ba255c58b8cfc9fbf15d02d..f97b6ddad87824400d8cd65bfa56ad4336ba3a78 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 5a74cb99020ea89de6f4aaf77990b3bbae8f1cbb..0a5778ad3741afaf1cd7afc9c7aff452e0e1e061 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 07dc5f128739b16960a82d4f4a8e0d5130078258..c8b94ee62e07f54d9ce5bcc19f3f054cef2c5851 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 70988ddd09907e998b20ebcc7537f6ef87d080c1..a5f41c520ba150dd70a0261ef650d8603f17ee0e 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 44380016085d123a1729f10fb9755bee2f04ebe9..e9df3d07bee2348c36219eb3d9c40da781de5780 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 01d0dc8bb12c8685352e454582c43be99528148f..fbb34ae60ebc1375821ed973657ef5e71d22a3d0 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 60f540a189cae15d509f1f49d466241cf8dc1b3a..3f49551416a5157ce23a376a804ce02e7c0ab34b 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 be6a82b0c28f9351c09d2526f2240e8cef9e9ae1..24832b694861de70e83e7578e9ef7465a728ff66 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 05b3b77afb774d9bae601360d4f3ee7f88c974e5..9b85807d035ec1d65d5ecee9f225a95a8d867620 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 93b0da660df1546a047e68b22061e1d4f9df0a44..57ea92b703bba66b17ba70319281aed606736593 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 9f8ffeabe2960d4611e7ff8c40fe9b706ef49301..2979bb1723adb28a352f9b91c58f07acaf327500 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 0c6265ad526d1a59fb073307c6e6c64c5a21c5ae..d39461b166bd3daaa16cc94b1ad251a615a9b90b 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 7a64b883e531d8189bddfefb4d8b2f029ba638d9..49de9edb4eb2b6fcf59393070300cb5d8a53f9c8 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 e48e0119ac50365a3058a6d48308e806891d939c..87db1ca281596c8f7d95d1c0f6f7c10337c6c8a5 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 ef2fe161ea6431c27ded24d9f2e2142cb2884650..c543f5809667a2558d3044b8954173ee74fa3e29 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 1f883ae3d984c4a3069c2b6d62d1649b64837e4f..bd42f8cb1c5e6d7a0811976e03db307f3815fce4 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 b3dd91a167f6b825c55e6de1e3833368bbf45ace..7306c22ead912f313ed0e9981c1cf66208412fd8 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 bc1d6bed89ed31d2f091204026a4227e485e6661..689dfb025c5d0e83a1de18b3d0f549bf30b00c7e 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 f443f7554c6f407f9796426952ca2c0e5b5afa5d..ef3ebff54b6f3b1e75c67ade7af37ad68bc7b91a 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 c9e2e7ead09607fefaedf9efe1ac8b10f25eac1f..cbd096f86dac2bf5dfd7ca944a9231df3a6737f3 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 2ef690160c189e3ebdb4e48c649719fa749dfd04..0df72fa29592f663f831c2fd2a2e6a36f54200cf 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 8a7c4db8835ca3277fbbc3015a42bf906bed7977..9beb6cac6acdc54f0d3d45ac5383d72827928bc0 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 0ea4a279188aa94cf44f7550406d762d17ad9b5a..2d9af53b853e492e69ccd2bfdd3546e7e8e54965 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 8aa6a66517f64a4fbb6e35a50d96c6c36eba0795..d3bcf1fa2e16188ff33000a2b614b67e87facce4 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 6de439369b1aa3ebcbc893c93153b324350c57fa..ad193b4bd3d4514bb6ff610426da5d60c48012a9 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 bba282e95f88b546d9b6eee306acc50f93ccd73b..472e416abd8ab2ee9a3d55bee9436ee07b7534cc 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 27db0e30d8a475ce1cd80d00287f0e39b86c1593..75e9b9ef5d97f8cde7d3b42e51f33c0d0297e5e7 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 2d0f7e44959c60cc57f70512bfcaf54a777644c8..b8f32bd0a043b1cd9575b62e121e5eee5da51fbb 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 2065ff8660ac480d237dc46afa76d4a5bd650eeb..d9ed8ddc31cc1717d55ed4f4fbe542693ece0831 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 17f756396e9b4817d3ca7e5ca57e460d6a6bcf8d..9c86319a2757444fb967a71373b1956e4f80574f 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 70643ede1a7ed7f100d945bba3e473a9dcf630bc..2383d7f14c6c55f9af7b6c3f7a79dee6e7b5db62 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 4af58ec04f0dbd6bd5ffb96797821ca051e22401..da5d176ae51005990c9865d4fb1a9317f880e3b7 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 6fc4b25a30c3b479e0c584e6650f335622a8422c..ddcac6f746b07b351f96fcdc7df2fb058db9ba51 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 c5eb07f5317e169e5d690b18c6fc814c5d303ab0..21583ae6027664679276e5dcee4a8102f0f70e9c 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 107b36b21b472a9de08e267d02466a27b8d771eb..2706147c011d5b1645cd92ff69d76242d1b0ab4a 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 2a27a7681dbc113401dd445e7a8bfb16bc103d22..293661219a71c39b02c1b53d47e5f37392e2cc40 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 6bb1f0f67e78db16e12934d17f01a5bead39b154..6552c7e26ee6a2de0391699086b833958c447007 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 82bf4af528a04073afd4d2511898bd716a9cc0eb..817eac1b6677e1454cd95876aa570148a1cb9760 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 0de5cd9e37f5087d3d6dca8b0a07924f02b551b7..393699d1b05cc5f4fe7172349b980811283f739c 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 d75145f0828afe499b12c25b6891c4d273ea2eb6..8979264f297f885402919ef57978e1fc3a61f431 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 84f916c3fe96a891ef0d9f1e78bfff5ed4ba1efc..0fc57ff75717bb3f42daf238c84fef26c0446061 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 af2a1acff31a454c01a22d8dce29ffa10d1db562..062014b5cbe5f7212079f08311af489529e39fb9 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 5569acc917698f01b0492261d7c48613f0a81f3c..c7724830513e8555585bad28d826c9ca929cf836 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 48d95edb36b804bf98b157c6c1e7bf75798e49eb..c4c4c3615ea8d5e7f2e4c342ef19a37be1649d7a 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 78e02c12a492be297e3fda21548443b9f985ec40..d154d1f88bcb7d1423b8c8d5ab8d4b010d343f22 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 37f1ad53180bbfa7f6656de89e9c4f7690a9aad4..5b16ad5391d0031d9f1e0744bebb472e6461dd73 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 69aaaade29377e280845288b9bd1a137607ac7e4..07f198a26194f7349aac3c43233fe84a3febb10f 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 c3cac0a58e72ea131dbe30369473f6b8aecc2bb7..cb046dd2a6b4b0876a0878b1ad95fa871e0e8772 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 32a7c72cad7e3b8115073a6a0872b589422dfb9d..cee6ea3843d0e000a08e6d42315e1bd4f8c524df 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 6913923dbcbb8c2cc0bb3040508b8c5b868724e6..37d5b0e857a6149245455eb7050387d3a7cd73ec 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 68c0cb5748bc087ed15a1ea2fbe41e8173f45b2e..d13bb7b4ab16cbbedbb6096b582ee6cf8a204d94 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 5ce0179da5ab78063e0e7706387d1beaf48b64a6..23a52afccfe73abe460ca8975f08eaff18ab0c0d 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 f736f6a17be96ae2290243228e58fe1c45b64a12..d059662167a1efdb24bfa79a3e707e54b2fd69ac 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 6a33687dd396695377165746c8cb4a495205ffad..d31b29f14b017a83ed22c399cd5bd589ad1dc8b6 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 1fae7902ebd897dd3a8f10ddc5d88faa75e9c8b2..2a380c9cfbd6aa1ebd1f73f0d1f05647bbd8eabe 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 06f8bec93de2ae73446ab89b0e208580c26436c2..e67f12d15ebbf9c88f22a3210a13589b8c3f9480 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 2fea47dfd79bf0bdbd9aca89a502a72f0256dacf..11b578dd1307498fc755385fce6ee981bd818afe 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 4bf034287a3abbf692655727aa9f10d26dfb9e40..46ff93de25401813253bd16e18f446317ffc9414 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 09f5bb92927262523542286e3abd1131ff4f7816..4297186503a3d73d9c62ab710aa0b6f5e749c4c4 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 9830e6568b21278bfee5d2854730a12e906e815b..51e15ffb123a7bff4ce1281e19950161ce68d4a5 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 ccf17080f183958a421ebb0008c7879acbcd16dc..67379dd86b762c40fc032b2d5f149b45b33b7aad 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 93fcbc519c14ef21dabe8e3e9b6e99c24f0a4516..d1e86be12e9e35ea6b5cd2946f0e108a69ec9e14 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 02e6098c02086f518559052850b98c4df1fbaee8..c1cc3e14f09ba8ede239372b4e222621bb233b13 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 6ba377a2a426f2111e005ba7fdde5c193620e461..5783eb072ff2de58d7b5f182211773f2de0fbcdc 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 098e802da75c97e0bd4149cf1ccf46c81b0edece..879271ba671e41920e504db67a1801163a345035 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"