diff --git a/src/components/Action/ActionDone.spec.tsx b/src/components/Action/ActionDone.spec.tsx index 5b84261409c7ad4f7e4be626ab60721f9da9a015..522984b9cd0e0316820df426b0f8186377299812 100644 --- a/src/components/Action/ActionDone.spec.tsx +++ b/src/components/Action/ActionDone.spec.tsx @@ -10,6 +10,7 @@ import { Button } from '@material-ui/core' import * as reactRedux from 'react-redux' import * as challengeActions from 'store/challenge/challenge.actions' import { act } from '@testing-library/react' +import UsageEventService from 'services/usageEvent.service' const mockStore = configureStore([]) jest.mock('cozy-ui/transpiled/react/I18n', () => { @@ -21,6 +22,10 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => { }), } }) +jest.mock('services/usageEvent.service') +const mockAddEvent = jest.fn() +UsageEventService.addEvent = mockAddEvent + const mockHistoryGoBack = jest.fn() jest.mock('react-router-dom', () => ({ ...jest.requireActual('react-router-dom'), @@ -36,6 +41,7 @@ jest.mock('services/challenge.service', () => { } }) }) + describe('ActionDone component', () => { it('should be rendered correctly', () => { const store = mockStore({ diff --git a/src/components/Action/ActionModal.spec.tsx b/src/components/Action/ActionModal.spec.tsx index b39dddcd7873cc4c3407ba564fc398bd6b2bda86..3b74060117d5a25eb4fe1ff893131d3574fff81c 100644 --- a/src/components/Action/ActionModal.spec.tsx +++ b/src/components/Action/ActionModal.spec.tsx @@ -11,6 +11,7 @@ import { Button } from '@material-ui/core' import * as reactRedux from 'react-redux' import * as challengeActions from 'store/challenge/challenge.actions' import { act } from '@testing-library/react' +import UsageEventService from 'services/usageEvent.service' jest.mock('cozy-ui/transpiled/react/I18n', () => { return { @@ -29,6 +30,9 @@ jest.mock('services/challenge.service', () => { } }) }) +jest.mock('services/usageEvent.service') +const mockAddEvent = jest.fn() +UsageEventService.addEvent = mockAddEvent const mockStore = configureStore([]) describe('ActionModal component', () => { diff --git a/src/components/Charts/Bar.tsx b/src/components/Charts/Bar.tsx index 828ac75aa03df9084fb45accaef1927fff029eb3..1f66edfcb83879003af990386d897bd6c5f1f1ca 100644 --- a/src/components/Charts/Bar.tsx +++ b/src/components/Charts/Bar.tsx @@ -56,8 +56,8 @@ const Bar = ({ const fluidStyle = fluidType === FluidType.MULTIFLUID ? 'MULTIFLUID' : FluidType[fluidType] - const handleClick = async () => { - await UsageEventService.addEvent(client, { + const handleClick = () => { + UsageEventService.addEvent(client, { type: UsageEventType.CONSUMPTION_INTERACT_EVENT, context: FluidType[fluidType] + ' / ' + TimeStep[timeStep], }) diff --git a/src/components/LegalNotice/__snapshots__/LegalNoticeLink.spec.tsx.snap b/src/components/LegalNotice/__snapshots__/LegalNoticeLink.spec.tsx.snap index 8d9f2c491c1bf079f4f02d52aa0d168567823ddf..ac8a61cbeabbada2c7acbcb919e2417a5fe15cd5 100644 --- a/src/components/LegalNotice/__snapshots__/LegalNoticeLink.spec.tsx.snap +++ b/src/components/LegalNotice/__snapshots__/LegalNoticeLink.spec.tsx.snap @@ -32,6 +32,7 @@ exports[`LegalNoticeView component should be rendered correctly 1`] = ` > <div className="card" + onClick={[Function]} > <div className="legal-notice-card" diff --git a/src/components/TimeStepSelector/TimeStepSelector.spec.tsx b/src/components/TimeStepSelector/TimeStepSelector.spec.tsx index 66b8364a4fec088d538a7ed99af23d01c92e9d56..7ddc8bb8d6b3220b3d8708b454e6e34cefbba7b7 100644 --- a/src/components/TimeStepSelector/TimeStepSelector.spec.tsx +++ b/src/components/TimeStepSelector/TimeStepSelector.spec.tsx @@ -11,6 +11,7 @@ import * as chartActions from 'store/chart/chart.actions' import { FluidType } from 'enum/fluid.enum' import { TimeStep } from 'enum/timeStep.enum' import { DateTime } from 'luxon' +import UsageEventService from 'services/usageEvent.service' jest.mock('cozy-ui/transpiled/react/I18n', () => { return { @@ -21,6 +22,9 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => { }), } }) +jest.mock('services/usageEvent.service') +const mockAddEvent = jest.fn() +UsageEventService.addEvent = mockAddEvent const useSelectorSpy = jest.spyOn(reactRedux, 'useSelector') const useDispatchSpy = jest.spyOn(reactRedux, 'useDispatch') diff --git a/src/components/TimeStepSelector/TimeStepSelector.tsx b/src/components/TimeStepSelector/TimeStepSelector.tsx index 6576cec1d46e58795cf884dfcbfd898763c33079..3b9d04a70d6fa2215ee24e4736cbc0dafc2ca436 100644 --- a/src/components/TimeStepSelector/TimeStepSelector.tsx +++ b/src/components/TimeStepSelector/TimeStepSelector.tsx @@ -50,7 +50,7 @@ const TimeStepSelector: React.FC<TimeStepSelectorProps> = ({ ? [...timeStepElecArray] : [...timeStepMultiArray] - const handleZoomInClick = async () => { + const handleZoomInClick = () => { const previousTimeStep: TimeStep = dateChartService.definePreviousTimeStep( currentTimeStep ) @@ -58,7 +58,7 @@ const TimeStepSelector: React.FC<TimeStepSelectorProps> = ({ previousTimeStep, selectedDate ) - await UsageEventService.addEvent(client, { + UsageEventService.addEvent(client, { type: UsageEventType.CONSUMPTION_CHANGE_TIMESTEP_EVENT, target: TimeStep[previousTimeStep], context: FluidType[fluidType], @@ -66,7 +66,7 @@ const TimeStepSelector: React.FC<TimeStepSelectorProps> = ({ dispatch(setCurrentTimeStep(previousTimeStep)) dispatch(setCurrentIndex(index)) } - const handleZoomOutClick = async () => { + const handleZoomOutClick = () => { const nextTimeStep: TimeStep = dateChartService.defineNextTimeStep( currentTimeStep ) @@ -74,7 +74,7 @@ const TimeStepSelector: React.FC<TimeStepSelectorProps> = ({ nextTimeStep, selectedDate ) - await UsageEventService.addEvent(client, { + UsageEventService.addEvent(client, { type: UsageEventType.CONSUMPTION_CHANGE_TIMESTEP_EVENT, target: TimeStep[nextTimeStep], context: FluidType[fluidType],