Skip to content
Snippets Groups Projects
ConsumptionDetails.spec.tsx 1.55 KiB
Newer Older
  • Learn to ignore specific revisions
  • import { FluidType } from 'enums'
    
    Yoan VALLET's avatar
    Yoan VALLET committed
    import { mount } from 'enzyme'
    
    import toJson from 'enzyme-to-json'
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    import React from 'react'
    import { Provider } from 'react-redux'
    
    import { createMockEcolyoStore } from 'tests/__mocks__/store'
    import { waitForComponentToPaint } from 'tests/__mocks__/testUtils'
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    import ConsumptionDetails from './ConsumptionDetails'
    
    Yoan VALLET's avatar
    Yoan VALLET committed
    
    describe('ConsumptionDetails component', () => {
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
      const store = createMockEcolyoStore()
    
      it('should be rendered correctly', async () => {
    
    Yoan VALLET's avatar
    Yoan VALLET committed
        const wrapper = mount(
          <Provider store={store}>
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
            <ConsumptionDetails fluidType={FluidType.ELECTRICITY} />
    
    Yoan VALLET's avatar
    Yoan VALLET committed
          </Provider>
        )
    
        await waitForComponentToPaint(wrapper)
        expect(toJson(wrapper)).toMatchSnapshot()
    
    Yoan VALLET's avatar
    Yoan VALLET committed
      })
    
    
      it('should not render connection card', () => {
    
    Yoan VALLET's avatar
    Yoan VALLET committed
        const wrapper = mount(
          <Provider store={store}>
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
            <ConsumptionDetails fluidType={FluidType.MULTIFLUID} />
    
    Yoan VALLET's avatar
    Yoan VALLET committed
          </Provider>
        )
        expect(wrapper.contains('.fluidcard-link')).toBeFalsy()
      })
    
      it('should render one connection card', () => {
    
    Yoan VALLET's avatar
    Yoan VALLET committed
        const wrapper = mount(
          <Provider store={store}>
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
            <ConsumptionDetails fluidType={FluidType.MULTIFLUID} />
    
    Yoan VALLET's avatar
    Yoan VALLET committed
          </Provider>
        )
        expect(wrapper.find('.fluidcard-link')).toBeTruthy()
      })
      it('should not render connection card and show multifluid link', () => {
        const wrapper = mount(
          <Provider store={store}>
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
            <ConsumptionDetails fluidType={FluidType.ELECTRICITY} />
    
    Yoan VALLET's avatar
    Yoan VALLET committed
          </Provider>
        )
        expect(wrapper.find('.multi-link')).toBeTruthy()
      })
    })