From 9abd05d4d4b33fadbcce32df1896646a95aa7983 Mon Sep 17 00:00:00 2001 From: Bastien DUMONT <bdumont@grandlyon.com> Date: Mon, 25 Sep 2023 12:35:50 +0000 Subject: [PATCH] chore(eslint): add jest/recommended linting rules --- .eslintrc.js | 9 +- .vscode/settings.json | 1 + package.json | 3 +- .../Action/ActionBegin/ActionBegin.spec.tsx | 6 +- .../Action/ActionDone/ActionDone.spec.tsx | 2 +- .../Action/ActionList/ActionList.spec.tsx | 6 +- .../Action/ActionModal/ActionModal.spec.tsx | 2 +- src/components/Analysis/AnalysisView.spec.tsx | 4 +- .../ProfileComparator.spec.tsx | 2 +- .../ChallengeCardDone.spec.tsx | 10 +- .../ChallengeCardLast.spec.tsx | 2 +- src/components/Charts/Bar.spec.tsx | 2 +- .../ConsumptionDetails.spec.tsx | 4 +- .../Consumption/ConsumptionView.spec.tsx | 2 +- .../DataloadNoValue.spec.tsx | 2 +- .../DataloadSectionValue.spec.tsx | 2 +- src/components/Duel/DuelView.spec.tsx | 2 +- .../EcogestureInitModal.spec.tsx | 2 +- .../EcogestureList/EcogestureList.spec.tsx | 2 +- .../EcogestureFormEquipment.spec.tsx | 2 +- .../Feedback/FeedbackModal.spec.tsx | 2 +- .../TimeStepSelector.spec.tsx | 10 +- .../Modals/exportDoneModal.spec.tsx | 2 +- .../Modals/exportLoadingModal.spec.tsx | 2 +- .../Modals/exportStartModal.spec.tsx | 2 +- .../ReportOptions/ReportOptions.spec.tsx | 6 +- .../QuizQuestionContentCustom.spec.tsx | 11 +- .../WelcomeModal/WelcomeModal.spec.tsx | 4 +- src/migrations/migration.service.spec.ts | 20 +- src/migrations/migration.spec.ts | 16 +- src/services/account.service.spec.ts | 28 ++- src/services/challenge.service.spec.ts | 41 ++-- src/services/challenge.service.ts | 15 +- .../consumptionFormatter.service.spec.ts | 10 +- .../consumptionValidator.service.spec.ts | 28 +-- ...ce.test.ts => customPopup.service.spec.ts} | 3 +- src/services/customPopup.service.ts | 2 +- src/services/dateChart.service.spec.ts | 19 +- src/services/duel.service.spec.ts | 10 +- src/services/ecogesture.service.spec.ts | 10 +- src/services/exploration.service.spec.ts | 10 +- src/services/fluidsPrices.service.spec.ts | 33 ++-- src/services/initialization.service.spec.ts | 28 +-- src/services/partnersInfo.service.spec.ts | 7 +- src/services/partnersInfo.service.ts | 2 +- src/services/queryRunner.service.spec.ts | 2 +- src/services/quiz.service.spec.ts | 10 +- src/services/timePeriod.service.spec.ts | 39 ++-- src/services/triggers.service.spec.ts | 23 ++- src/services/usageEvent.service.spec.ts | 10 +- src/services/usageEvent.service.ts | 21 +- src/store/challenge/challenge.slice.spec.ts | 6 +- src/store/chart/chart.slice.spec.ts | 87 --------- src/utils/date.spec.ts | 6 +- src/utils/utils.spec.ts | 6 +- tests/__mocks__/testUtils.ts | 19 ++ yarn.lock | 183 +++++++++++++----- 57 files changed, 413 insertions(+), 387 deletions(-) rename src/services/{customPopup.service.test.ts => customPopup.service.spec.ts} (95%) diff --git a/.eslintrc.js b/.eslintrc.js index ee2350f23..808f52d66 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -29,8 +29,15 @@ module.exports = { '@typescript-eslint/no-var-requires': 'off', }, }, + { + files: ['**/*.spec.{ts,tsx}'], + extends: ['plugin:jest/recommended'], + rules: { + 'jest/no-mocks-import': 0, + }, + }, ], - plugins: ['@typescript-eslint', 'react', 'react-hooks'], + plugins: ['@typescript-eslint', 'react', 'react-hooks', 'jest'], parser: '@typescript-eslint/parser', // Specifies the ESLint parser parserOptions: { ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features diff --git a/.vscode/settings.json b/.vscode/settings.json index 9b958d5bd..e0492b209 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -47,6 +47,7 @@ "sonarlint.connectedMode.project": { "projectKey": "ecolyo" }, + "gitlens.remotes": [{ "type": "GitLab", "domain": "forge.grandlyon.com" }], "cSpell.language": "fr,en", "cSpell.words": [ "authform", diff --git a/package.json b/package.json index c78c84c4f..973f9bc6b 100644 --- a/package.json +++ b/package.json @@ -115,8 +115,9 @@ "enzyme": "3.11.0", "enzyme-adapter-react-16": "1.15.6", "enzyme-to-json": "^3.6.2", - "eslint": "^8.36.0", + "eslint": "^8.49.0", "eslint-config-prettier": "^8.8.0", + "eslint-plugin-jest": "^27.2.3", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-react": "7.32.2", "eslint-plugin-react-hooks": "^4.6.0", diff --git a/src/components/Action/ActionBegin/ActionBegin.spec.tsx b/src/components/Action/ActionBegin/ActionBegin.spec.tsx index 2c05f3c11..68c77e405 100644 --- a/src/components/Action/ActionBegin/ActionBegin.spec.tsx +++ b/src/components/Action/ActionBegin/ActionBegin.spec.tsx @@ -69,7 +69,7 @@ describe('ActionBegin component', () => { await waitForComponentToPaint(wrapper) expect(wrapper.find('.action-title').text()).toBe('Coup de vent') }) - it('should render chosen action ', async () => { + it('should render chosen action', async () => { const store = createMockEcolyoStore({ global: { ...mockGlobalState, fluidTypes: [0, 1, 2] }, profile: mockProfileState, @@ -87,7 +87,7 @@ describe('ActionBegin component', () => { await waitForComponentToPaint(wrapper) expect(wrapper.find(ActionBegin).exists()).toBeTruthy() }) - it('should open launch Modal ', async () => { + it('should open launch Modal', async () => { const store = createMockEcolyoStore({ global: { ...mockGlobalState, fluidTypes: [0, 1, 2] }, profile: mockProfileState, @@ -107,7 +107,7 @@ describe('ActionBegin component', () => { expect(wrapper.find(ActionModal).exists()).toBeTruthy() expect(wrapper.find(ActionModal).prop('open')).toBeTruthy() }) - it('should go to the list ', async () => { + it('should go to the list', async () => { const store = createMockEcolyoStore({ global: { ...mockGlobalState, fluidTypes: [0, 1, 2] }, profile: mockProfileState, diff --git a/src/components/Action/ActionDone/ActionDone.spec.tsx b/src/components/Action/ActionDone/ActionDone.spec.tsx index 0716cc3b7..768da1998 100644 --- a/src/components/Action/ActionDone/ActionDone.spec.tsx +++ b/src/components/Action/ActionDone/ActionDone.spec.tsx @@ -45,6 +45,6 @@ describe('ActionDone component', () => { ) wrapper.find(Button).first().simulate('click') await waitForComponentToPaint(wrapper) - expect(updateChallengeSpy).toBeCalledTimes(1) + expect(updateChallengeSpy).toHaveBeenCalledTimes(1) }) }) diff --git a/src/components/Action/ActionList/ActionList.spec.tsx b/src/components/Action/ActionList/ActionList.spec.tsx index e243a3a28..aad7a7a4c 100644 --- a/src/components/Action/ActionList/ActionList.spec.tsx +++ b/src/components/Action/ActionList/ActionList.spec.tsx @@ -7,6 +7,7 @@ import { mockChallengeState, mockProfileState, } from 'tests/__mocks__/store' +import { waitForComponentToPaint } from 'tests/__mocks__/testUtils' import ActionCard from '../ActionCard/ActionCard' import ActionList from './ActionList' @@ -21,7 +22,7 @@ jest.mock('services/action.service', () => { }) describe('ActionList component', () => { - it('should be rendered correctly', () => { + it('should be rendered correctly', async () => { mockGetDefaultActions.mockResolvedValueOnce(defaultEcogestureData) const store = createMockEcolyoStore({ challenge: { ...mockChallengeState }, @@ -33,6 +34,7 @@ describe('ActionList component', () => { <ActionList setSelectedAction={jest.fn()} setShowList={jest.fn()} /> </Provider> ) - expect(wrapper.find(ActionCard).exists()) + await waitForComponentToPaint(wrapper) + expect(wrapper.find(ActionCard)).toBeTruthy() }) }) diff --git a/src/components/Action/ActionModal/ActionModal.spec.tsx b/src/components/Action/ActionModal/ActionModal.spec.tsx index 9f54ea0a1..4507b4c42 100644 --- a/src/components/Action/ActionModal/ActionModal.spec.tsx +++ b/src/components/Action/ActionModal/ActionModal.spec.tsx @@ -56,6 +56,6 @@ describe('ActionModal component', () => { ) wrapper.find(Button).first().simulate('click') await waitForComponentToPaint(wrapper) - expect(updateChallengeSpy).toBeCalledTimes(1) + expect(updateChallengeSpy).toHaveBeenCalledTimes(1) }) }) diff --git a/src/components/Analysis/AnalysisView.spec.tsx b/src/components/Analysis/AnalysisView.spec.tsx index 6045ccf90..6c2515b5b 100644 --- a/src/components/Analysis/AnalysisView.spec.tsx +++ b/src/components/Analysis/AnalysisView.spec.tsx @@ -67,11 +67,11 @@ describe('AnalysisView component', () => { expect(wrapper.find('mock-header').exists()).toBeTruthy() expect(wrapper.find('mock-datenavigator').exists()).toBeTruthy() expect(wrapper.find('mock-monthlyanalysis').exists()).toBeTruthy() - expect(updateProfileSpy).toBeCalledTimes(1) + expect(updateProfileSpy).toHaveBeenCalledTimes(1) expect(updateProfileSpy).toHaveBeenCalledWith({ haveSeenLastAnalysis: true, }) - expect(toggleAnalysisNotificationSpy).toBeCalledTimes(1) + expect(toggleAnalysisNotificationSpy).toHaveBeenCalledTimes(1) expect(toggleAnalysisNotificationSpy).toHaveBeenCalledWith(false) }) }) diff --git a/src/components/Analysis/ProfileComparator/ProfileComparator.spec.tsx b/src/components/Analysis/ProfileComparator/ProfileComparator.spec.tsx index e3d8ffd7a..8bb603abf 100644 --- a/src/components/Analysis/ProfileComparator/ProfileComparator.spec.tsx +++ b/src/components/Analysis/ProfileComparator/ProfileComparator.spec.tsx @@ -205,6 +205,6 @@ describe('AnalysisConsumption component', () => { ) await waitForComponentToPaint(wrapper) wrapper.find(Button).first().simulate('click') - expect(mockedNavigate).toBeCalledWith('/profileType') + expect(mockedNavigate).toHaveBeenCalledWith('/profileType') }) }) diff --git a/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.spec.tsx b/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.spec.tsx index 22af2203e..21a0b674c 100644 --- a/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.spec.tsx +++ b/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.spec.tsx @@ -49,11 +49,11 @@ describe('ChallengeCardDone component', () => { ) wrapper.find(Button).last().simulate('click') await waitForComponentToPaint(wrapper) - expect(mockDispatch).toBeCalledTimes(1) - expect(mockDispatch).toBeCalledWith({ + expect(mockDispatch).toHaveBeenCalledTimes(1) + expect(mockDispatch).toHaveBeenCalledWith({ type: 'challenge/updateUserChallengeList', }) - expect(mockUpdateUserChallenge).toBeCalledTimes(1) + expect(mockUpdateUserChallenge).toHaveBeenCalledTimes(1) }) it('should not reset challenge if another challenge is on going', async () => { mockAppDispatch.mockImplementationOnce(() => mockDispatch) @@ -69,8 +69,8 @@ describe('ChallengeCardDone component', () => { ) wrapper.find(Button).last().simulate('click') await waitForComponentToPaint(wrapper) - expect(mockDispatch).toBeCalledTimes(0) - expect(mockUpdateUserChallenge).toBeCalledTimes(0) + expect(mockDispatch).toHaveBeenCalledTimes(0) + expect(mockUpdateUserChallenge).toHaveBeenCalledTimes(0) }) it('should be primary button is challenge is lost', async () => { const wrapper = mount( diff --git a/src/components/Challenge/ChallengeCardLast/ChallengeCardLast.spec.tsx b/src/components/Challenge/ChallengeCardLast/ChallengeCardLast.spec.tsx index b711bf01d..7cd4d37df 100644 --- a/src/components/Challenge/ChallengeCardLast/ChallengeCardLast.spec.tsx +++ b/src/components/Challenge/ChallengeCardLast/ChallengeCardLast.spec.tsx @@ -17,7 +17,7 @@ describe('ChallengeCardLast component', () => { const wrapper = mount(<ChallengeCardLast />) wrapper.find('.btn_lastCard').first().simulate('click') - expect(window.open).toBeCalledTimes(1) + expect(window.open).toHaveBeenCalledTimes(1) expect(global.open).toHaveBeenCalledWith( `${__SAU_IDEA_DIRECT_LINK__}?version=0.0.0` ) diff --git a/src/components/Charts/Bar.spec.tsx b/src/components/Charts/Bar.spec.tsx index 85e8adfc9..e1de4c716 100644 --- a/src/components/Charts/Bar.spec.tsx +++ b/src/components/Charts/Bar.spec.tsx @@ -130,7 +130,7 @@ describe('Bar component test', () => { </Provider> ) wrapper.find('rect').first().simulate('click') - expect(setSelectedDateSpy).toBeCalledTimes(1) + expect(setSelectedDateSpy).toHaveBeenCalledTimes(1) expect(setSelectedDateSpy).toHaveBeenCalledWith( graphData.actualData[0].date ) diff --git a/src/components/Consumption/ConsumptionDetails/ConsumptionDetails.spec.tsx b/src/components/Consumption/ConsumptionDetails/ConsumptionDetails.spec.tsx index 6268e2f34..939ab0b35 100644 --- a/src/components/Consumption/ConsumptionDetails/ConsumptionDetails.spec.tsx +++ b/src/components/Consumption/ConsumptionDetails/ConsumptionDetails.spec.tsx @@ -20,7 +20,7 @@ describe('ConsumptionDetails component', () => { expect(toJson(wrapper)).toMatchSnapshot() }) - it('should not render connection card ', () => { + it('should not render connection card', () => { const wrapper = mount( <Provider store={store}> <ConsumptionDetails fluidType={FluidType.MULTIFLUID} /> @@ -28,7 +28,7 @@ describe('ConsumptionDetails component', () => { ) expect(wrapper.contains('.fluidcard-link')).toBeFalsy() }) - it('should render one connection card ', () => { + it('should render one connection card', () => { const wrapper = mount( <Provider store={store}> <ConsumptionDetails fluidType={FluidType.MULTIFLUID} /> diff --git a/src/components/Consumption/ConsumptionView.spec.tsx b/src/components/Consumption/ConsumptionView.spec.tsx index bb036742c..75ce5755c 100644 --- a/src/components/Consumption/ConsumptionView.spec.tsx +++ b/src/components/Consumption/ConsumptionView.spec.tsx @@ -132,7 +132,7 @@ describe('ConsumptionView component', () => { <ConsumptionView fluidType={FluidType.GAS} /> </Provider> ) - expect(setCurrentTimeStepSpy).toBeCalledTimes(1) + expect(setCurrentTimeStepSpy).toHaveBeenCalledTimes(1) expect(setCurrentTimeStepSpy).toHaveBeenCalledWith(TimeStep.WEEK) }) diff --git a/src/components/ConsumptionVisualizer/DataloadNoValue.spec.tsx b/src/components/ConsumptionVisualizer/DataloadNoValue.spec.tsx index 28f63e557..8d9f06183 100644 --- a/src/components/ConsumptionVisualizer/DataloadNoValue.spec.tsx +++ b/src/components/ConsumptionVisualizer/DataloadNoValue.spec.tsx @@ -109,6 +109,6 @@ describe('DataloadNoValue component', () => { /> ) wrapper.find('.dataloadvisualizer-content').simulate('click') - expect(mockSetActive).toBeCalledWith(true) + expect(mockSetActive).toHaveBeenCalledWith(true) }) }) diff --git a/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx b/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx index 799209817..f29778ada 100644 --- a/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx +++ b/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx @@ -105,7 +105,7 @@ describe('DataloadSectionValue component', () => { /> ) wrapper.find('.estimated').simulate('click') - expect(mockToggleEstimationModal).toBeCalled() + expect(mockToggleEstimationModal).toHaveBeenCalled() }) }) }) diff --git a/src/components/Duel/DuelView.spec.tsx b/src/components/Duel/DuelView.spec.tsx index 80a35498f..9908eb501 100644 --- a/src/components/Duel/DuelView.spec.tsx +++ b/src/components/Duel/DuelView.spec.tsx @@ -77,7 +77,7 @@ describe('DuelView component', () => { expect(wrapper.find(DuelError).exists()).toBeTruthy() }) - it('should be rendered with DuelError component when current challenge with state != duel ', () => { + it('should be rendered with DuelError component when current challenge with state != duel', () => { const updatedUserChallenge = { ...userChallengeData[1], state: UserChallengeState.ONGOING, diff --git a/src/components/Ecogesture/EcogestureInitModal/EcogestureInitModal.spec.tsx b/src/components/Ecogesture/EcogestureInitModal/EcogestureInitModal.spec.tsx index 9f527a984..7f0411500 100644 --- a/src/components/Ecogesture/EcogestureInitModal/EcogestureInitModal.spec.tsx +++ b/src/components/Ecogesture/EcogestureInitModal/EcogestureInitModal.spec.tsx @@ -17,7 +17,7 @@ describe('EcogestureInitModal component', () => { ) expect(toJson(wrapper)).toMatchSnapshot() }) - it('should close modal ', () => { + it('should close modal', () => { const wrapper = mount( <EcogestureInitModal open={true} diff --git a/src/components/Ecogesture/EcogestureList/EcogestureList.spec.tsx b/src/components/Ecogesture/EcogestureList/EcogestureList.spec.tsx index e51a18972..10780f017 100644 --- a/src/components/Ecogesture/EcogestureList/EcogestureList.spec.tsx +++ b/src/components/Ecogesture/EcogestureList/EcogestureList.spec.tsx @@ -62,7 +62,7 @@ describe('EcogesturesList component', () => { wrapper.find(Button).first().simulate('click') expect(wrapper.find('.filter-menu').exists()).toBeTruthy() wrapper.find(MenuItem).at(1).simulate('click') - expect(updateEcogestureFilter).toBeCalledTimes(1) + expect(updateEcogestureFilter).toHaveBeenCalledTimes(1) }) it('should display the selection section', async () => { diff --git a/src/components/EcogestureForm/EcogestureFormEquipment/EcogestureFormEquipment.spec.tsx b/src/components/EcogestureForm/EcogestureFormEquipment/EcogestureFormEquipment.spec.tsx index 102b0d4b3..91a4fd40e 100644 --- a/src/components/EcogestureForm/EcogestureFormEquipment/EcogestureFormEquipment.spec.tsx +++ b/src/components/EcogestureForm/EcogestureFormEquipment/EcogestureFormEquipment.spec.tsx @@ -45,7 +45,7 @@ describe('EcogestureFormEquipment component', () => { wrapper.find('.item-eq').first().simulate('change') await waitForComponentToPaint(wrapper) - expect(wrapper.find('.item-eq').first().hasClass('checked')).toBeTruthy + 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() diff --git a/src/components/Feedback/FeedbackModal.spec.tsx b/src/components/Feedback/FeedbackModal.spec.tsx index 9d92f7ab0..8c7520ace 100644 --- a/src/components/Feedback/FeedbackModal.spec.tsx +++ b/src/components/Feedback/FeedbackModal.spec.tsx @@ -63,7 +63,7 @@ describe('FeedbackModal component', () => { </Provider> ) wrapper.find('.btn-highlight').first().simulate('click') - expect(window.open).toBeCalledTimes(1) + expect(window.open).toHaveBeenCalledTimes(1) expect(global.open).toHaveBeenCalledWith(`${__SAU_LINK__}?version=0.0.0`) }) }) diff --git a/src/components/FluidChart/TimeStepSelector/TimeStepSelector.spec.tsx b/src/components/FluidChart/TimeStepSelector/TimeStepSelector.spec.tsx index 2264ab476..25c2672cc 100644 --- a/src/components/FluidChart/TimeStepSelector/TimeStepSelector.spec.tsx +++ b/src/components/FluidChart/TimeStepSelector/TimeStepSelector.spec.tsx @@ -77,9 +77,9 @@ describe('TimeStepSelector component', () => { </Provider> ) wrapper.find('#day').first().simulate('click') - expect(setCurrentTimeStepSpy).toBeCalledTimes(1) + expect(setCurrentTimeStepSpy).toHaveBeenCalledTimes(1) expect(setCurrentTimeStepSpy).toHaveBeenCalledWith(TimeStep.DAY) - expect(setCurrentIndexSpy).toBeCalledTimes(1) + expect(setCurrentIndexSpy).toHaveBeenCalledTimes(1) }) it('should go to todays day with timestep week', () => { const store = createMockEcolyoStore({ @@ -96,9 +96,9 @@ describe('TimeStepSelector component', () => { </Provider> ) wrapper.find(Button).first().simulate('click') - expect(setCurrentTimeStepSpy).toBeCalledTimes(1) + expect(setCurrentTimeStepSpy).toHaveBeenCalledTimes(1) expect(setCurrentTimeStepSpy).toHaveBeenCalledWith(TimeStep.WEEK) - expect(setCurrentIndexSpy).toBeCalledTimes(2) - expect(setSelectedDateSpy).toBeCalledTimes(1) + expect(setCurrentIndexSpy).toHaveBeenCalledTimes(2) + expect(setSelectedDateSpy).toHaveBeenCalledTimes(1) }) }) diff --git a/src/components/Options/ExportData/Modals/exportDoneModal.spec.tsx b/src/components/Options/ExportData/Modals/exportDoneModal.spec.tsx index 6cb90a0e0..a9e1c7f46 100644 --- a/src/components/Options/ExportData/Modals/exportDoneModal.spec.tsx +++ b/src/components/Options/ExportData/Modals/exportDoneModal.spec.tsx @@ -26,7 +26,7 @@ describe('exportDoneModal component', () => { it('should display error message', () => undefined) - it('should close modal ', () => { + it('should close modal', () => { const wrapper = mount( <Provider store={store}> <ExportDoneModal diff --git a/src/components/Options/ExportData/Modals/exportLoadingModal.spec.tsx b/src/components/Options/ExportData/Modals/exportLoadingModal.spec.tsx index c25414ec7..aeb7d672b 100644 --- a/src/components/Options/ExportData/Modals/exportLoadingModal.spec.tsx +++ b/src/components/Options/ExportData/Modals/exportLoadingModal.spec.tsx @@ -28,7 +28,7 @@ describe('ExportLoadingModal component', () => { expect(toJson(wrapper)).toMatchSnapshot() }) - it('should cancel download ', () => { + it('should cancel download', () => { const wrapper = mount( <Provider store={store}> <ExportLoadingModal diff --git a/src/components/Options/ExportData/Modals/exportStartModal.spec.tsx b/src/components/Options/ExportData/Modals/exportStartModal.spec.tsx index 2857c5f12..f72defa44 100644 --- a/src/components/Options/ExportData/Modals/exportStartModal.spec.tsx +++ b/src/components/Options/ExportData/Modals/exportStartModal.spec.tsx @@ -25,7 +25,7 @@ describe('exportStartModal component', () => { expect(toJson(wrapper)).toMatchSnapshot() }) - it('should close modal ', () => { + it('should close modal', () => { const wrapper = mount( <Provider store={store}> <ExportStartModal diff --git a/src/components/Options/ReportOptions/ReportOptions.spec.tsx b/src/components/Options/ReportOptions/ReportOptions.spec.tsx index 7453ae580..8794bd7e8 100644 --- a/src/components/Options/ReportOptions/ReportOptions.spec.tsx +++ b/src/components/Options/ReportOptions/ReportOptions.spec.tsx @@ -42,7 +42,7 @@ describe('ReportOptions component', () => { </Provider> ) wrapper.find(Button).first().simulate('click') - expect(updateProfileSpy).toBeCalledTimes(1) + expect(updateProfileSpy).toHaveBeenCalledTimes(1) expect(updateProfileSpy).toHaveBeenCalledWith({ sendAnalysisNotification: false, }) @@ -56,7 +56,7 @@ describe('ReportOptions component', () => { </Provider> ) wrapper.find(Button).first().simulate('click') - expect(updateProfileSpy).toBeCalledTimes(1) + expect(updateProfileSpy).toHaveBeenCalledTimes(1) expect(updateProfileSpy).toHaveBeenCalledWith({ sendAnalysisNotification: true, }) @@ -85,7 +85,7 @@ describe('ReportOptions component', () => { .find('input') .first() .simulate('change', { target: { checked: 'true' } }) - expect(updateProfileSpy).toBeCalledTimes(1) + expect(updateProfileSpy).toHaveBeenCalledTimes(1) expect(updateProfileSpy).toHaveBeenCalledWith({ sendConsumptionAlert: true, }) diff --git a/src/components/Quiz/QuizQuestion/QuizQuestionContentCustom.spec.tsx b/src/components/Quiz/QuizQuestion/QuizQuestionContentCustom.spec.tsx index b05a3a8f6..7c5b860e9 100644 --- a/src/components/Quiz/QuizQuestion/QuizQuestionContentCustom.spec.tsx +++ b/src/components/Quiz/QuizQuestion/QuizQuestionContentCustom.spec.tsx @@ -80,12 +80,11 @@ describe('QuizCustomQuestionContent component', () => { </Provider> ) const answer = questionEntity.answers[0].answerLabel - expect( - wrapper - .find({ type: 'radio' }) - .at(0) - .simulate('change', { target: { value: answer } }) - ) + wrapper + .find({ type: 'radio' }) + .at(0) + .simulate('change', { target: { value: answer } }) + expect(wrapper.find(Button).exists()).toBeTruthy() wrapper.find('.btn-secondary-negative').forEach(node => { node.simulate('click') diff --git a/src/components/WelcomeModal/WelcomeModal.spec.tsx b/src/components/WelcomeModal/WelcomeModal.spec.tsx index 9d6706a61..a4fa5b421 100644 --- a/src/components/WelcomeModal/WelcomeModal.spec.tsx +++ b/src/components/WelcomeModal/WelcomeModal.spec.tsx @@ -71,7 +71,7 @@ describe('WelcomeModal component', () => { </Provider> ) component.find(Button).first().simulate('click') - expect(mockSendMail).toBeCalled() + expect(mockSendMail).toHaveBeenCalled() expect(updateProfileSpy).toHaveBeenCalledWith({ isFirstConnection: false, onboarding: { @@ -87,7 +87,7 @@ describe('WelcomeModal component', () => { </Provider> ) component.find(IconButton).first().simulate('click') - expect(mockSendMail).toBeCalled() + expect(mockSendMail).toHaveBeenCalled() expect(updateProfileSpy).toHaveBeenCalledWith({ isFirstConnection: false, onboarding: { diff --git a/src/migrations/migration.service.spec.ts b/src/migrations/migration.service.spec.ts index af4ee1112..c865c5d7a 100644 --- a/src/migrations/migration.service.spec.ts +++ b/src/migrations/migration.service.spec.ts @@ -4,6 +4,7 @@ import { Profile } from 'models' import { Notes } from 'models/releaseNotes.model' import { Schema } from 'models/schema.models' import mockClient from 'tests/__mocks__/client.mock' +import { getError } from 'tests/__mocks__/testUtils' import * as Migrate from './migration' import { MIGRATION_RESULT_FAILED } from './migration.data' import { MigrationService } from './migration.service' @@ -47,7 +48,7 @@ describe('Migration service', () => { ] mockClient.query.mockResolvedValue(mockQueryResult) await ms.runMigrations(migrations) - expect(migrateSpy).toBeCalledTimes(1) + expect(migrateSpy).toHaveBeenCalledTimes(1) }) it('should run migrations with one fail', async () => { @@ -79,7 +80,7 @@ describe('Migration service', () => { mockClient.query.mockResolvedValue(mockQueryResult) await ms.runMigrations(migrations) - expect(migrateSpyOneFail).toBeCalledTimes(2) + expect(migrateSpyOneFail).toHaveBeenCalledTimes(2) }) it('should not run migrations with two fail', async () => { @@ -112,13 +113,10 @@ describe('Migration service', () => { .spyOn(Migrate, 'migrate') .mockResolvedValueOnce(result) .mockResolvedValueOnce(result) - try { - await ms.runMigrations(migrations) - expect(migrateSpyTwoFailsKo).toBeCalledTimes(1) - expect(migrateSpy).toBeCalledTimes(1) - } catch (error) { - expect(error).toEqual(new Error()) - } + const error = await getError(async () => ms.runMigrations(migrations)) + expect(migrateSpyTwoFailsKo).toHaveBeenCalledTimes(2) + expect(migrateSpy).toHaveBeenCalledTimes(2) + expect(error).toEqual(new Error()) }) it('should skip migrations if schema number is up to date', async () => { @@ -145,7 +143,7 @@ describe('Migration service', () => { mockClient.query.mockResolvedValue(mockQueryResult) await ms.runMigrations(migrations) - expect(migrateSpy).toBeCalledTimes(0) + expect(migrateSpy).toHaveBeenCalledTimes(0) }) it('should run 2 migrations properly from a fresh instance and dont show releasenotes', async () => { const schema: Schema = { _id: '1', version: 0 } @@ -182,7 +180,7 @@ describe('Migration service', () => { mockClient.query.mockResolvedValue(mockQueryResult) const res = await ms.runMigrations(migrations) - expect(migrateSpy).toBeCalledTimes(2) + expect(migrateSpy).toHaveBeenCalledTimes(2) expect(res.show).toBeFalsy() }) }) diff --git a/src/migrations/migration.spec.ts b/src/migrations/migration.spec.ts index f316279e7..03ae98d66 100644 --- a/src/migrations/migration.spec.ts +++ b/src/migrations/migration.spec.ts @@ -30,13 +30,13 @@ describe('migration logger', () => { }, } - it('it should return noop', () => { + it('should return noop', () => { const result: MigrationResult = { type: MIGRATION_RESULT_NOOP, errors: [] } const reply = migrationLog(migration, result) expect(reply).toEqual('--- Removing mailToken from profil => NOOP') }) - it('it should return noop', () => { + it('should return Complete', () => { const result: MigrationResult = { type: MIGRATION_RESULT_COMPLETE, errors: [], @@ -45,7 +45,7 @@ describe('migration logger', () => { expect(reply).toEqual('--- Removing mailToken from profil => Complete') }) - it('it should return noop', () => { + it('should return Failed', () => { const result: MigrationResult = { type: MIGRATION_RESULT_FAILED, errors: [], @@ -73,7 +73,7 @@ describe('migration', () => { }, } - it('it should return schema does not exist', async () => { + it('should return schema does not exist', async () => { const mockQueryResult: QueryResult<Schema[]> = { data: [], bookmark: '', @@ -94,7 +94,7 @@ describe('migration', () => { expect(result).toEqual({ type: MIGRATION_RESULT_NOOP, errors: [] }) }) - it('it should return migration failed', async () => { + it('should return migration failed', async () => { const mockQueryResult: QueryResult<Schema[]> = { data: [], bookmark: '', @@ -120,7 +120,7 @@ describe('migration', () => { }) }) - it('it should return migration complete', async () => { + it('should return migration complete', async () => { const mockQueryResultWithoutAnySchema: QueryResult<Schema[]> = { data: [], bookmark: '', @@ -152,7 +152,7 @@ describe('migration', () => { }) }) - it('it should return migration noop', async () => { + it('should return migration noop', async () => { const migrationTest: Migration = { baseSchemaVersion: 0, targetSchemaVersion: 1, @@ -197,7 +197,7 @@ describe('migration', () => { }) describe('migration create', () => { - it('it should return migration complete for creation', async () => { + it('should return migration complete for creation', async () => { const migrationTestCreate: Migration = { baseSchemaVersion: 0, targetSchemaVersion: 1, diff --git a/src/services/account.service.spec.ts b/src/services/account.service.spec.ts index e43bb207e..cb6e07b6b 100644 --- a/src/services/account.service.spec.ts +++ b/src/services/account.service.spec.ts @@ -5,6 +5,7 @@ import { Account, AccountAuthData } from 'models' import { accountsData } from 'tests/__mocks__/accountsData.mock' import mockClient from 'tests/__mocks__/client.mock' import { konnectorsData } from 'tests/__mocks__/konnectorsData.mock' +import { getError } from 'tests/__mocks__/testUtils' import { triggersEnedisData } from 'tests/__mocks__/triggersData.mock' import AccountService from './account.service' @@ -49,11 +50,10 @@ describe('Account service', () => { it('should throw error when fetchAccount unsuccessfully', async () => { mockHavestLibAccounts.fetchAccount.mockRejectedValueOnce(new Error()) const mockId = 'io.cozy.konnectors/eglgrandlyon' - try { - await accountService.getAccount(mockId) - } catch (error) { - expect(error).toEqual(new Error('Get account failed')) - } + const error = await getError(async () => + accountService.getAccount(mockId) + ) + expect(error).toEqual(new Error('Get account failed')) }) }) @@ -130,11 +130,10 @@ describe('Account service', () => { it('should throw error when updateAccount unsuccessfully', async () => { mockHavestLibAccounts.updateAccount.mockRejectedValueOnce(new Error()) - try { - await accountService.updateAccount(accountsData[2]) - } catch (error) { - expect(error).toEqual(new Error('Update account failed')) - } + const error = await getError(async () => + accountService.updateAccount(accountsData[2]) + ) + expect(error).toEqual(new Error('Update account failed')) }) }) @@ -147,11 +146,10 @@ describe('Account service', () => { it('should throw error when destroy unsuccessfully', async () => { mockHavestLibAccounts.deleteAccount.mockRejectedValueOnce(new Error()) - try { - await accountService.deleteAccount(accountsData[2]) - } catch (error) { - expect(error).toEqual(new Error('Delete account failed')) - } + const error = await getError(async () => + accountService.deleteAccount(accountsData[2]) + ) + expect(error).toEqual(new Error('Delete account failed')) }) }) diff --git a/src/services/challenge.service.spec.ts b/src/services/challenge.service.spec.ts index a683a391b..2f0c2bb07 100644 --- a/src/services/challenge.service.spec.ts +++ b/src/services/challenge.service.spec.ts @@ -42,6 +42,7 @@ import { } from 'tests/__mocks__/explorationData.mock' import { fluidStatusData } from 'tests/__mocks__/fluidStatusData.mock' import { quizEntity, userQuiz } from 'tests/__mocks__/quizData.mock' +import { getError } from 'tests/__mocks__/testUtils' import { userChallengeData, userChallengeDefault, @@ -255,11 +256,10 @@ describe('Challenge service', () => { } mockClient.query.mockResolvedValueOnce(mockQueryResult) mockClient.destroy.mockRejectedValue(new Error()) - try { - await challengeService.deleteAllChallengeEntities() - } catch (error) { - expect(error).toEqual(new Error()) - } + const error = await getError(async () => + challengeService.deleteAllChallengeEntities() + ) + expect(error).toEqual(new Error()) }) }) @@ -307,12 +307,11 @@ describe('Challenge service', () => { expect(result).toEqual(expectedResult) }) it('should throw an error because create failed', async () => { - mockClient.create.mockRejectedValue(new Error()) - try { - await challengeService.initChallengeDuelProgress(userChallengeData[0]) - } catch (error) { - expect(error).toEqual(new Error()) - } + mockClient.save.mockRejectedValue(new Error()) + const error = await getError(async () => + challengeService.initChallengeDuelProgress(userChallengeData[0]) + ) + expect(error).toEqual(new Error()) }) }) @@ -332,11 +331,10 @@ describe('Challenge service', () => { }) it('should throw an error because create failed', async () => { mockClient.create.mockRejectedValue(new Error()) - try { - await challengeService.startUserChallenge(userChallengeData[0]) - } catch (error) { - expect(error).toEqual(new Error()) - } + const error = await getError(async () => + challengeService.startUserChallenge(userChallengeData[0]) + ) + expect(error).toEqual(new Error()) }) }) @@ -374,14 +372,15 @@ describe('Challenge service', () => { ) expect(result).toEqual(userChallengeData[0]) }) - it('should throw error when failed to save the updateUserChallenge', () => { + it('should throw error when failed to save the updateUserChallenge', async () => { mockClient.save.mockRejectedValueOnce(new Error()) - expect( + const error = await getError(async () => challengeService.updateUserChallenge( userChallengeData[0], UserChallengeUpdateFlag.DUEL_START ) - ).rejects.toEqual(new Error()) + ) + expect(error).toEqual(new Error()) }) }) @@ -486,7 +485,7 @@ describe('Challenge service', () => { ) expect(result).toEqual({ isDone: true, isWin: true }) }) - it('should return isDone = true, isWin = false when userConsumption >= threshold ', async () => { + it('should return isDone = true, isWin = false when userConsumption >= threshold', async () => { const updatedUserChallenge = { ...userChallenge, duel: { @@ -572,7 +571,7 @@ describe('Challenge service', () => { expect(result).toEqual({ isDone: true, isWin: true }) }) - it('should return isDone = true and isWin = false when all data are available and userConsumption >= threshold ', async () => { + it('should return isDone = true and isWin = false when all data are available and userConsumption >= threshold', async () => { const updatedUserChallenge = { ...userChallenge, duel: { diff --git a/src/services/challenge.service.ts b/src/services/challenge.service.ts index e625f4179..ff4623e38 100644 --- a/src/services/challenge.service.ts +++ b/src/services/challenge.service.ts @@ -518,10 +518,8 @@ export default class ChallengeService { }> { const consumptionService = new ConsumptionDataManager(this._client) try { - const dataloads: Dataload[] = await this.getUserChallengeDataload( - userChallenge - ) - const userConsumption: number = getRoundFloat( + const dataloads = await this.getUserChallengeDataload(userChallenge) + const userConsumption = getRoundFloat( consumptionService.calculatePerformanceIndicatorValue(dataloads) ) const _userChallenge: UserChallenge = { @@ -531,11 +529,10 @@ export default class ChallengeService { userConsumption: userConsumption, }, } - const updatedUserChallenge: UserChallenge = - await this.updateUserChallenge( - _userChallenge, - UserChallengeUpdateFlag.DUEL_CONSUMPTION - ) + const updatedUserChallenge = await this.updateUserChallenge( + _userChallenge, + UserChallengeUpdateFlag.DUEL_CONSUMPTION + ) return { updatedUserChallenge, dataloads } } catch (error) { const errorMessage = `Challenge service error on initChallengeDuelProgress: ${JSON.stringify( diff --git a/src/services/consumptionFormatter.service.spec.ts b/src/services/consumptionFormatter.service.spec.ts index bfcb9f2cb..2c07788f2 100644 --- a/src/services/consumptionFormatter.service.spec.ts +++ b/src/services/consumptionFormatter.service.spec.ts @@ -2,6 +2,7 @@ import { DataloadState, FluidType, TimeStep } from 'enums' import { DateTime } from 'luxon' import { Dataload, FluidStatus, TimePeriod } from 'models' import { fluidStatusConnectedData } from 'tests/__mocks__/fluidStatusData.mock' +import { getError } from 'tests/__mocks__/testUtils' import ConsumptionFormatterService from './consumptionFormatter.service' const localSpy = jest.spyOn(DateTime, 'local') @@ -249,8 +250,8 @@ describe('ConsumptionFormatter service', () => { ) expect(result).toEqual(mockResult) }) - it('should return an error because of unknown TimeStep', () => { - try { + it('should return an error because of unknown TimeStep', async () => { + const error = await getError(async () => consumptionFormatterService.formatGraphData( mockDataLoad, mockTimePeriod, @@ -258,9 +259,8 @@ describe('ConsumptionFormatter service', () => { FluidType.ELECTRICITY, fluidStatus[FluidType.ELECTRICITY] ) - } catch (error) { - expect(error).toEqual(new Error('TimeStep unknown')) - } + ) + expect(error).toEqual(new Error('TimeStep unknown')) }) }) diff --git a/src/services/consumptionValidator.service.spec.ts b/src/services/consumptionValidator.service.spec.ts index e18a4f5b4..819a9724a 100644 --- a/src/services/consumptionValidator.service.spec.ts +++ b/src/services/consumptionValidator.service.spec.ts @@ -11,15 +11,15 @@ const mockTimePeriodComparison: TimePeriod = { startDate: DateTime.fromISO('2020-09-01T00:00:00.000Z', { zone: 'utc' }), endDate: DateTime.fromISO('2020-09-03T23:59:59.999Z', { zone: 'utc' }), } -let fluidTypes: FluidType[] = [0, 1, 2] +let allFluids: FluidType[] = [0, 1, 2] describe('ConsumptionFormatter service', () => { const consumptionValidatorService = new ConsumptionValidatorService() - describe('formatGraphData method', () => { + describe('ValidateGetGraphData method', () => { it('should return true for DAY', () => { const result = consumptionValidatorService.ValidateGetGraphData( mockTimePeriod, TimeStep.DAY, - fluidTypes + allFluids ) expect(result).toBeTruthy() }) @@ -27,7 +27,7 @@ describe('ConsumptionFormatter service', () => { const result = consumptionValidatorService.ValidateGetGraphData( mockTimePeriod, TimeStep.DAY, - fluidTypes, + allFluids, mockTimePeriodComparison ) expect(result).toBeTruthy() @@ -42,12 +42,12 @@ describe('ConsumptionFormatter service', () => { const result = consumptionValidatorService.ValidateGetGraphData( mockTimePeriod, TimeStep.DAY, - fluidTypes, + allFluids, wrongTimePeriodComparison ) expect(result).toBeFalsy() }) - it('should return false with comparison Date', () => { + it('should return false with comparison Date for elec', () => { const wrongTimePeriodComparison: TimePeriod = { startDate: DateTime.fromISO('2020-09-05T00:00:00.000Z', { zone: 'utc', @@ -81,7 +81,7 @@ describe('ConsumptionFormatter service', () => { const result = consumptionValidatorService.ValidateGetGraphData( wrongTimePeriod, TimeStep.DAY, - fluidTypes + allFluids ) expect(result).toBeFalsy() }) @@ -89,12 +89,12 @@ describe('ConsumptionFormatter service', () => { const result = consumptionValidatorService.ValidateGetGraphData( mockTimePeriod, TimeStep.HALF_AN_HOUR, - fluidTypes + allFluids ) expect(result).toBeFalsy() }) it('should return false because of HALF_AN_HOUR and ValidateTimePeriodLength', () => { - fluidTypes = [0] // Only fluid without TimeStep incompatibilty + allFluids = [0] // Only fluid without TimeStep incompatibilty const mockTimePeriodTooLong: TimePeriod = { startDate: DateTime.fromISO('2020-10-01T00:00:00.000Z', { zone: 'utc', @@ -104,7 +104,7 @@ describe('ConsumptionFormatter service', () => { const result = consumptionValidatorService.ValidateGetGraphData( mockTimePeriodTooLong, TimeStep.HALF_AN_HOUR, - fluidTypes + allFluids ) expect(result).toBeFalsy() }) @@ -118,7 +118,7 @@ describe('ConsumptionFormatter service', () => { const result = consumptionValidatorService.ValidateGetGraphData( mockTimePeriodTooLong, TimeStep.WEEK, - fluidTypes + allFluids ) expect(result).toBeFalsy() }) @@ -132,7 +132,7 @@ describe('ConsumptionFormatter service', () => { const result = consumptionValidatorService.ValidateGetGraphData( mockTimePeriodTooLong, TimeStep.DAY, - fluidTypes + allFluids ) expect(result).toBeFalsy() }) @@ -146,7 +146,7 @@ describe('ConsumptionFormatter service', () => { const result = consumptionValidatorService.ValidateGetGraphData( mockTimePeriodTooLong, TimeStep.MONTH, - fluidTypes + allFluids ) expect(result).toBeFalsy() }) @@ -160,7 +160,7 @@ describe('ConsumptionFormatter service', () => { const result = consumptionValidatorService.ValidateGetGraphData( mockTimePeriodTooLong, TimeStep.YEAR, - fluidTypes + allFluids ) expect(result).toBeFalsy() }) diff --git a/src/services/customPopup.service.test.ts b/src/services/customPopup.service.spec.ts similarity index 95% rename from src/services/customPopup.service.test.ts rename to src/services/customPopup.service.spec.ts index 6808d6cef..11d1d9cc7 100644 --- a/src/services/customPopup.service.test.ts +++ b/src/services/customPopup.service.spec.ts @@ -24,7 +24,8 @@ describe('PartnersInfo service', () => { res = await customPopupService.getCustomPopup() expect(true).toBe(false) } catch (error) { - expect(res).toBe(undefined) + // } + expect(res).toBe(undefined) }) }) diff --git a/src/services/customPopup.service.ts b/src/services/customPopup.service.ts index 0237970e6..71c308900 100644 --- a/src/services/customPopup.service.ts +++ b/src/services/customPopup.service.ts @@ -20,7 +20,7 @@ export default class CustomPopupService { /** * Get information from backoffice about the status of custom popup * On success, respond the customPopup - * Else, throw an error + * Else, return undefined */ public async getCustomPopup(): Promise<CustomPopup | undefined> { const env = new EnvironmentService() diff --git a/src/services/dateChart.service.spec.ts b/src/services/dateChart.service.spec.ts index f7bfff659..59c9d2d5b 100644 --- a/src/services/dateChart.service.spec.ts +++ b/src/services/dateChart.service.spec.ts @@ -1,6 +1,7 @@ import { TimeStep } from 'enums' import { DateTime } from 'luxon' import { TimePeriod } from 'models' +import { getError } from 'tests/__mocks__/testUtils' import DateChartService from './dateChart.service' const localSpy = jest.spyOn(DateTime, 'local') @@ -294,12 +295,11 @@ describe('dateChart service', () => { expect(result).toEqual(expectedTimePeriod) }) - it('should throw error for unknown TimeStep', () => { - try { + it('should throw error for unknown TimeStep', async () => { + const error = await getError(async () => dateChartService.defineTimePeriod(refDate, unknownTimeStep, -1) - } catch (error) { - expect(error).toEqual(new Error('TimeStep unknown')) - } + ) + expect(error).toEqual(new Error('TimeStep unknown')) }) }) @@ -686,18 +686,17 @@ describe('dateChart service', () => { expect(result).toBe(false) }) - it('should throw error for unknown TimeStep', () => { + it('should throw error for unknown TimeStep', async () => { const firstDate = DateTime.fromISO('2020-10-31T00:00:00.000Z', { zone: 'utc', }) const secondDate = DateTime.fromISO('2020-10-31T00:30:00.000Z', { zone: 'utc', }) - try { + const error = await getError(async () => dateChartService.compareStepDate(unknownTimeStep, firstDate, secondDate) - } catch (error) { - expect(error).toEqual(new Error('TimeStep unknown')) - } + ) + expect(error).toEqual(new Error('TimeStep unknown')) }) }) diff --git a/src/services/duel.service.spec.ts b/src/services/duel.service.spec.ts index f50bf5e4a..93cd9552a 100644 --- a/src/services/duel.service.spec.ts +++ b/src/services/duel.service.spec.ts @@ -14,6 +14,7 @@ import { fluidStatusConnectedData, fluidStatusData, } from 'tests/__mocks__/fluidStatusData.mock' +import { getError } from 'tests/__mocks__/testUtils' const mockGetPerformanceIndicators = jest.fn() const mockGetGraphData = jest.fn() @@ -87,11 +88,10 @@ describe('Duel service', () => { } mockClient.query.mockResolvedValueOnce(mockQueryResult) mockClient.destroy.mockRejectedValue(new Error()) - try { - await duelService.deleteAllDuelEntities() - } catch (error) { - expect(error).toEqual(new Error()) - } + const error = await getError(async () => + duelService.deleteAllDuelEntities() + ) + expect(error).toEqual(new Error()) }) }) diff --git a/src/services/ecogesture.service.spec.ts b/src/services/ecogesture.service.spec.ts index df4796ddc..a249083d9 100644 --- a/src/services/ecogesture.service.spec.ts +++ b/src/services/ecogesture.service.spec.ts @@ -12,6 +12,7 @@ import { mockedEcogesturesData, } from 'tests/__mocks__/ecogesturesData.mock' import { mockProfileEcogesture } from 'tests/__mocks__/profileEcogesture.mock' +import { getError } from 'tests/__mocks__/testUtils' import { hashFile } from 'utils/hash' import EcogestureService from './ecogesture.service' @@ -58,7 +59,7 @@ describe('Ecogesture service', () => { it('should return true when 3 ecogestures stored', async () => { mockClient.query.mockResolvedValueOnce(mockQueryResultMockedEcogestures) const result = await ecogestureService.deleteAllEcogestures() - expect(mockClient.destroy).toBeCalledTimes(3) + expect(mockClient.destroy).toHaveBeenCalledTimes(3) expect(result).toBe(true) }) it('should return true when no ecogestures stored', async () => { @@ -78,7 +79,7 @@ describe('Ecogesture service', () => { it('should return true when 3 ecogestures stored', async () => { mockClient.query.mockResolvedValueOnce(mockQueryResultMockedEcogestures) const result = await ecogestureService.reinitAllEcogestures() - expect(mockClient.save).toBeCalledTimes(3) + expect(mockClient.save).toHaveBeenCalledTimes(3) expect(result).toBe(true) }) it('should return true when no ecogestures stored', async () => { @@ -303,7 +304,10 @@ describe('Ecogesture service', () => { .spyOn(ecogestureService, 'deleteAllEcogestures') .mockResolvedValue(true) mockClient.create.mockRejectedValueOnce(new Error()) - expect(ecogestureService.initEcogesture('')).rejects.toThrow(new Error()) + const error = await getError(async () => + ecogestureService.initEcogesture('') + ) + expect(error).toEqual(new Error()) }) }) }) diff --git a/src/services/exploration.service.spec.ts b/src/services/exploration.service.spec.ts index 9745d5f30..ebd9e8870 100644 --- a/src/services/exploration.service.spec.ts +++ b/src/services/exploration.service.spec.ts @@ -9,6 +9,7 @@ import { userExplorationStarted, userExplorationUnlocked, } from 'tests/__mocks__/explorationData.mock' +import { getError } from 'tests/__mocks__/testUtils' import { userChallengeExplo1OnGoing, userChallengeExplo2OnGoing, @@ -72,11 +73,10 @@ describe('Exploration service', () => { } mockClient.query.mockResolvedValueOnce(mockQueryResult) mockClient.destroy.mockRejectedValue(new Error()) - try { - await explorationService.deleteAllExplorationEntities() - } catch (error) { - expect(error).toEqual(new Error()) - } + const error = await getError(async () => + explorationService.deleteAllExplorationEntities() + ) + expect(error).toEqual(new Error()) }) }) diff --git a/src/services/fluidsPrices.service.spec.ts b/src/services/fluidsPrices.service.spec.ts index c1620f889..a25157e4c 100644 --- a/src/services/fluidsPrices.service.spec.ts +++ b/src/services/fluidsPrices.service.spec.ts @@ -7,6 +7,7 @@ import { allLastFluidPrices, fluidPrices, } from 'tests/__mocks__/fluidPrice.mock' +import { getError } from 'tests/__mocks__/testUtils' import FluidPricesService from './fluidsPrices.service' describe('FluidPrices service', () => { @@ -23,7 +24,7 @@ describe('FluidPrices service', () => { mockClient.query.mockResolvedValueOnce(mockQueryResult) const prices = await fluidPricesService.getAllPrices() expect(prices).toBe(fluidPrices) - expect(mockClient.query).toBeCalled() + expect(mockClient.query).toHaveBeenCalled() }) }) @@ -43,7 +44,7 @@ describe('FluidPrices service', () => { }) ) expect(prices).toBe(fluidPrices[0]) - expect(mockClient.query).toBeCalled() + expect(mockClient.query).toHaveBeenCalled() }) it('should getPrices for gas', async () => { const mockQueryResult: QueryResult<FluidPrice[]> = { @@ -60,7 +61,7 @@ describe('FluidPrices service', () => { }) ) expect(prices).toBe(fluidPrices[3]) - expect(mockClient.query).toBeCalled() + expect(mockClient.query).toHaveBeenCalled() }) }) @@ -77,7 +78,7 @@ describe('FluidPrices service', () => { console.log('Prix reçus :', prices) console.log('Prix attendus :', allLastFluidPrices) expect(prices).toStrictEqual(allLastFluidPrices) - expect(mockClient.query).toBeCalled() + expect(mockClient.query).toHaveBeenCalled() }) }) @@ -91,7 +92,7 @@ describe('FluidPrices service', () => { } mockClient.query.mockResolvedValueOnce(mockQueryResult) const result = await fluidPricesService.deleteAllFluidsPrices() - expect(mockClient.destroy).toBeCalledTimes(6) + expect(mockClient.destroy).toHaveBeenCalledTimes(6) expect(result).toBe(true) }) it('should return true when no fluidsPrices stored', async () => { @@ -128,7 +129,7 @@ describe('FluidPrices service', () => { mockClient.query.mockResolvedValueOnce(mockQueryResult) const price = await fluidPricesService.checkIfPriceExists(fluidPrices[0]) expect(price).toStrictEqual(fluidPrices[0]) - expect(mockClient.query).toBeCalled() + expect(mockClient.query).toHaveBeenCalled() }) it('should create a price and return it', async () => { const mockQueryResult: QueryResult<FluidPrice> = { @@ -143,11 +144,10 @@ describe('FluidPrices service', () => { }) it('should fail to create a price', async () => { mockClient.create.mockRejectedValue(new Error()) - try { - await fluidPricesService.createPrice(fluidPrices[0]) - } catch (error) { - expect(error).toEqual(new Error()) - } + const error = await getError( + async () => await fluidPricesService.createPrice(fluidPrices[0]) + ) + expect(error).toEqual(new Error()) }) it('should update a price', async () => { const updatedPrice = { ...fluidPrices[0], price: 0.1 } @@ -162,16 +162,15 @@ describe('FluidPrices service', () => { price: 0.1, }) expect(price).toStrictEqual(updatedPrice) - expect(mockClient.query).toBeCalled() + expect(mockClient.query).toHaveBeenCalled() }) it('should fail to update a price', async () => { mockClient.save.mockRejectedValue(new Error()) - try { - await fluidPricesService.updatePrice(fluidPrices[0], { + const error = await getError(async () => + fluidPricesService.updatePrice(fluidPrices[0], { price: 0.1, }) - } catch (error) { - expect(error).toEqual(new Error()) - } + ) + expect(error).toEqual(new Error()) }) }) diff --git a/src/services/initialization.service.spec.ts b/src/services/initialization.service.spec.ts index 19669c17d..6b273c34f 100644 --- a/src/services/initialization.service.spec.ts +++ b/src/services/initialization.service.spec.ts @@ -171,14 +171,18 @@ describe('Initialization service', () => { new Error('initProfile: Profile not created') ) }) - it('should throw error when the profile could not be fetched', () => { + it('should throw error when the profile could not be fetched', async () => { mockGetProfile.mockRejectedValueOnce(new Error()) - expect(initializationService.initProfile()).rejects.toEqual(new Error()) + await expect(initializationService.initProfile()).rejects.toEqual( + new Error() + ) }) - it('should throw error when the profile failed to be created', () => { + it('should throw error when the profile failed to be created', async () => { mockGetProfile.mockResolvedValueOnce(null) mockClient.create.mockRejectedValueOnce(new Error()) - expect(initializationService.initProfile()).rejects.toEqual(new Error()) + await expect(initializationService.initProfile()).rejects.toEqual( + new Error() + ) }) }) @@ -306,9 +310,9 @@ describe('Initialization service', () => { .mockResolvedValueOnce(challengeEntityData) mockDeleteAllChallengeEntities.mockResolvedValue(true) mockClient.create.mockRejectedValueOnce(new Error()) - expect(initializationService.initChallengeEntity('')).rejects.toThrow( - new Error() - ) + await expect( + initializationService.initChallengeEntity('') + ).rejects.toThrow(new Error()) }) }) @@ -398,7 +402,7 @@ describe('Initialization service', () => { .mockResolvedValueOnce(duelEntityData) mockDeleteAllDuelEntities.mockResolvedValue(true) mockClient.create.mockRejectedValueOnce(new Error()) - expect(initializationService.initDuelEntity('')).rejects.toThrow( + await expect(initializationService.initDuelEntity('')).rejects.toThrow( new Error() ) }) @@ -490,7 +494,7 @@ describe('Initialization service', () => { .mockResolvedValueOnce(quizEntityData) mockDeleteAllQuizEntities.mockResolvedValue(true) mockClient.create.mockRejectedValueOnce(new Error()) - expect(initializationService.initQuizEntity('')).rejects.toThrow( + await expect(initializationService.initQuizEntity('')).rejects.toThrow( new Error() ) }) @@ -592,9 +596,9 @@ describe('Initialization service', () => { .mockResolvedValueOnce(explorationEntityData) mockDeleteAllExplorationEntities.mockResolvedValue(true) mockClient.create.mockRejectedValueOnce(new Error()) - expect(initializationService.initExplorationEntity('')).rejects.toThrow( - new Error() - ) + await expect( + initializationService.initExplorationEntity('') + ).rejects.toThrow(new Error()) }) }) diff --git a/src/services/partnersInfo.service.spec.ts b/src/services/partnersInfo.service.spec.ts index 652109c9e..43e224017 100644 --- a/src/services/partnersInfo.service.spec.ts +++ b/src/services/partnersInfo.service.spec.ts @@ -28,14 +28,15 @@ describe('PartnersInfo service', () => { expect(result).toEqual(mockPartnersInfo) }) - it('should return an error', async () => { + it('should return undefined', async () => { mockClient.getStackClient().fetchJSON.mockRejectedValue(new Error()) let res try { res = await partnersInfoService.getPartnersInfo() expect(true).toBe(false) - } catch (error) { - expect(res).toBe(undefined) + } catch (e) { + // } + expect(res).toBe(undefined) }) }) diff --git a/src/services/partnersInfo.service.ts b/src/services/partnersInfo.service.ts index 6a39656d9..18bf02ce5 100644 --- a/src/services/partnersInfo.service.ts +++ b/src/services/partnersInfo.service.ts @@ -20,7 +20,7 @@ export default class PartnersInfoService { /** * Get information from backoffice about the status of partners' service * On success, respond the partnersInfo - * Else, throw an error + * Else, return undefined */ public async getPartnersInfo(): Promise<PartnersInfo | undefined> { const env = new EnvironmentService() diff --git a/src/services/queryRunner.service.spec.ts b/src/services/queryRunner.service.spec.ts index f273f8f47..656180de0 100644 --- a/src/services/queryRunner.service.spec.ts +++ b/src/services/queryRunner.service.spec.ts @@ -1367,7 +1367,7 @@ describe('queryRunner service', () => { }) }) - describe('fetchFluidData method', () => { + describe('fetchFluidRawDoctype method', () => { it('should return the data of the elec fluid and year time step', async () => { const mockTimePeriod = { startDate: DateTime.fromISO('2018-01-01T00:00:00.000Z', { diff --git a/src/services/quiz.service.spec.ts b/src/services/quiz.service.spec.ts index 6db5b0f90..7b891b841 100644 --- a/src/services/quiz.service.spec.ts +++ b/src/services/quiz.service.spec.ts @@ -31,6 +31,7 @@ import { quizEntity, userQuiz, } from 'tests/__mocks__/quizData.mock' +import { getError } from 'tests/__mocks__/testUtils' import QuizService from './quiz.service' const localSpy = jest.spyOn(DateTime, 'local') @@ -101,11 +102,10 @@ describe('Quiz service', () => { } mockClient.query.mockResolvedValueOnce(mockQueryResult) mockClient.destroy.mockRejectedValue(new Error()) - try { - await quizService.deleteAllQuizEntities() - } catch (error) { - expect(error).toEqual(new Error()) - } + const error = await getError(async () => + quizService.deleteAllQuizEntities() + ) + expect(error).toEqual(new Error()) }) }) diff --git a/src/services/timePeriod.service.spec.ts b/src/services/timePeriod.service.spec.ts index fe57abc97..abc6455fb 100644 --- a/src/services/timePeriod.service.spec.ts +++ b/src/services/timePeriod.service.spec.ts @@ -1,6 +1,7 @@ import { FluidType, TimeStep } from 'enums' import { DateTime } from 'luxon' import { TimePeriod } from 'models' +import { getError } from 'tests/__mocks__/testUtils' import TimePeriodService from './timePeriod.service' const randomDate = DateTime.fromISO('2020-10-10T08:00:00.000Z', { @@ -253,7 +254,7 @@ describe('timePeriod service', () => { ) expect(result).toEqual(expectedComparisonDateTime) }) - it('should return an error because of unknown TimeStep', () => { + it('should return an error because of unknown TimeStep', async () => { const timePeriod: TimePeriod = { startDate: DateTime.fromISO('2020-10-07T08:00:00.000Z', { zone: 'utc', @@ -262,11 +263,10 @@ describe('timePeriod service', () => { zone: 'utc', }), } - try { + const error = await getError(async () => timePeriodService.getComparisonTimePeriod(timePeriod, unknownTimeStep) - } catch (error) { - expect(error).toEqual(new Error('TimeStep unknown')) - } + ) + expect(error).toEqual(new Error('TimeStep unknown')) }) }) @@ -321,15 +321,14 @@ describe('timePeriod service', () => { ) expect(result).toEqual(expectedDate) }) - it('should return an error because of unknown TimeStep', () => { - try { + it('should return an error because of unknown TimeStep', async () => { + const error = await getError(async () => timePeriodService.getLastDayOfCompletePeriod( randomDate, unknownTimeStep ) - } catch (error) { - expect(error).toEqual(new Error('TimeStep unknown')) - } + ) + expect(error).toEqual(new Error('TimeStep unknown')) }) }) @@ -374,7 +373,7 @@ describe('timePeriod service', () => { ) expect(result).toEqual(expectedDate) }) - it('should return the date of the last day of current period', () => { + it('should return the date of the last day of current period for year', () => { const expectedDate = DateTime.fromISO('2020-12-31T00:00:00.000Z', { zone: 'utc', }) @@ -384,12 +383,11 @@ describe('timePeriod service', () => { ) expect(result).toEqual(expectedDate) }) - it('should return the date of the last day of current period', () => { - try { + it('should return unknown timestep', async () => { + const error = await getError(async () => timePeriodService.getLastDayOfTimePeriod(randomDate, unknownTimeStep) - } catch (error) { - expect(error).toEqual(new Error('TimeStep unknown')) - } + ) + expect(error).toEqual(new Error('TimeStep unknown')) }) }) @@ -444,15 +442,14 @@ describe('timePeriod service', () => { ) expect(result).toEqual(expectedDate) }) - it('should return the date of the last day of current period', () => { - try { + it('should return the date of the last day of current period', async () => { + const error = await getError(async () => timePeriodService.getStartDateFromEndDateByTimeStep( randomDate, unknownTimeStep ) - } catch (error) { - expect(error).toEqual(new Error('TimeStep unknown')) - } + ) + expect(error).toEqual(new Error('TimeStep unknown')) }) }) }) diff --git a/src/services/triggers.service.spec.ts b/src/services/triggers.service.spec.ts index 23aac8b37..88691fb42 100644 --- a/src/services/triggers.service.spec.ts +++ b/src/services/triggers.service.spec.ts @@ -3,6 +3,7 @@ import { Trigger, TriggerState } from 'models' import { accountsData } from 'tests/__mocks__/accountsData.mock' import mockClient from 'tests/__mocks__/client.mock' import { konnectorsData } from 'tests/__mocks__/konnectorsData.mock' +import { getError } from 'tests/__mocks__/testUtils' import { triggerStateData } from 'tests/__mocks__/triggerStateData.mock' import { triggersData } from 'tests/__mocks__/triggersData.mock' import TriggerService from './triggers.service' @@ -119,34 +120,32 @@ describe('TriggerService service', () => { it('should throw an error', async () => { mockClient.getStackClient().fetchJSON.mockRejectedValueOnce(new Error()) - try { - await triggerService.fetchTriggerState(triggersData[0]) - } catch (error) { - expect(error).toEqual(new Error('Fetch trigger state failed')) - } + const error = await getError(async () => + triggerService.fetchTriggerState(triggersData[0]) + ) + expect(error).toEqual(new Error('Fetch trigger state failed')) }) }) describe('deleteTrigger method', () => { it('should return true when destroy successfully', async () => { - const mockDetroyResult: QueryResult<Trigger[]> = { + const mockDestroyResult: QueryResult<Trigger[]> = { data: [], bookmark: '', next: false, skip: 0, } - mockClient.destroy.mockResolvedValueOnce(mockDetroyResult) + mockClient.destroy.mockResolvedValueOnce(mockDestroyResult) const result = await triggerService.deleteTrigger(triggersData[0]) expect(result).toBe(true) }) it('should throw error when destroy unsuccessfully', async () => { mockClient.destroy.mockRejectedValueOnce(new Error()) - try { - await triggerService.deleteTrigger(triggersData[0]) - } catch (error) { - expect(error).toEqual(new Error('Delete trigger failed')) - } + const error = await getError(async () => + triggerService.deleteTrigger(triggersData[0]) + ) + expect(error).toEqual(new Error('Delete trigger failed')) }) }) }) diff --git a/src/services/usageEvent.service.spec.ts b/src/services/usageEvent.service.spec.ts index eed34dce5..237f7c74d 100644 --- a/src/services/usageEvent.service.spec.ts +++ b/src/services/usageEvent.service.spec.ts @@ -3,6 +3,7 @@ import { UsageEventType } from 'enums' import { DateTime } from 'luxon' import { AddEventParams, UsageEventEntity } from 'models' import mockClient from 'tests/__mocks__/client.mock' +import { getError } from 'tests/__mocks__/testUtils' import { allUsageEventsData, connectionAttemptEGLError, @@ -63,14 +64,13 @@ describe('UsageEvent service', () => { }) it('should throw an error', async () => { mockClient.save.mockRejectedValue(new Error()) - try { - await UsageEventService.updateUsageEventsAggregated( + const error = await getError(async () => + UsageEventService.updateUsageEventsAggregated( mockClient, allUsageEventsData ) - } catch (error) { - expect(error).toEqual(new Error()) - } + ) + expect(error).toEqual(new Error('Could not update all events')) }) }) describe('getEvents method', () => { diff --git a/src/services/usageEvent.service.ts b/src/services/usageEvent.service.ts index d97489545..7b396168c 100644 --- a/src/services/usageEvent.service.ts +++ b/src/services/usageEvent.service.ts @@ -120,22 +120,23 @@ export default class UsageEventService { client: Client, events: UsageEvent[] ): Promise<boolean> { - for (const event of events) { - try { + try { + for (const event of events) { await client.save({ ...event, aggregated: true, }) - } catch (error) { - const errorMessage = `UsageEvent service error on updateUsageEventsAggregated: ${JSON.stringify( - error - )}` - logStack('error', errorMessage) - logApp.error(errorMessage) - Sentry.captureException(errorMessage) } + return true + } catch (error) { + const errorMessage = `UsageEvent service error on updateUsageEventsAggregated: ${JSON.stringify( + error + )}` + logStack('error', errorMessage) + logApp.error(errorMessage) + Sentry.captureException(errorMessage) + throw new Error('Could not update all events') } - return true } /** diff --git a/src/store/challenge/challenge.slice.spec.ts b/src/store/challenge/challenge.slice.spec.ts index 759c4c868..f4a265cdf 100644 --- a/src/store/challenge/challenge.slice.spec.ts +++ b/src/store/challenge/challenge.slice.spec.ts @@ -33,7 +33,7 @@ describe('challenge reducer', () => { expect(state).toEqual(expectedResult) }) - it('should handle updateUserChallengeList ', () => { + it('should handle updateUserChallengeList', () => { const updatedMockInitialChallengeState = { ...mockChallengeState, userChallengeList: userChallengeDefault, @@ -57,7 +57,7 @@ describe('challenge reducer', () => { expect(state).toEqual(expectedResult) }) - it('should handle unlockNextUserChallenge ', () => { + it('should handle unlockNextUserChallenge', () => { const updatedMockInitialChallengeState = { ...mockChallengeState, userChallengeList: userChallengeDefault, @@ -87,7 +87,7 @@ describe('challenge reducer', () => { expect(state).toEqual(expectedResult) }) - it('should handle SET_CHALLENGE_CONSUMPTION ', () => { + it('should handle SET_CHALLENGE_CONSUMPTION', () => { const updatedMockInitialChallengeState = { ...mockChallengeState, userChallengeList: userChallengeDefault, diff --git a/src/store/chart/chart.slice.spec.ts b/src/store/chart/chart.slice.spec.ts index e0d04f15c..9015e59e3 100644 --- a/src/store/chart/chart.slice.spec.ts +++ b/src/store/chart/chart.slice.spec.ts @@ -120,90 +120,3 @@ describe('chart reducer', () => { }) }) }) - -describe('chart reducer', () => { - it('should return the initial state', () => { - const initialState = chartSlice.reducer(undefined, { type: undefined }) - expect(initialState).toEqual(mockChartState) - }) - - it('should return same state if no action', () => { - const state = chartSlice.reducer(mockChartState, { type: undefined }) - expect(state).toEqual(mockChartState) - }) - - describe('setSelectedDate', () => { - it('should handle SET_SELECTED_DATE with payload', () => { - const mockDate = DateTime.fromISO('2021-01-01T00:00:00.000Z', { - zone: 'utc', - }) - const state = chartSlice.reducer( - mockChartState, - setSelectedDate(mockDate) - ) - expect(state).toEqual({ - ...mockChartState, - selectedDate: mockDate, - }) - }) - }) - - describe('setCurrentTimeStep', () => { - it('should handle SET_CURRENT_TIMESTEP with payload', () => { - const state = chartSlice.reducer( - mockChartState, - setCurrentTimeStep(TimeStep.MONTH) - ) - expect(state).toEqual({ - ...mockChartState, - currentTimeStep: TimeStep.MONTH, - }) - }) - }) - - describe('setCurrentIndex', () => { - it('should handle SET_CURRENT_INDEX with payload', () => { - const state = chartSlice.reducer(mockChartState, setCurrentIndex(1)) - expect(state).toEqual({ - ...mockChartState, - currentIndex: 1, - }) - }) - }) - - describe('setCurrentDataChart', () => { - it('should handle SET_CURRENT_DATACHART with payload', () => { - const state = chartSlice.reducer( - mockChartState, - setCurrentDataChart(graphData) - ) - expect(state).toEqual({ - ...mockChartState, - currentDatachart: graphData, - }) - }) - }) - - describe('setCurrentDataChartIndex', () => { - it('should handle SET_CURRENT_DATACHART_INDEX with payload', () => { - const state = chartSlice.reducer( - mockChartState, - setCurrentDataChartIndex(1) - ) - expect(state).toEqual({ - ...mockChartState, - currentDatachartIndex: 1, - }) - }) - }) - - describe('setLoading', () => { - it('should handle SET_LOADING with payload', () => { - const state = chartSlice.reducer(mockChartState, setLoading(false)) - expect(state).toEqual({ - ...mockChartState, - loading: false, - }) - }) - }) -}) diff --git a/src/utils/date.spec.ts b/src/utils/date.spec.ts index 2e3d5ee8c..a1028add5 100644 --- a/src/utils/date.spec.ts +++ b/src/utils/date.spec.ts @@ -346,7 +346,7 @@ describe('date utils', () => { expect(result).toBe(3) }) - it('it should return 3 when there are many fluid type including WATER', () => { + it('should return 3 when there are many fluid type including WATER', () => { const result = getLagDays([FluidType.ELECTRICITY, FluidType.WATER]) expect(result).toBe(3) }) @@ -356,12 +356,12 @@ describe('date utils', () => { expect(result).toBe(2) }) - it('it should return 2 when there are many fluid type including GAS and excluding WATER', () => { + it('should return 2 when there are many fluid type including GAS and excluding WATER', () => { const result = getLagDays([FluidType.ELECTRICITY, FluidType.GAS]) expect(result).toBe(2) }) - it('it should return when there is only ELECTRICITY Fluid Type', () => { + it('should return when there is only ELECTRICITY Fluid Type', () => { const result = getLagDays([FluidType.ELECTRICITY]) expect(result).toBe(1) }) diff --git a/src/utils/utils.spec.ts b/src/utils/utils.spec.ts index db1e042d0..1fe7e5944 100644 --- a/src/utils/utils.spec.ts +++ b/src/utils/utils.spec.ts @@ -197,18 +197,18 @@ describe('utils test', () => { }) }) - describe('getMonthFullName', () => { + describe('getMonthName', () => { it('should return the name of the month', () => { expect(getMonthName(DateTime.local(2023, 6, 1))).toBe('juin') }) }) describe('getMonthNameWithPrep', () => { - it('should return the name of the month with " de " ', () => { + it('should return the name of the month with " de "', () => { const date = DateTime.fromISO('2020-11-29T23:59:59.999Z') expect(getMonthNameWithPrep(date)).toBe('de novembre') }) - it('should return the name of the month with " d\'" ', () => { + it('should return the name of the month with " d\'"', () => { const date = DateTime.fromISO('2020-10-29T23:59:59.999Z') expect(getMonthNameWithPrep(date)).toBe('d’octobre') }) diff --git a/tests/__mocks__/testUtils.ts b/tests/__mocks__/testUtils.ts index 6b779ccf6..dd25be422 100644 --- a/tests/__mocks__/testUtils.ts +++ b/tests/__mocks__/testUtils.ts @@ -9,3 +9,22 @@ export const waitForComponentToPaint = async <TP extends any = {}>( wrapper.update() }) } + +class NoErrorThrownError extends Error {} + +/** + * @issue Jest only considers a test to have failed if it throws an error, meaning if calls to assertion functions like expect occur in conditional code such as a catch statement, tests can end up passing but not actually test anything. + * @solution A better way to handle this situation is to introduce a wrapper to handle the catching, and otherwise return a specific "no error thrown" error if nothing is thrown by the wrapped function + * @docs https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-conditional-expect.md#disallow-calling-expect-conditionally-no-conditional-expect + */ +export const getError = async <TError>( + call: () => unknown +): Promise<TError> => { + try { + await call() + + throw new NoErrorThrownError('No error thrown') + } catch (error: unknown) { + return error as TError + } +} diff --git a/yarn.lock b/yarn.lock index 7bf41b3b3..fa4b819ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +"@aashutoshrathi/word-wrap@^1.2.3": + version "1.2.6" + resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf" + integrity sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA== + "@alloc/types@^1.2.1": version "1.3.0" resolved "https://registry.yarnpkg.com/@alloc/types/-/types-1.3.0.tgz#904245b8d3260a4b7d8a801c12501968f64fac08" @@ -1681,6 +1686,11 @@ resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.4.0.tgz#3e61c564fcd6b921cb789838631c5ee44df09403" integrity sha512-A9983Q0LnDGdLPjxyXQ00sbV+K+O+ko2Dr+CZigbHWtX9pNfxlaBkMR8X1CztI73zuEyEBXTVjx7CE+/VSwDiQ== +"@eslint-community/regexpp@^4.6.1": + version "4.8.0" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.8.0.tgz#11195513186f68d42fbf449f9a7136b2c0c92005" + integrity sha512-JylOEEzDiOryeUnFbQz+oViCXS0KsvR1mvHkoMiu5+UiBvy+RYX7tzlIIIEstF/gVa2tj9AQXk3dgnxv6KxhFg== + "@eslint/eslintrc@^0.4.3": version "0.4.3" resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.3.tgz#9e42981ef035beb3dd49add17acb96e8ff6f394c" @@ -1711,14 +1721,14 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@eslint/eslintrc@^2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.0.1.tgz#7888fe7ec8f21bc26d646dbd2c11cd776e21192d" - integrity sha512-eFRmABvW2E5Ho6f5fHLqgena46rOj7r7OKHYfLElqcBfGFHHpjBhivyi5+jOEQuSpdc/1phIZJlbC2te+tZNIw== +"@eslint/eslintrc@^2.1.2": + version "2.1.2" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.1.2.tgz#c6936b4b328c64496692f76944e755738be62396" + integrity sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g== dependencies: ajv "^6.12.4" debug "^4.3.2" - espree "^9.5.0" + espree "^9.6.0" globals "^13.19.0" ignore "^5.2.0" import-fresh "^3.2.1" @@ -1726,20 +1736,20 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@eslint/js@8.36.0": - version "8.36.0" - resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.36.0.tgz#9837f768c03a1e4a30bd304a64fb8844f0e72efe" - integrity sha512-lxJ9R5ygVm8ZWgYdUweoq5ownDlJ4upvoWmO4eLxBYHdMo+vZ/Rx0EN6MbKWDJOSUGrqJy2Gt+Dyv/VKml0fjg== +"@eslint/js@8.49.0": + version "8.49.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.49.0.tgz#86f79756004a97fa4df866835093f1df3d03c333" + integrity sha512-1S8uAY/MTJqVx0SC4epBq+N2yhuwtNwLbJYNZyhL2pO1ZVKn5HFXav5T41Ryzy9K9V7ZId2JB2oy/W4aCd9/2w== "@gar/promisify@^1.0.1": version "1.1.3" resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6" integrity sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw== -"@humanwhocodes/config-array@^0.11.8": - version "0.11.8" - resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.8.tgz#03595ac2075a4dc0f191cc2131de14fbd7d410b9" - integrity sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g== +"@humanwhocodes/config-array@^0.11.11": + version "0.11.11" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.11.tgz#88a04c570dbbc7dd943e4712429c3df09bc32844" + integrity sha512-N2brEuAadi0CcdeMXUkhbZB84eskAc8MEX1By6qEchoVywSgXPIjou4rYsl0V3Hj0ZnuGycGCjdNgockbzeWNA== dependencies: "@humanwhocodes/object-schema" "^1.2.1" debug "^4.1.1" @@ -3123,6 +3133,14 @@ "@typescript-eslint/types" "5.56.0" "@typescript-eslint/visitor-keys" "5.56.0" +"@typescript-eslint/scope-manager@5.62.0": + version "5.62.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.62.0.tgz#d9457ccc6a0b8d6b37d0eb252a23022478c5460c" + integrity sha512-VXuvVvZeQCQb5Zgf4HAxc04q5j+WrNAtNh9OwCsCgpKqESMTu3tF/jhZ3xG6T4NZwWl65Bg8KuS2uEvhSfLl0w== + dependencies: + "@typescript-eslint/types" "5.62.0" + "@typescript-eslint/visitor-keys" "5.62.0" + "@typescript-eslint/type-utils@5.56.0": version "5.56.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.56.0.tgz#e6f004a072f09c42e263dc50e98c70b41a509685" @@ -3143,6 +3161,11 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.56.0.tgz#b03f0bfd6fa2afff4e67c5795930aff398cbd834" integrity sha512-JyAzbTJcIyhuUhogmiu+t79AkdnqgPUEsxMTMc/dCZczGMJQh1MK2wgrju++yMN6AWroVAy2jxyPcPr3SWCq5w== +"@typescript-eslint/types@5.62.0": + version "5.62.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.62.0.tgz#258607e60effa309f067608931c3df6fed41fd2f" + integrity sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ== + "@typescript-eslint/typescript-estree@5.30.5": version "5.30.5" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.30.5.tgz#c520e4eba20551c4ec76af8d344a42eb6c9767bb" @@ -3169,6 +3192,19 @@ semver "^7.3.7" tsutils "^3.21.0" +"@typescript-eslint/typescript-estree@5.62.0": + version "5.62.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.62.0.tgz#7d17794b77fabcac615d6a48fb143330d962eb9b" + integrity sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA== + dependencies: + "@typescript-eslint/types" "5.62.0" + "@typescript-eslint/visitor-keys" "5.62.0" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + semver "^7.3.7" + tsutils "^3.21.0" + "@typescript-eslint/utils@5.56.0": version "5.56.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.56.0.tgz#db64705409b9a15546053fb4deb2888b37df1f41" @@ -3183,6 +3219,20 @@ eslint-scope "^5.1.1" semver "^7.3.7" +"@typescript-eslint/utils@^5.10.0": + version "5.62.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.62.0.tgz#141e809c71636e4a75daa39faed2fb5f4b10df86" + integrity sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ== + dependencies: + "@eslint-community/eslint-utils" "^4.2.0" + "@types/json-schema" "^7.0.9" + "@types/semver" "^7.3.12" + "@typescript-eslint/scope-manager" "5.62.0" + "@typescript-eslint/types" "5.62.0" + "@typescript-eslint/typescript-estree" "5.62.0" + eslint-scope "^5.1.1" + semver "^7.3.7" + "@typescript-eslint/visitor-keys@5.30.5": version "5.30.5" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.30.5.tgz#d4bb969202019d5d5d849a0aaedc7370cc044b14" @@ -3199,6 +3249,14 @@ "@typescript-eslint/types" "5.56.0" eslint-visitor-keys "^3.3.0" +"@typescript-eslint/visitor-keys@5.62.0": + version "5.62.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.62.0.tgz#2174011917ce582875954ffe2f6912d5931e353e" + integrity sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw== + dependencies: + "@typescript-eslint/types" "5.62.0" + eslint-visitor-keys "^3.3.0" + "@webassemblyjs/ast@1.9.0": version "1.9.0" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.9.0.tgz#bd850604b4042459a5a41cd7d338cbed695ed964" @@ -3413,10 +3471,10 @@ acorn@^8.2.4, acorn@^8.7.1: resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30" integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A== -acorn@^8.8.0: - version "8.8.2" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a" - integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw== +acorn@^8.9.0: + version "8.10.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5" + integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw== add-stream@^1.0.0: version "1.0.0" @@ -4681,9 +4739,9 @@ camelcase@^6.0.0: integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== caniuse-lite@^1.0.30001039, caniuse-lite@^1.0.30001359: - version "1.0.30001361" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001361.tgz#ba2adb2527566fb96f3ac7c67698ae7fc495a28d" - integrity sha512-ybhCrjNtkFji1/Wto6SSJKkWk6kZgVQsDq5QI83SafsF6FXv2JB4df9eEdH6g8sdGgqTXrFLjAxqBGgYoU3azQ== + version "1.0.30001538" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001538.tgz" + integrity sha512-HWJnhnID+0YMtGlzcp3T9drmBJUVDchPJ08tpUGFLs9CYlwWPH2uLgpHn8fND5pCgXVtnGS3H4QR9XLMHVNkHw== capture-exit@^2.0.0: version "2.0.0" @@ -7493,6 +7551,13 @@ eslint-loader@^4.0.2: object-hash "^2.0.3" schema-utils "^2.6.5" +eslint-plugin-jest@^27.2.3: + version "27.2.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-27.2.3.tgz#6f8a4bb2ca82c0c5d481d1b3be256ab001f5a3ec" + integrity sha512-sRLlSCpICzWuje66Gl9zvdF6mwD5X86I4u55hJyFBsxYOsBCmT5+kSUjf+fkFWVMMgpzNEupjW8WzUqi83hJAQ== + dependencies: + "@typescript-eslint/utils" "^5.10.0" + eslint-plugin-prettier@3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.2.tgz#432e5a667666ab84ce72f945c72f77d996a5c9ba" @@ -7615,6 +7680,14 @@ eslint-scope@^7.0.0, eslint-scope@^7.1.1: esrecurse "^4.3.0" estraverse "^5.2.0" +eslint-scope@^7.2.2: + version "7.2.2" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.2.2.tgz#deb4f92563390f32006894af62a22dba1c46423f" + integrity sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg== + dependencies: + esrecurse "^4.3.0" + estraverse "^5.2.0" + eslint-utils@^1.3.1: version "1.4.3" resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.3.tgz#74fec7c54d0776b6f67e0251040b5806564e981f" @@ -7651,6 +7724,11 @@ eslint-visitor-keys@^3.1.0, eslint-visitor-keys@^3.3.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== +eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4.3: + version "3.4.3" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" + integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== + eslint@5.16.0: version "5.16.0" resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.16.0.tgz#a1e3ac1aae4a3fbd8296fcf8f7ab7314cbb6abea" @@ -7739,27 +7817,27 @@ eslint@^7.32.0: text-table "^0.2.0" v8-compile-cache "^2.0.3" -eslint@^8.36.0: - version "8.36.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.36.0.tgz#1bd72202200a5492f91803b113fb8a83b11285cf" - integrity sha512-Y956lmS7vDqomxlaaQAHVmeb4tNMp2FWIvU/RnU5BD3IKMD/MJPr76xdyr68P8tV1iNMvN2mRK0yy3c+UjL+bw== +eslint@^8.49.0: + version "8.49.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.49.0.tgz#09d80a89bdb4edee2efcf6964623af1054bf6d42" + integrity sha512-jw03ENfm6VJI0jA9U+8H5zfl5b+FvuU3YYvZRdZHOlU2ggJkxrlkJH4HcDrZpj6YwD8kuYqvQM8LyesoazrSOQ== dependencies: "@eslint-community/eslint-utils" "^4.2.0" - "@eslint-community/regexpp" "^4.4.0" - "@eslint/eslintrc" "^2.0.1" - "@eslint/js" "8.36.0" - "@humanwhocodes/config-array" "^0.11.8" + "@eslint-community/regexpp" "^4.6.1" + "@eslint/eslintrc" "^2.1.2" + "@eslint/js" "8.49.0" + "@humanwhocodes/config-array" "^0.11.11" "@humanwhocodes/module-importer" "^1.0.1" "@nodelib/fs.walk" "^1.2.8" - ajv "^6.10.0" + ajv "^6.12.4" chalk "^4.0.0" cross-spawn "^7.0.2" debug "^4.3.2" doctrine "^3.0.0" escape-string-regexp "^4.0.0" - eslint-scope "^7.1.1" - eslint-visitor-keys "^3.3.0" - espree "^9.5.0" + eslint-scope "^7.2.2" + eslint-visitor-keys "^3.4.3" + espree "^9.6.1" esquery "^1.4.2" esutils "^2.0.2" fast-deep-equal "^3.1.3" @@ -7767,22 +7845,19 @@ eslint@^8.36.0: find-up "^5.0.0" glob-parent "^6.0.2" globals "^13.19.0" - grapheme-splitter "^1.0.4" + graphemer "^1.4.0" ignore "^5.2.0" - import-fresh "^3.0.0" imurmurhash "^0.1.4" is-glob "^4.0.0" is-path-inside "^3.0.3" - js-sdsl "^4.1.4" js-yaml "^4.1.0" json-stable-stringify-without-jsonify "^1.0.1" levn "^0.4.1" lodash.merge "^4.6.2" minimatch "^3.1.2" natural-compare "^1.4.0" - optionator "^0.9.1" + optionator "^0.9.3" strip-ansi "^6.0.1" - strip-json-comments "^3.1.0" text-table "^0.2.0" eslint@^8.7.0: @@ -7862,14 +7937,14 @@ espree@^9.0.0, espree@^9.3.2: acorn-jsx "^5.3.2" eslint-visitor-keys "^3.3.0" -espree@^9.5.0: - version "9.5.0" - resolved "https://registry.yarnpkg.com/espree/-/espree-9.5.0.tgz#3646d4e3f58907464edba852fa047e6a27bdf113" - integrity sha512-JPbJGhKc47++oo4JkEoTe2wjy4fmMwvFpgJT9cQzmfXKp22Dr6Hf1tdCteLz1h0P3t+mGvWZ+4Uankvh8+c6zw== +espree@^9.6.0, espree@^9.6.1: + version "9.6.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f" + integrity sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ== dependencies: - acorn "^8.8.0" + acorn "^8.9.0" acorn-jsx "^5.3.2" - eslint-visitor-keys "^3.3.0" + eslint-visitor-keys "^3.4.1" esprima@^4.0.0, esprima@^4.0.1: version "4.0.1" @@ -8897,6 +8972,11 @@ grapheme-splitter@^1.0.4: resolved "https://registry.yarnpkg.com/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz#9cf3a665c6247479896834af35cf1dbb4400767e" integrity sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ== +graphemer@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/graphemer/-/graphemer-1.4.0.tgz#fb2f1d55e0e3a1849aeffc90c4fa0dd53a0e66c6" + integrity sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag== + growly@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" @@ -10655,11 +10735,6 @@ js-levenshtein@^1.1.3: resolved "https://registry.yarnpkg.com/js-levenshtein/-/js-levenshtein-1.1.6.tgz#c6cee58eb3550372df8deb85fad5ce66ce01d59d" integrity sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g== -js-sdsl@^4.1.4: - version "4.4.0" - resolved "https://registry.yarnpkg.com/js-sdsl/-/js-sdsl-4.4.0.tgz#8b437dbe642daa95760400b602378ed8ffea8430" - integrity sha512-FfVSdx6pJ41Oa+CF7RDaFmTnCaFhua+SNYQX74riGOpl96x+2jQCqEfQ2bnXu/5DPCqlRuiqyvTJM0Qjz26IVg== - "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -12807,6 +12882,18 @@ optionator@^0.9.1: type-check "^0.4.0" word-wrap "^1.2.3" +optionator@^0.9.3: + version "0.9.3" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.3.tgz#007397d44ed1872fdc6ed31360190f81814e2c64" + integrity sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg== + dependencies: + "@aashutoshrathi/word-wrap" "^1.2.3" + deep-is "^0.1.3" + fast-levenshtein "^2.0.6" + levn "^0.4.1" + prelude-ls "^1.2.1" + type-check "^0.4.0" + os-browserify@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27" -- GitLab