Skip to content
Snippets Groups Projects
Commit fe4288e2 authored by Guilhem CARRON's avatar Guilhem CARRON
Browse files

Fix tests

parent 6072a33a
Branches
Tags
1 merge request!348Features/create aggregation usage service
...@@ -10,6 +10,7 @@ import { Button } from '@material-ui/core' ...@@ -10,6 +10,7 @@ import { Button } from '@material-ui/core'
import * as reactRedux from 'react-redux' import * as reactRedux from 'react-redux'
import * as challengeActions from 'store/challenge/challenge.actions' import * as challengeActions from 'store/challenge/challenge.actions'
import { act } from '@testing-library/react' import { act } from '@testing-library/react'
import UsageEventService from 'services/usageEvent.service'
const mockStore = configureStore([]) const mockStore = configureStore([])
jest.mock('cozy-ui/transpiled/react/I18n', () => { jest.mock('cozy-ui/transpiled/react/I18n', () => {
...@@ -21,6 +22,10 @@ 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() const mockHistoryGoBack = jest.fn()
jest.mock('react-router-dom', () => ({ jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'), ...jest.requireActual('react-router-dom'),
...@@ -36,6 +41,7 @@ jest.mock('services/challenge.service', () => { ...@@ -36,6 +41,7 @@ jest.mock('services/challenge.service', () => {
} }
}) })
}) })
describe('ActionDone component', () => { describe('ActionDone component', () => {
it('should be rendered correctly', () => { it('should be rendered correctly', () => {
const store = mockStore({ const store = mockStore({
......
...@@ -11,6 +11,7 @@ import { Button } from '@material-ui/core' ...@@ -11,6 +11,7 @@ import { Button } from '@material-ui/core'
import * as reactRedux from 'react-redux' import * as reactRedux from 'react-redux'
import * as challengeActions from 'store/challenge/challenge.actions' import * as challengeActions from 'store/challenge/challenge.actions'
import { act } from '@testing-library/react' import { act } from '@testing-library/react'
import UsageEventService from 'services/usageEvent.service'
jest.mock('cozy-ui/transpiled/react/I18n', () => { jest.mock('cozy-ui/transpiled/react/I18n', () => {
return { return {
...@@ -29,6 +30,9 @@ jest.mock('services/challenge.service', () => { ...@@ -29,6 +30,9 @@ jest.mock('services/challenge.service', () => {
} }
}) })
}) })
jest.mock('services/usageEvent.service')
const mockAddEvent = jest.fn()
UsageEventService.addEvent = mockAddEvent
const mockStore = configureStore([]) const mockStore = configureStore([])
describe('ActionModal component', () => { describe('ActionModal component', () => {
......
...@@ -56,8 +56,8 @@ const Bar = ({ ...@@ -56,8 +56,8 @@ const Bar = ({
const fluidStyle = const fluidStyle =
fluidType === FluidType.MULTIFLUID ? 'MULTIFLUID' : FluidType[fluidType] fluidType === FluidType.MULTIFLUID ? 'MULTIFLUID' : FluidType[fluidType]
const handleClick = async () => { const handleClick = () => {
await UsageEventService.addEvent(client, { UsageEventService.addEvent(client, {
type: UsageEventType.CONSUMPTION_INTERACT_EVENT, type: UsageEventType.CONSUMPTION_INTERACT_EVENT,
context: FluidType[fluidType] + ' / ' + TimeStep[timeStep], context: FluidType[fluidType] + ' / ' + TimeStep[timeStep],
}) })
......
...@@ -32,6 +32,7 @@ exports[`LegalNoticeView component should be rendered correctly 1`] = ` ...@@ -32,6 +32,7 @@ exports[`LegalNoticeView component should be rendered correctly 1`] = `
> >
<div <div
className="card" className="card"
onClick={[Function]}
> >
<div <div
className="legal-notice-card" className="legal-notice-card"
......
...@@ -11,6 +11,7 @@ import * as chartActions from 'store/chart/chart.actions' ...@@ -11,6 +11,7 @@ import * as chartActions from 'store/chart/chart.actions'
import { FluidType } from 'enum/fluid.enum' import { FluidType } from 'enum/fluid.enum'
import { TimeStep } from 'enum/timeStep.enum' import { TimeStep } from 'enum/timeStep.enum'
import { DateTime } from 'luxon' import { DateTime } from 'luxon'
import UsageEventService from 'services/usageEvent.service'
jest.mock('cozy-ui/transpiled/react/I18n', () => { jest.mock('cozy-ui/transpiled/react/I18n', () => {
return { return {
...@@ -21,6 +22,9 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => { ...@@ -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 useSelectorSpy = jest.spyOn(reactRedux, 'useSelector')
const useDispatchSpy = jest.spyOn(reactRedux, 'useDispatch') const useDispatchSpy = jest.spyOn(reactRedux, 'useDispatch')
......
...@@ -50,7 +50,7 @@ const TimeStepSelector: React.FC<TimeStepSelectorProps> = ({ ...@@ -50,7 +50,7 @@ const TimeStepSelector: React.FC<TimeStepSelectorProps> = ({
? [...timeStepElecArray] ? [...timeStepElecArray]
: [...timeStepMultiArray] : [...timeStepMultiArray]
const handleZoomInClick = async () => { const handleZoomInClick = () => {
const previousTimeStep: TimeStep = dateChartService.definePreviousTimeStep( const previousTimeStep: TimeStep = dateChartService.definePreviousTimeStep(
currentTimeStep currentTimeStep
) )
...@@ -58,7 +58,7 @@ const TimeStepSelector: React.FC<TimeStepSelectorProps> = ({ ...@@ -58,7 +58,7 @@ const TimeStepSelector: React.FC<TimeStepSelectorProps> = ({
previousTimeStep, previousTimeStep,
selectedDate selectedDate
) )
await UsageEventService.addEvent(client, { UsageEventService.addEvent(client, {
type: UsageEventType.CONSUMPTION_CHANGE_TIMESTEP_EVENT, type: UsageEventType.CONSUMPTION_CHANGE_TIMESTEP_EVENT,
target: TimeStep[previousTimeStep], target: TimeStep[previousTimeStep],
context: FluidType[fluidType], context: FluidType[fluidType],
...@@ -66,7 +66,7 @@ const TimeStepSelector: React.FC<TimeStepSelectorProps> = ({ ...@@ -66,7 +66,7 @@ const TimeStepSelector: React.FC<TimeStepSelectorProps> = ({
dispatch(setCurrentTimeStep(previousTimeStep)) dispatch(setCurrentTimeStep(previousTimeStep))
dispatch(setCurrentIndex(index)) dispatch(setCurrentIndex(index))
} }
const handleZoomOutClick = async () => { const handleZoomOutClick = () => {
const nextTimeStep: TimeStep = dateChartService.defineNextTimeStep( const nextTimeStep: TimeStep = dateChartService.defineNextTimeStep(
currentTimeStep currentTimeStep
) )
...@@ -74,7 +74,7 @@ const TimeStepSelector: React.FC<TimeStepSelectorProps> = ({ ...@@ -74,7 +74,7 @@ const TimeStepSelector: React.FC<TimeStepSelectorProps> = ({
nextTimeStep, nextTimeStep,
selectedDate selectedDate
) )
await UsageEventService.addEvent(client, { UsageEventService.addEvent(client, {
type: UsageEventType.CONSUMPTION_CHANGE_TIMESTEP_EVENT, type: UsageEventType.CONSUMPTION_CHANGE_TIMESTEP_EVENT,
target: TimeStep[nextTimeStep], target: TimeStep[nextTimeStep],
context: FluidType[fluidType], context: FluidType[fluidType],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment