Newer
Older
import MonthlyAnalysis from 'components/Analysis/MonthlyAnalysis'
import toJson from 'enzyme-to-json'
import { PerformanceIndicator } from 'models'
import { BrowserRouter } from 'react-router-dom'
import { createMockEcolyoStore } from 'tests/__mocks__/store'
import { waitForComponentToPaint } from 'tests/__mocks__/testUtils'
const mockPI: PerformanceIndicator[] = [
{ value: 5, compareValue: 10, percentageVariation: 50 },
{ value: 5, compareValue: 10, percentageVariation: 50 },
]
jest.mock('services/consumption.service', () => {
return jest.fn(() => {
return {
getFluidsWithDataForTimePeriod: jest.fn(() => [0, 1, 2]),
getFluidsWithIncompleteData: jest.fn(() => [0]),
getPerformanceIndicators: jest.fn(() => mockPI),
}
})
})
jest.mock('components/Analysis/Comparison/Comparison', () => 'mock-comparison')
jest.mock(
'components/Analysis/TotalAnalysisChart/TotalAnalysisChart',
() => 'mock-total-analysis'
)
jest.mock(
'components/Analysis/MaxConsumptionCard/MaxConsumptionCard',
() => 'mock-max-consumption'
)
jest.mock(
'components/Analysis/ProfileComparator/ProfileComparator',
() => 'mock-analysis'
)
jest.mock(
'components/Analysis/ElecHalfHourMonthlyAnalysis/ElecHalfHourMonthlyAnalysis',
() => 'mock-half-hour-analysis'
)
window.scrollTo = jest.fn()
it('should be rendered correctly', async () => {
<BrowserRouter>
<Provider store={store}>
<MonthlyAnalysis
saveLastScrollPosition={jest.fn()}
scrollPosition={0}
/>
</Provider>
</BrowserRouter>
)
await waitForComponentToPaint(wrapper)
expect(toJson(wrapper)).toMatchSnapshot()