Newer
Older
import { TimeStep } from 'enums'
import { DateTime } from 'luxon'
import React from 'react'
import { Provider } from 'react-redux'
import { graphData } from 'tests/__mocks__/chartData.mock'
import { createMockEcolyoStore } from 'tests/__mocks__/store'
const mockXScale: ScaleBand<string> = scaleBand()
.domain(['0', '10'])
.range([0, 100])
.padding(0.2)
const mockProps = {
data: graphData.actualData,
xScale: mockXScale,
height: 20,
marginLeft: 10,
marginBottom: 10,
}
describe('AxisBottom component test', () => {
const store = createMockEcolyoStore({
chart: {
selectedDate: DateTime.fromISO('2020-10-01T00:00:00.000Z', {
zone: 'utc',
}),
},
})
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
it('should correctly render YEAR format of AxisBottom', () => {
const wrapper = mount(
<Provider store={store}>
<svg>
<AxisBottom {...mockProps} timeStep={TimeStep.YEAR} />
</svg>
</Provider>
)
expect(wrapper.getElement()).toMatchSnapshot()
})
it('should correctly render MONTH format of AxisBottom', () => {
const wrapper = mount(
<Provider store={store}>
<svg>
<AxisBottom {...mockProps} timeStep={TimeStep.MONTH} />
</svg>
</Provider>
)
expect(wrapper.getElement()).toMatchSnapshot()
})
it('should correctly render DAY format of AxisBottom without duel', () => {
const wrapper = mount(
<Provider store={store}>
<svg>
<AxisBottom {...mockProps} timeStep={TimeStep.DAY} />
</svg>
</Provider>
)
expect(wrapper.getElement()).toMatchSnapshot()
})
it('should correctly render DAY format of AxisBottom with duel', () => {
const wrapper = mount(
<Provider store={store}>
<svg>
<AxisBottom {...mockProps} timeStep={TimeStep.DAY} isDuel={true} />
</svg>
</Provider>
)
expect(wrapper.getElement()).toMatchSnapshot()
})
it('should correctly render WEEK format of AxisBottom', () => {
const wrapper = mount(
<Provider store={store}>
<svg>
<AxisBottom {...mockProps} timeStep={TimeStep.WEEK} />
</svg>
</Provider>
)
expect(wrapper.getElement()).toMatchSnapshot()
})
it('should correctly render HALF_AN_HOUR format of AxisBottom', () => {
const wrapper = mount(
<Provider store={store}>
<svg>
<AxisBottom {...mockProps} timeStep={TimeStep.HALF_AN_HOUR} />
</svg>
</Provider>
)
expect(wrapper.getElement()).toMatchSnapshot()
})
})