Skip to content
Snippets Groups Projects
TotalConsumption.spec.tsx 2.57 KiB
Newer Older
  • Learn to ignore specific revisions
  • import { FluidType, TimeStep } from 'enums'
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    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'
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    import TotalConsumption from './TotalConsumption'
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    const mockChartStore = createMockEcolyoStore({
      chart: {
        ...mockChartState,
        currentDatachart: graphData,
    
    Yoan VALLET's avatar
    Yoan VALLET committed
    describe('TotalConsumption component', () => {
    
    Yoan VALLET's avatar
    Yoan VALLET committed
        const component = mount(
    
          <Provider store={mockChartStore}>
            <TotalConsumption fluidType={FluidType.ELECTRICITY} />
    
    Yoan VALLET's avatar
    Yoan VALLET committed
        )
    
        await waitForComponentToPaint(component)
    
    Yoan VALLET's avatar
    Yoan VALLET committed
        expect(component).toMatchSnapshot()
      })
    
    Yoan VALLET's avatar
    Yoan VALLET committed
        const component = mount(
    
          <Provider store={mockChartStore}>
            <TotalConsumption fluidType={FluidType.ELECTRICITY} />
    
    Yoan VALLET's avatar
    Yoan VALLET committed
        )
    
        await waitForComponentToPaint(component)
    
        expect(component.find('.euro-value').first().text()).toEqual('22,77')
    
    Yoan VALLET's avatar
    Yoan VALLET committed
      })
    
        const component = mount(
          <Provider store={mockChartStore}>
            <TotalConsumption fluidType={FluidType.MULTIFLUID} />
          </Provider>
        )
    
        await waitForComponentToPaint(component)
    
    
        expect(component.find('.euro-value').first().text()).toEqual('130,84')
      })
      it('should format multifluid value AND compared value', async () => {
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
        const store = createMockEcolyoStore({
          chart: {
            ...mockChartState,
            currentDatachart: graphData,
            showCompare: true,
            currentTimeStep: TimeStep.DAY,
    
    Yoan VALLET's avatar
    Yoan VALLET committed
        const component = mount(
    
            <TotalConsumption fluidType={FluidType.MULTIFLUID} />
    
    Yoan VALLET's avatar
    Yoan VALLET committed
        )
    
        await waitForComponentToPaint(component)
    
        expect(component.find('.euro-value').first().text()).toEqual('130,84')
    
        expect(component.find('.euro-value').at(1).text()).toEqual('110,66')
    
    Yoan VALLET's avatar
    Yoan VALLET committed
      })
    
      it('should display ----- when half an hour electricity data is not activated', async () => {
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
        const store = createMockEcolyoStore()
    
          <Provider store={store}>
            <TotalConsumption fluidType={FluidType.ELECTRICITY} />
    
        await waitForComponentToPaint(component)
    
        expect(component.find('.euro-value').first().text()).toEqual('-----')
    
    Yoan VALLET's avatar
    Yoan VALLET committed
    })