@telus-uds/components-base 1.26.0 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -2
- package/component-docs.json +2 -1
- package/lib/Carousel/dictionary.js +6 -6
- package/lib-module/Carousel/dictionary.js +6 -6
- package/package.json +2 -2
- package/src/Carousel/dictionary.js +6 -6
- package/.eslintrc.js +0 -9
- package/__tests17__/A11yText/A11yText.test.jsx +0 -34
- package/__tests17__/ActivityIndicator/ActivityIndicator.test.jsx +0 -68
- package/__tests17__/ActivityIndicator/__snapshots__/ActivityIndicator.test.jsx.snap +0 -299
- package/__tests17__/Box/Box.test.jsx +0 -111
- package/__tests17__/Button/Button.test.jsx +0 -86
- package/__tests17__/Button/ButtonBase.test.jsx +0 -82
- package/__tests17__/Button/ButtonGroup.test.jsx +0 -347
- package/__tests17__/Button/ButtonLink.test.jsx +0 -61
- package/__tests17__/Card/Card.test.jsx +0 -63
- package/__tests17__/Carousel/Carousel.test.jsx +0 -128
- package/__tests17__/Carousel/CarouselTabs.test.jsx +0 -142
- package/__tests17__/Checkbox/Checkbox.test.jsx +0 -94
- package/__tests17__/Checkbox/CheckboxGroup.test.jsx +0 -246
- package/__tests17__/Divider/Divider.test.jsx +0 -91
- package/__tests17__/ExpandCollapse/ExpandCollapse.test.jsx +0 -109
- package/__tests17__/Feedback/Feedback.test.jsx +0 -42
- package/__tests17__/FlexGrid/Col.test.jsx +0 -261
- package/__tests17__/FlexGrid/FlexGrid.test.jsx +0 -136
- package/__tests17__/FlexGrid/Row.test.jsx +0 -273
- package/__tests17__/HorizontalScroll/HorizontalScroll.test.jsx +0 -165
- package/__tests17__/Icon/Icon.test.jsx +0 -61
- package/__tests17__/IconButton/IconButton.test.jsx +0 -52
- package/__tests17__/InputLabel/InputLabel.test.jsx +0 -28
- package/__tests17__/InputLabel/__snapshots__/InputLabel.test.jsx.snap +0 -3
- package/__tests17__/InputSupports/InputSupports.test.jsx +0 -60
- package/__tests17__/Link/Link.test.jsx +0 -63
- package/__tests17__/Link/TextButton.test.jsx +0 -35
- package/__tests17__/List/List.test.jsx +0 -82
- package/__tests17__/Modal/Modal.test.jsx +0 -47
- package/__tests17__/Notification/Notification.test.jsx +0 -20
- package/__tests17__/Pagination/Pagination.test.jsx +0 -160
- package/__tests17__/Progress/Progress.test.jsx +0 -79
- package/__tests17__/Radio/Radio.test.jsx +0 -87
- package/__tests17__/Radio/RadioGroup.test.jsx +0 -220
- package/__tests17__/RadioCard/RadioCard.test.jsx +0 -87
- package/__tests17__/RadioCard/RadioCardGroup.test.jsx +0 -246
- package/__tests17__/Search/Search.test.jsx +0 -87
- package/__tests17__/Select/Select.test.jsx +0 -94
- package/__tests17__/SideNav/SideNav.test.jsx +0 -110
- package/__tests17__/Skeleton/Skeleton.test.jsx +0 -61
- package/__tests17__/SkipLink/SkipLink.test.jsx +0 -61
- package/__tests17__/Spacer/Spacer.test.jsx +0 -63
- package/__tests17__/StackView/StackView.test.jsx +0 -211
- package/__tests17__/StackView/StackWrap.test.jsx +0 -47
- package/__tests17__/StackView/getStackedContent.test.jsx +0 -295
- package/__tests17__/StepTracker/StepTracker.test.jsx +0 -108
- package/__tests17__/Tabs/Tabs.test.jsx +0 -49
- package/__tests17__/Tags/Tags.test.jsx +0 -327
- package/__tests17__/TextInput/TextArea.test.jsx +0 -35
- package/__tests17__/TextInput/TextInputBase.test.jsx +0 -125
- package/__tests17__/ThemeProvider/ThemeProvider.test.jsx +0 -82
- package/__tests17__/ThemeProvider/useThemeTokens.test.jsx +0 -514
- package/__tests17__/ThemeProvider/utils/theme-tokens.test.js +0 -41
- package/__tests17__/ToggleSwitch/ToggleSwitch.test.jsx +0 -82
- package/__tests17__/ToggleSwitch/ToggleSwitchGroup.test.jsx +0 -192
- package/__tests17__/Tooltip/Tooltip.test.jsx +0 -65
- package/__tests17__/Tooltip/getTooltipPosition.test.js +0 -79
- package/__tests17__/Typography/typography.test.jsx +0 -90
- package/__tests17__/utils/children.test.jsx +0 -128
- package/__tests17__/utils/containUniqueFields.test.js +0 -25
- package/__tests17__/utils/input.test.js +0 -375
- package/__tests17__/utils/props.test.js +0 -36
- package/__tests17__/utils/semantics.test.jsx +0 -34
- package/__tests17__/utils/useCopy.test.js +0 -42
- package/__tests17__/utils/useResponsiveProp.test.jsx +0 -202
- package/__tests17__/utils/useSpacingScale.test.jsx +0 -273
- package/__tests17__/utils/useUniqueId.test.js +0 -31
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
import React, { Fragment } from 'react'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
import { View } from 'react-native'
|
|
4
|
-
import { render } from '@testing-library/react-native'
|
|
5
|
-
|
|
6
|
-
import Theme from '../../__fixtures__/Theme'
|
|
7
|
-
import { getStackedContent, Typography } from '../../src'
|
|
8
|
-
|
|
9
|
-
// Make test composition simpler by wrapping getStackedContent in a component
|
|
10
|
-
const StackedContent = ({ children, ...props }) => <View>{getStackedContent(children, props)}</View>
|
|
11
|
-
StackedContent.propTypes = { children: PropTypes.node }
|
|
12
|
-
|
|
13
|
-
describe('getStackedContent (Spacers)', () => {
|
|
14
|
-
it('renders spacers between simple children', () => {
|
|
15
|
-
const { queryAllByTestId } = render(
|
|
16
|
-
<StackedContent space={1}>
|
|
17
|
-
<Typography>A</Typography>
|
|
18
|
-
<Typography>B</Typography>
|
|
19
|
-
<Typography>C</Typography>
|
|
20
|
-
</StackedContent>,
|
|
21
|
-
{ wrapper: Theme }
|
|
22
|
-
)
|
|
23
|
-
expect(queryAllByTestId(/Stack-Spacer/)).toHaveLength(2)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('gives spacers sizes according to own space prop and spacing scale', () => {
|
|
27
|
-
const expectedSize = 8 // from __fixtures__/testTheme.js
|
|
28
|
-
const expectedStyle = { height: expectedSize }
|
|
29
|
-
|
|
30
|
-
const { getByTestId } = render(
|
|
31
|
-
<StackedContent space={2}>
|
|
32
|
-
<Typography>A</Typography>
|
|
33
|
-
<Typography>B</Typography>
|
|
34
|
-
<Typography>C</Typography>
|
|
35
|
-
</StackedContent>,
|
|
36
|
-
{ wrapper: Theme }
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
expect(getByTestId('Stack-Spacer-1')).toHaveStyle(expectedStyle)
|
|
40
|
-
expect(getByTestId('Stack-Spacer-2')).toHaveStyle(expectedStyle)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('renders spacers between children wrapped in one Fragment', () => {
|
|
44
|
-
const content = (
|
|
45
|
-
<>
|
|
46
|
-
<Typography>A</Typography>
|
|
47
|
-
<Typography>B</Typography>
|
|
48
|
-
<Typography>C</Typography>
|
|
49
|
-
</>
|
|
50
|
-
)
|
|
51
|
-
const { queryAllByTestId } = render(<StackedContent space={1}>{content}</StackedContent>, {
|
|
52
|
-
wrapper: Theme
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
expect(queryAllByTestId(/Stack-Spacer/)).toHaveLength(2)
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
it('renders spacers between children wrapped in sibling Fragments', () => {
|
|
59
|
-
// Simulate common pattern of using fragments for conditional rendering
|
|
60
|
-
const someCondition = true
|
|
61
|
-
|
|
62
|
-
const content = (
|
|
63
|
-
<>
|
|
64
|
-
<Typography>A</Typography>
|
|
65
|
-
<Typography>B</Typography>
|
|
66
|
-
{someCondition && (
|
|
67
|
-
<>
|
|
68
|
-
<Typography>C</Typography>
|
|
69
|
-
<Typography>D</Typography>
|
|
70
|
-
<Typography>E</Typography>
|
|
71
|
-
</>
|
|
72
|
-
)}
|
|
73
|
-
</>
|
|
74
|
-
)
|
|
75
|
-
const { queryAllByTestId } = render(<StackedContent space={1}>{content}</StackedContent>, {
|
|
76
|
-
wrapper: Theme
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
expect(queryAllByTestId(/Stack-Spacer/)).toHaveLength(4)
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
it('does not render spacers between children wrapped in a component', () => {
|
|
83
|
-
const content = (
|
|
84
|
-
<View>
|
|
85
|
-
<Typography>A</Typography>
|
|
86
|
-
<Typography>B</Typography>
|
|
87
|
-
<Typography>C</Typography>
|
|
88
|
-
</View>
|
|
89
|
-
)
|
|
90
|
-
const { queryAllByTestId } = render(<StackedContent space={1}>{content}</StackedContent>, {
|
|
91
|
-
wrapper: Theme
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
expect(queryAllByTestId(/Stack-Spacer/)).toHaveLength(0)
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
it('does not render spacers between empty or nullish children', () => {
|
|
98
|
-
const { queryAllByTestId } = render(
|
|
99
|
-
<StackedContent space={1}>
|
|
100
|
-
<Typography>A</Typography>
|
|
101
|
-
{/* this is a comment */}
|
|
102
|
-
<Typography>B</Typography>
|
|
103
|
-
{null}
|
|
104
|
-
<Typography>C</Typography>
|
|
105
|
-
{false}
|
|
106
|
-
<Typography>D</Typography>
|
|
107
|
-
{undefined}
|
|
108
|
-
{null}
|
|
109
|
-
{false}
|
|
110
|
-
<Typography>E</Typography>
|
|
111
|
-
</StackedContent>,
|
|
112
|
-
{ wrapper: Theme }
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
expect(queryAllByTestId(/Stack-Spacer/)).toHaveLength(4)
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
it('renders spacers between valid children in an array', () => {
|
|
119
|
-
const content = [
|
|
120
|
-
<Typography key="A">A</Typography>,
|
|
121
|
-
null,
|
|
122
|
-
false,
|
|
123
|
-
<Typography key="B">B</Typography>,
|
|
124
|
-
undefined,
|
|
125
|
-
<View key="C">
|
|
126
|
-
<Typography key="D">D</Typography>
|
|
127
|
-
<Typography key="E">E</Typography>
|
|
128
|
-
<Typography key="F">F</Typography>
|
|
129
|
-
</View>,
|
|
130
|
-
<Fragment key="G">
|
|
131
|
-
<Typography key="H">H</Typography>
|
|
132
|
-
<Typography key="I">I</Typography>
|
|
133
|
-
</Fragment>
|
|
134
|
-
]
|
|
135
|
-
|
|
136
|
-
const { queryAllByTestId } = render(<StackedContent space={1}>{content}</StackedContent>, {
|
|
137
|
-
wrapper: Theme
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
// Between A, B, C, H, I = 4
|
|
141
|
-
expect(queryAllByTestId(/Stack-Spacer/)).toHaveLength(4)
|
|
142
|
-
})
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
describe('getStackedContent (Dividers)', () => {
|
|
146
|
-
it('renders dividers between simple children', () => {
|
|
147
|
-
const { queryAllByTestId } = render(
|
|
148
|
-
<StackedContent divider>
|
|
149
|
-
<Typography>A</Typography>
|
|
150
|
-
<Typography>B</Typography>
|
|
151
|
-
<Typography>C</Typography>
|
|
152
|
-
</StackedContent>,
|
|
153
|
-
{ wrapper: Theme }
|
|
154
|
-
)
|
|
155
|
-
|
|
156
|
-
expect(queryAllByTestId(/Stack-Divider-\d$/)).toHaveLength(2)
|
|
157
|
-
expect(queryAllByTestId(/Stack-Spacer/)).toHaveLength(0)
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
it('renders dividers between valid children in an array', () => {
|
|
161
|
-
const content = [
|
|
162
|
-
<Typography key="A">A</Typography>,
|
|
163
|
-
null,
|
|
164
|
-
false,
|
|
165
|
-
<Typography key="B">B</Typography>,
|
|
166
|
-
undefined,
|
|
167
|
-
<View key="C">
|
|
168
|
-
<Typography key="D">D</Typography>
|
|
169
|
-
<Typography key="E">E</Typography>
|
|
170
|
-
<Typography key="F">F</Typography>
|
|
171
|
-
</View>,
|
|
172
|
-
<Fragment key="G">
|
|
173
|
-
<Typography key="H">H</Typography>
|
|
174
|
-
<Typography key="I">I</Typography>
|
|
175
|
-
</Fragment>
|
|
176
|
-
]
|
|
177
|
-
|
|
178
|
-
const { queryAllByTestId } = render(
|
|
179
|
-
<StackedContent space={1} divider>
|
|
180
|
-
{content}
|
|
181
|
-
</StackedContent>,
|
|
182
|
-
{
|
|
183
|
-
wrapper: Theme
|
|
184
|
-
}
|
|
185
|
-
)
|
|
186
|
-
|
|
187
|
-
// Between A, B, C, H, I = 4
|
|
188
|
-
expect(queryAllByTestId(/Stack-Divider-\d+$/)).toHaveLength(4)
|
|
189
|
-
expect(queryAllByTestId(/Stack-Spacer/)).toHaveLength(0)
|
|
190
|
-
})
|
|
191
|
-
|
|
192
|
-
it('gives dividers spacing according to own space prop and spacing scale', () => {
|
|
193
|
-
const expectedSize = 8 // from __fixtures__/testTheme.js
|
|
194
|
-
const expectedStyle = { height: expectedSize }
|
|
195
|
-
|
|
196
|
-
const { getByTestId } = render(
|
|
197
|
-
<StackedContent space={2} divider>
|
|
198
|
-
<Typography>A</Typography>
|
|
199
|
-
<Typography>B</Typography>
|
|
200
|
-
<Typography>C</Typography>
|
|
201
|
-
</StackedContent>,
|
|
202
|
-
{ wrapper: Theme }
|
|
203
|
-
)
|
|
204
|
-
|
|
205
|
-
expect(getByTestId('Stack-Divider-1-Spacer-before')).toHaveStyle(expectedStyle)
|
|
206
|
-
expect(getByTestId('Stack-Divider-1-Spacer-after')).toHaveStyle(expectedStyle)
|
|
207
|
-
expect(getByTestId('Stack-Divider-2-Spacer-before')).toHaveStyle(expectedStyle)
|
|
208
|
-
expect(getByTestId('Stack-Divider-2-Spacer-after')).toHaveStyle(expectedStyle)
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
it('can pass props down to dividers', () => {
|
|
212
|
-
const tokens = { color: '#012345' }
|
|
213
|
-
|
|
214
|
-
const { getByTestId } = render(
|
|
215
|
-
<StackedContent divider={{ tokens, vertical: true }}>
|
|
216
|
-
<Typography>A</Typography>
|
|
217
|
-
<Typography>B</Typography>
|
|
218
|
-
<Typography>C</Typography>
|
|
219
|
-
</StackedContent>,
|
|
220
|
-
{ wrapper: Theme }
|
|
221
|
-
)
|
|
222
|
-
|
|
223
|
-
expect(getByTestId('Stack-Divider-1')).toHaveStyle({ borderRightColor: tokens.color })
|
|
224
|
-
expect(getByTestId('Stack-Divider-2')).toHaveStyle({ borderRightColor: tokens.color })
|
|
225
|
-
})
|
|
226
|
-
})
|
|
227
|
-
|
|
228
|
-
describe('getStackedContent (Boxes)', () => {
|
|
229
|
-
it('renders boxes around simple children', () => {
|
|
230
|
-
const { queryAllByTestId } = render(
|
|
231
|
-
<StackedContent box>
|
|
232
|
-
<Typography>A</Typography>
|
|
233
|
-
<Typography>B</Typography>
|
|
234
|
-
<Typography>C</Typography>
|
|
235
|
-
</StackedContent>,
|
|
236
|
-
{ wrapper: Theme }
|
|
237
|
-
)
|
|
238
|
-
|
|
239
|
-
expect(queryAllByTestId(/Stack-Box-\d$/)).toHaveLength(3)
|
|
240
|
-
expect(queryAllByTestId(/Stack-Divider/)).toHaveLength(0)
|
|
241
|
-
expect(queryAllByTestId(/Stack-Spacer/)).toHaveLength(0)
|
|
242
|
-
})
|
|
243
|
-
|
|
244
|
-
it('gives boxes spacing according to own space prop and spacing scale', () => {
|
|
245
|
-
const expectedSize = 8 // from __fixtures__/testTheme.js
|
|
246
|
-
const expectedStyle = {
|
|
247
|
-
paddingTop: expectedSize,
|
|
248
|
-
paddingLeft: expectedSize,
|
|
249
|
-
paddingBottom: expectedSize,
|
|
250
|
-
paddingRight: expectedSize
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
const { getByTestId } = render(
|
|
254
|
-
<StackedContent space={2} box>
|
|
255
|
-
<Typography>A</Typography>
|
|
256
|
-
<Typography>B</Typography>
|
|
257
|
-
<Typography>C</Typography>
|
|
258
|
-
</StackedContent>,
|
|
259
|
-
{ wrapper: Theme }
|
|
260
|
-
)
|
|
261
|
-
|
|
262
|
-
expect(getByTestId('Stack-Box-0')).toHaveStyle(expectedStyle)
|
|
263
|
-
expect(getByTestId('Stack-Box-1')).toHaveStyle(expectedStyle)
|
|
264
|
-
expect(getByTestId('Stack-Box-2')).toHaveStyle(expectedStyle)
|
|
265
|
-
})
|
|
266
|
-
|
|
267
|
-
it('gives boxes spacing on specified sides only, if box props object is passed', () => {
|
|
268
|
-
const expectedSize = 8 // from __fixtures__/testTheme.js
|
|
269
|
-
const expectedStyle = {
|
|
270
|
-
paddingTop: expectedSize,
|
|
271
|
-
paddingLeft: expectedSize
|
|
272
|
-
}
|
|
273
|
-
const unexpectedStyle = {
|
|
274
|
-
paddingBottom: expectedSize,
|
|
275
|
-
paddingRight: expectedSize
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const { getByTestId } = render(
|
|
279
|
-
<StackedContent box={{ top: 2, left: 2 }}>
|
|
280
|
-
<Typography>A</Typography>
|
|
281
|
-
<Typography>B</Typography>
|
|
282
|
-
<Typography>C</Typography>
|
|
283
|
-
</StackedContent>,
|
|
284
|
-
{ wrapper: Theme }
|
|
285
|
-
)
|
|
286
|
-
|
|
287
|
-
expect(getByTestId('Stack-Box-0')).toHaveStyle(expectedStyle)
|
|
288
|
-
expect(getByTestId('Stack-Box-1')).toHaveStyle(expectedStyle)
|
|
289
|
-
expect(getByTestId('Stack-Box-2')).toHaveStyle(expectedStyle)
|
|
290
|
-
|
|
291
|
-
expect(getByTestId('Stack-Box-0')).not.toHaveStyle(unexpectedStyle)
|
|
292
|
-
expect(getByTestId('Stack-Box-1')).not.toHaveStyle(unexpectedStyle)
|
|
293
|
-
expect(getByTestId('Stack-Box-2')).not.toHaveStyle(unexpectedStyle)
|
|
294
|
-
})
|
|
295
|
-
})
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { render, within } from '@testing-library/react-native'
|
|
3
|
-
|
|
4
|
-
import { StepTracker } from '../../src'
|
|
5
|
-
import Theme from '../../__fixtures__/Theme'
|
|
6
|
-
import Viewport from '../../__fixtures__/Viewport'
|
|
7
|
-
import dictionary from '../../src/StepTracker/dictionary'
|
|
8
|
-
|
|
9
|
-
const defaultSteps = [...Array(5).keys()].map((key) => `Some Step Title ${key + 1}`)
|
|
10
|
-
|
|
11
|
-
const setup = ({ current, steps = defaultSteps, tokens, viewport, ...args }) =>
|
|
12
|
-
render(
|
|
13
|
-
<Theme>
|
|
14
|
-
<Viewport viewport={viewport}>
|
|
15
|
-
<StepTracker current={current} steps={steps} tokens={tokens} {...args} />
|
|
16
|
-
</Viewport>
|
|
17
|
-
</Theme>
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
describe('StepTracker', () => {
|
|
21
|
-
const currentStep = 2
|
|
22
|
-
|
|
23
|
-
it('renders the steps properly', () => {
|
|
24
|
-
const { getAllByTestId, getByA11yLabel } = setup({ current: currentStep })
|
|
25
|
-
|
|
26
|
-
expect(getAllByTestId(/StepTracker-Step/).length).toBe(defaultSteps.length)
|
|
27
|
-
expect(getAllByTestId(/StepTracker-Step-Completed/).length).toBe(
|
|
28
|
-
defaultSteps.length - currentStep - 1
|
|
29
|
-
)
|
|
30
|
-
expect(
|
|
31
|
-
within(getByA11yLabel(defaultSteps[currentStep])).getByTestId('StepTracker-Step-Current')
|
|
32
|
-
).toBeTruthy()
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('only displays the step tracker label and no step labels on small screens', () => {
|
|
36
|
-
const { getByText, queryByText } = setup({
|
|
37
|
-
viewport: 'sm'
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
const stepTrackerLabel = dictionary.en.stepTrackerLabel
|
|
41
|
-
.replace('%{stepNumber}', 1)
|
|
42
|
-
.replace('%{stepCount}', defaultSteps.length)
|
|
43
|
-
.replace('%{stepLabel}', defaultSteps[0])
|
|
44
|
-
expect(getByText(stepTrackerLabel)).toBeTruthy()
|
|
45
|
-
expect(queryByText(defaultSteps[1])).toBeFalsy()
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it('only displays the step labels and no step tracker label on large screens', () => {
|
|
49
|
-
const { getByText, queryByText } = setup({
|
|
50
|
-
viewport: 'lg'
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
const stepTrackerLabel = dictionary.en.stepTrackerLabel
|
|
54
|
-
.replace('%{stepNumber}', 1)
|
|
55
|
-
.replace('%{stepCount}', defaultSteps.length)
|
|
56
|
-
.replace('%{stepLabel}', defaultSteps[0])
|
|
57
|
-
expect(queryByText(stepTrackerLabel)).toBeFalsy()
|
|
58
|
-
expect(getByText(defaultSteps[1])).toBeTruthy()
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
it('displays the step tracker label if requested', () => {
|
|
62
|
-
const { getByText, queryByText } = setup({
|
|
63
|
-
current: currentStep,
|
|
64
|
-
tokens: { showStepTrackerLabel: true }
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
defaultSteps.forEach((stepTitle) => {
|
|
68
|
-
if (defaultSteps.indexOf(stepTitle) === currentStep) {
|
|
69
|
-
const stepTrackerLabel = dictionary.en.stepTrackerLabel
|
|
70
|
-
.replace('%{stepNumber}', currentStep + 1)
|
|
71
|
-
.replace('%{stepCount}', defaultSteps.length)
|
|
72
|
-
.replace('%{stepLabel}', stepTitle)
|
|
73
|
-
expect(getByText(stepTrackerLabel)).toBeTruthy()
|
|
74
|
-
} else {
|
|
75
|
-
expect(queryByText(stepTitle)).toBeFalsy()
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
it('displays the step names and titles if requested', () => {
|
|
81
|
-
const { getByText } = setup({ tokens: { showStepLabel: true } })
|
|
82
|
-
|
|
83
|
-
defaultSteps.forEach((stepTitle, index) => {
|
|
84
|
-
expect(getByText(dictionary.en.stepLabel.replace('%{stepNumber}', index + 1))).toBeTruthy()
|
|
85
|
-
expect(getByText(stepTitle)).toBeTruthy()
|
|
86
|
-
})
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
it('hides step names if requested', () => {
|
|
90
|
-
const { getByText } = setup({ tokens: { showStepLabel: true, showStepName: false } })
|
|
91
|
-
|
|
92
|
-
defaultSteps.forEach((stepTitle) => expect(getByText(stepTitle)).toBeTruthy())
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
it('has appropriate accessibilityValue props', () => {
|
|
96
|
-
const accessibilityLabel = 'StepTracker label'
|
|
97
|
-
const current = 3
|
|
98
|
-
const { getByA11yLabel } = setup({ accessibilityLabel, current })
|
|
99
|
-
const container = getByA11yLabel(accessibilityLabel)
|
|
100
|
-
|
|
101
|
-
expect(container).toHaveProp('accessibilityValue', {
|
|
102
|
-
min: 0,
|
|
103
|
-
max: defaultSteps.length - 1,
|
|
104
|
-
now: current,
|
|
105
|
-
text: 'Some Step Title 4'
|
|
106
|
-
})
|
|
107
|
-
})
|
|
108
|
-
})
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { fireEvent, render } from '@testing-library/react-native'
|
|
3
|
-
|
|
4
|
-
import { Tabs } from '../../src'
|
|
5
|
-
import Theme from '../../__fixtures__/Theme'
|
|
6
|
-
|
|
7
|
-
describe('Tabs', () => {
|
|
8
|
-
const items = [{ label: 'one' }, { label: 'two' }, { label: 'three' }, { label: 'four' }]
|
|
9
|
-
const linkItems = items.map((item) => ({ ...item, href: 'https://telus.com' }))
|
|
10
|
-
|
|
11
|
-
it('renders a menu', () => {
|
|
12
|
-
const { queryAllByA11yRole } = render(<Tabs items={items} />, { wrapper: Theme })
|
|
13
|
-
expect(queryAllByA11yRole('tablist')).toHaveLength(1)
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
it('renders menuitems by default', () => {
|
|
17
|
-
const { queryAllByA11yRole } = render(<Tabs items={items} />, { wrapper: Theme })
|
|
18
|
-
expect(queryAllByA11yRole('tab')).toHaveLength(4)
|
|
19
|
-
expect(queryAllByA11yRole('link')).toHaveLength(0)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it('renders nav/links by if a navigation role is passed (web-only)', () => {
|
|
23
|
-
const { queryAllByA11yRole } = render(
|
|
24
|
-
// navigation role is web-only, but the test runs fine here even on ios
|
|
25
|
-
// eslint-disable-next-line react-native-a11y/has-valid-accessibility-role
|
|
26
|
-
<Tabs items={linkItems} accessibilityRole="navigation" />,
|
|
27
|
-
{ wrapper: Theme }
|
|
28
|
-
)
|
|
29
|
-
expect(queryAllByA11yRole('tablist')).toHaveLength(0)
|
|
30
|
-
expect(queryAllByA11yRole('navigation')).toHaveLength(1)
|
|
31
|
-
expect(queryAllByA11yRole('tab')).toHaveLength(0)
|
|
32
|
-
expect(queryAllByA11yRole('link')).toHaveLength(4)
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('is selected when pressed', () => {
|
|
36
|
-
const { queryByA11yState, getByText } = render(<Tabs items={items} />, { wrapper: Theme })
|
|
37
|
-
let selected
|
|
38
|
-
selected = queryByA11yState({ selected: true })
|
|
39
|
-
expect(selected).toBeFalsy()
|
|
40
|
-
|
|
41
|
-
fireEvent.press(getByText('two'))
|
|
42
|
-
|
|
43
|
-
selected = queryByA11yState({ selected: true })
|
|
44
|
-
expect(selected).toBeTruthy()
|
|
45
|
-
expect(selected).toHaveTextContent('two')
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
// TODO add a test for the current: 'page' handling (web-only, see https://github.com/telus/universal-design-system/issues/319)
|
|
49
|
-
})
|