Newer
Older
import { FluidType, TimeStep } from 'enums'
import { mount } from 'enzyme'
import React from 'react'
import { Provider } from 'react-redux'
import { graphData } from 'tests/__mocks__/chartData.mock'
import { createMockEcolyoStore, mockChartState } from 'tests/__mocks__/store'
import { waitForComponentToPaint } from 'tests/__mocks__/testUtils'

Rémi PAILHAREY
committed
const mockChartStore = createMockEcolyoStore({
chart: {
...mockChartState,
currentDatachart: graphData,

Rémi PAILHAREY
committed
},
})

Rémi PAILHAREY
committed
it('should be rendered correctly', async () => {
<Provider store={mockChartStore}>
<TotalConsumption fluidType={FluidType.ELECTRICITY} />

Rémi PAILHAREY
committed
</Provider>

Rémi PAILHAREY
committed
it('should render euro value', async () => {
<Provider store={mockChartStore}>
<TotalConsumption fluidType={FluidType.ELECTRICITY} />

Rémi PAILHAREY
committed
</Provider>

Rémi PAILHAREY
committed
expect(component.find('.euro-value').first().text()).toEqual('22,77')

Rémi PAILHAREY
committed
it('should format multifluid value', async () => {
const component = mount(
<Provider store={mockChartStore}>
<TotalConsumption fluidType={FluidType.MULTIFLUID} />
</Provider>
)
expect(component.find('.euro-value').first().text()).toEqual('130,84')
})
it('should format multifluid value AND compared value', async () => {
const store = createMockEcolyoStore({
chart: {
...mockChartState,
currentDatachart: graphData,
showCompare: true,
currentTimeStep: TimeStep.DAY,

Rémi PAILHAREY
committed
<Provider store={store}>
<TotalConsumption fluidType={FluidType.MULTIFLUID} />

Rémi PAILHAREY
committed
</Provider>

Rémi PAILHAREY
committed
expect(component.find('.euro-value').first().text()).toEqual('130,84')
expect(component.find('.euro-value').at(1).text()).toEqual('110,66')

Rémi PAILHAREY
committed
it('should display ----- when half an hour electricity data is not activated', async () => {

Rémi PAILHAREY
committed
const component = mount(
<Provider store={store}>
<TotalConsumption fluidType={FluidType.ELECTRICITY} />

Rémi PAILHAREY
committed
</Provider>
)

Rémi PAILHAREY
committed
expect(component.find('.euro-value').first().text()).toEqual('-----')

Rémi PAILHAREY
committed
})