-
Notifications
You must be signed in to change notification settings - Fork 177
/
SectionList.test.tsx
94 lines (90 loc) · 3.36 KB
/
SectionList.test.tsx
1
2
3
4
5
6
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
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
import { renderWithProviders } from '@opentrons/components'
import * as React from 'react'
import { i18n } from '../../../../i18n'
import { SectionList } from '../SectionList'
import { Section } from '../types'
const MOCK_SECTIONS_1_PIPETTE_2_STEPS = [
'PRIMARY_PIPETTE_TIPRACKS',
'RETURN_TIP',
] as Section[]
const MOCK_SECTIONS_2_PIPETTES_3_STEPS = [
'PRIMARY_PIPETTE_TIPRACKS',
'SECONDARY_PIPETTE_TIPRACKS',
'RETURN_TIP',
] as Section[]
const MOCK_SECTIONS_2_PIPETTES_4_STEPS = [
'PRIMARY_PIPETTE_TIPRACKS',
'SECONDARY_PIPETTE_TIPRACKS',
'CHECK_REMAINING_LABWARE_WITH_PRIMARY_PIPETTE',
'RETURN_TIP',
] as Section[]
const render = (props: React.ComponentProps<typeof SectionList>) => {
return renderWithProviders(<SectionList {...props} />, {
i18nInstance: i18n,
})[0]
}
describe('SectionList', () => {
let props: React.ComponentProps<typeof SectionList>
beforeEach(() => {
props = {
sections: MOCK_SECTIONS_1_PIPETTE_2_STEPS,
currentSection: 'PRIMARY_PIPETTE_TIPRACKS',
primaryPipetteMount: 'left',
secondaryPipetteMount: '',
}
})
it('renders a 2 step Nav with 1 pipette', () => {
const { getByText } = render(props)
expect(getByText('1')).toHaveStyle('backgroundColor: #00c3e6')
getByText('Check tipracks with Left Pipette')
expect(getByText('2')).toHaveStyle('backgroundColor: C_DISABLED')
getByText('Return tip')
})
it('renders a 3 step Nav with 2 pipettes', () => {
props = {
sections: MOCK_SECTIONS_2_PIPETTES_3_STEPS,
currentSection: 'PRIMARY_PIPETTE_TIPRACKS',
primaryPipetteMount: 'left',
secondaryPipetteMount: 'right',
}
const { getByText } = render(props)
expect(getByText('1')).toHaveStyle('backgroundColor: #00c3e6')
getByText('Check tipracks with Left Pipette')
expect(getByText('2')).toHaveStyle('backgroundColor: C_DISABLED')
getByText('Check tipracks with Right Pipette')
expect(getByText('3')).toHaveStyle('backgroundColor: C_DISABLED')
getByText('Return tip')
})
it('renders a 4 step Nav with 2 pipettes', () => {
props = {
sections: MOCK_SECTIONS_2_PIPETTES_4_STEPS,
currentSection: 'PRIMARY_PIPETTE_TIPRACKS',
primaryPipetteMount: 'left',
secondaryPipetteMount: 'right',
}
const { getByText } = render(props)
expect(getByText('1')).toHaveStyle('backgroundColor: #00c3e6')
getByText('Check tipracks with Left Pipette')
expect(getByText('2')).toHaveStyle('backgroundColor: C_DISABLED')
getByText('Check tipracks with Right Pipette')
expect(getByText('3')).toHaveStyle('backgroundColor: C_DISABLED')
getByText('Check remaining labware with Left Pipette')
expect(getByText('4')).toHaveStyle('backgroundColor: C_DISABLED')
getByText('Return tip')
})
it('renders a 3 step Nav with 2 pipettes and on the second step', () => {
props = {
sections: MOCK_SECTIONS_2_PIPETTES_3_STEPS,
currentSection: 'SECONDARY_PIPETTE_TIPRACKS',
primaryPipetteMount: 'left',
secondaryPipetteMount: 'right',
completedSections: ['PRIMARY_PIPETTE_TIPRACKS'],
}
const { getByText } = render(props)
getByText('Check tipracks with Left Pipette')
expect(getByText('2')).toHaveStyle('backgroundColor: #00c3e6')
getByText('Check tipracks with Right Pipette')
expect(getByText('3')).toHaveStyle('backgroundColor: C_DISABLED')
getByText('Return tip')
})
})