Newer
Older
import { DataloadSectionType, FluidType } from 'enums'
import { mount } from 'enzyme'
import toJson from 'enzyme-to-json'
import { Dataload } from 'models'
import { baseDataLoad } from 'tests/__mocks__/chartData.mock'
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import DataloadSection from './DataloadSection'
jest.mock(
'components/ConsumptionVisualizer/DataloadSectionValue',
() => 'mock-dataloadsectionvalue'
)
jest.mock(
'components/ConsumptionVisualizer/DataloadSectionDetail',
() => 'mock-dataloadsectiondetail'
)
const mockToggleEstimationModal = jest.fn()
describe('DataloadSection component', () => {
const mockDataload: Dataload = baseDataLoad
it('should render correctly', () => {
const wrapper = mount(
<DataloadSection
dataload={mockDataload}
fluidType={FluidType.ELECTRICITY}
dataloadSectionType={DataloadSectionType.NO_COMPARE}
toggleEstimationModal={mockToggleEstimationModal}
/>
)
expect(toJson(wrapper)).toMatchSnapshot()
})
it('should render no_data when dataload value is -1 and section is left', () => {
const _mockDatalaod = { ...mockDataload, value: -1 }
const wrapper = mount(
<DataloadSection
dataload={_mockDatalaod}
fluidType={FluidType.ELECTRICITY}
dataloadSectionType={DataloadSectionType.LEFT}
toggleEstimationModal={mockToggleEstimationModal}
/>
)
expect(wrapper.find('.dataloadvisualizer-novalue').text()).toBe(
'consumption_visualizer.no_data'
)
})
})