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

Fix tests

parent 6072a33a
No related branches found
No related tags found
1 merge request!348Features/create aggregation usage service
......@@ -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({
......
......@@ -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', () => {
......
......@@ -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],
})
......
......@@ -32,6 +32,7 @@ exports[`LegalNoticeView component should be rendered correctly 1`] = `
>
<div
className="card"
onClick={[Function]}
>
<div
className="legal-notice-card"
......
......@@ -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')
......
......@@ -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],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment