@telus-uds/components-base 1.26.0 → 1.27.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +16 -2
  2. package/component-docs.json +2 -1
  3. package/package.json +2 -2
  4. package/.eslintrc.js +0 -9
  5. package/__tests17__/A11yText/A11yText.test.jsx +0 -34
  6. package/__tests17__/ActivityIndicator/ActivityIndicator.test.jsx +0 -68
  7. package/__tests17__/ActivityIndicator/__snapshots__/ActivityIndicator.test.jsx.snap +0 -299
  8. package/__tests17__/Box/Box.test.jsx +0 -111
  9. package/__tests17__/Button/Button.test.jsx +0 -86
  10. package/__tests17__/Button/ButtonBase.test.jsx +0 -82
  11. package/__tests17__/Button/ButtonGroup.test.jsx +0 -347
  12. package/__tests17__/Button/ButtonLink.test.jsx +0 -61
  13. package/__tests17__/Card/Card.test.jsx +0 -63
  14. package/__tests17__/Carousel/Carousel.test.jsx +0 -128
  15. package/__tests17__/Carousel/CarouselTabs.test.jsx +0 -142
  16. package/__tests17__/Checkbox/Checkbox.test.jsx +0 -94
  17. package/__tests17__/Checkbox/CheckboxGroup.test.jsx +0 -246
  18. package/__tests17__/Divider/Divider.test.jsx +0 -91
  19. package/__tests17__/ExpandCollapse/ExpandCollapse.test.jsx +0 -109
  20. package/__tests17__/Feedback/Feedback.test.jsx +0 -42
  21. package/__tests17__/FlexGrid/Col.test.jsx +0 -261
  22. package/__tests17__/FlexGrid/FlexGrid.test.jsx +0 -136
  23. package/__tests17__/FlexGrid/Row.test.jsx +0 -273
  24. package/__tests17__/HorizontalScroll/HorizontalScroll.test.jsx +0 -165
  25. package/__tests17__/Icon/Icon.test.jsx +0 -61
  26. package/__tests17__/IconButton/IconButton.test.jsx +0 -52
  27. package/__tests17__/InputLabel/InputLabel.test.jsx +0 -28
  28. package/__tests17__/InputLabel/__snapshots__/InputLabel.test.jsx.snap +0 -3
  29. package/__tests17__/InputSupports/InputSupports.test.jsx +0 -60
  30. package/__tests17__/Link/Link.test.jsx +0 -63
  31. package/__tests17__/Link/TextButton.test.jsx +0 -35
  32. package/__tests17__/List/List.test.jsx +0 -82
  33. package/__tests17__/Modal/Modal.test.jsx +0 -47
  34. package/__tests17__/Notification/Notification.test.jsx +0 -20
  35. package/__tests17__/Pagination/Pagination.test.jsx +0 -160
  36. package/__tests17__/Progress/Progress.test.jsx +0 -79
  37. package/__tests17__/Radio/Radio.test.jsx +0 -87
  38. package/__tests17__/Radio/RadioGroup.test.jsx +0 -220
  39. package/__tests17__/RadioCard/RadioCard.test.jsx +0 -87
  40. package/__tests17__/RadioCard/RadioCardGroup.test.jsx +0 -246
  41. package/__tests17__/Search/Search.test.jsx +0 -87
  42. package/__tests17__/Select/Select.test.jsx +0 -94
  43. package/__tests17__/SideNav/SideNav.test.jsx +0 -110
  44. package/__tests17__/Skeleton/Skeleton.test.jsx +0 -61
  45. package/__tests17__/SkipLink/SkipLink.test.jsx +0 -61
  46. package/__tests17__/Spacer/Spacer.test.jsx +0 -63
  47. package/__tests17__/StackView/StackView.test.jsx +0 -211
  48. package/__tests17__/StackView/StackWrap.test.jsx +0 -47
  49. package/__tests17__/StackView/getStackedContent.test.jsx +0 -295
  50. package/__tests17__/StepTracker/StepTracker.test.jsx +0 -108
  51. package/__tests17__/Tabs/Tabs.test.jsx +0 -49
  52. package/__tests17__/Tags/Tags.test.jsx +0 -327
  53. package/__tests17__/TextInput/TextArea.test.jsx +0 -35
  54. package/__tests17__/TextInput/TextInputBase.test.jsx +0 -125
  55. package/__tests17__/ThemeProvider/ThemeProvider.test.jsx +0 -82
  56. package/__tests17__/ThemeProvider/useThemeTokens.test.jsx +0 -514
  57. package/__tests17__/ThemeProvider/utils/theme-tokens.test.js +0 -41
  58. package/__tests17__/ToggleSwitch/ToggleSwitch.test.jsx +0 -82
  59. package/__tests17__/ToggleSwitch/ToggleSwitchGroup.test.jsx +0 -192
  60. package/__tests17__/Tooltip/Tooltip.test.jsx +0 -65
  61. package/__tests17__/Tooltip/getTooltipPosition.test.js +0 -79
  62. package/__tests17__/Typography/typography.test.jsx +0 -90
  63. package/__tests17__/utils/children.test.jsx +0 -128
  64. package/__tests17__/utils/containUniqueFields.test.js +0 -25
  65. package/__tests17__/utils/input.test.js +0 -375
  66. package/__tests17__/utils/props.test.js +0 -36
  67. package/__tests17__/utils/semantics.test.jsx +0 -34
  68. package/__tests17__/utils/useCopy.test.js +0 -42
  69. package/__tests17__/utils/useResponsiveProp.test.jsx +0 -202
  70. package/__tests17__/utils/useSpacingScale.test.jsx +0 -273
  71. package/__tests17__/utils/useUniqueId.test.js +0 -31
package/CHANGELOG.md CHANGED
@@ -1,12 +1,26 @@
1
1
  # Change Log - @telus-uds/components-base
2
2
 
3
- This log was last generated on Fri, 10 Feb 2023 17:37:16 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 23 Feb 2023 17:20:42 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.27.0
8
+
9
+ Thu, 23 Feb 2023 17:20:42 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - update public mobile themes (evander.owusu@telus.com)
14
+ - Bump @telus-uds/system-theme-tokens to v2.11.0
15
+
16
+ ### Patches
17
+
18
+ - ignore unwanted files (evander.owusu@telus.com)
19
+ - Updated snapshots based on the SVG changes (101351850+nadaltelus@users.noreply.github.com)
20
+
7
21
  ## 1.26.0
8
22
 
9
- Fri, 10 Feb 2023 17:37:16 GMT
23
+ Fri, 10 Feb 2023 17:40:05 GMT
10
24
 
11
25
  ### Minor changes
12
26
 
@@ -1817,7 +1817,8 @@
1817
1817
  8,
1818
1818
  9,
1819
1819
  10,
1820
- 11
1820
+ 11,
1821
+ 12
1821
1822
  ],
1822
1823
  "type": "state"
1823
1824
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "@floating-ui/react-native": "^0.8.1",
12
12
  "@gorhom/portal": "^1.0.14",
13
13
  "@telus-uds/system-constants": "^1.2.0",
14
- "@telus-uds/system-theme-tokens": "^2.10.0",
14
+ "@telus-uds/system-theme-tokens": "^2.11.0",
15
15
  "airbnb-prop-types": "^2.16.0",
16
16
  "lodash.debounce": "^4.0.8",
17
17
  "lodash.merge": "^4.6.2",
@@ -72,5 +72,5 @@
72
72
  "standard-engine": {
73
73
  "skip": true
74
74
  },
75
- "version": "1.26.0"
75
+ "version": "1.27.0"
76
76
  }
package/.eslintrc.js DELETED
@@ -1,9 +0,0 @@
1
- module.exports = {
2
- rules: {
3
- // Default props in React are deprecated outside of class-based components. Globally we use an
4
- // option that skips this rule for functional components, but it doesn't play nicely with forwardRef.
5
- // Since we don't intend to ever have class-based components within UDS components-base,
6
- // but we do use forwardRef, best to turn off the rule completely for this package.
7
- 'react/require-default-props': 'off'
8
- }
9
- }
@@ -1,34 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react-native'
3
- import A11yText from '../../src/A11yText'
4
-
5
- describe('A11yText', () => {
6
- it('has an accessible label', async () => {
7
- const { getByA11yLabel } = render(<A11yText text="Some text" />)
8
-
9
- const a11yText = getByA11yLabel('Some text')
10
- expect(a11yText).toBeTruthy()
11
- expect(() => getByA11yLabel('Not some text')).toThrow()
12
- })
13
-
14
- it("doesn't render regular text", async () => {
15
- const { getByText } = render(<A11yText text="Some text" />)
16
- expect(() => getByText('Some text')).toThrow()
17
- })
18
-
19
- it('defaults to text role', async () => {
20
- const { getByRole } = render(<A11yText text="Some text" />)
21
-
22
- const a11yText = getByRole('text')
23
- expect(a11yText).toBeTruthy()
24
- expect(() => getByRole('header')).toThrow()
25
- })
26
-
27
- it('can be set to header role', async () => {
28
- const { getByRole } = render(<A11yText text="Some text" heading />)
29
-
30
- const a11yText = getByRole('header')
31
- expect(a11yText).toBeTruthy()
32
- expect(() => getByRole('text')).toThrow()
33
- })
34
- })
@@ -1,68 +0,0 @@
1
- import React from 'react'
2
- import { Platform } from 'react-native'
3
- import { render as baseRender } from '@testing-library/react-native'
4
- import Theme from '../../__fixtures__/Theme'
5
- import ActivityIndicator from '../../src/ActivityIndicator'
6
- import * as A11yInfoProvider from '../../src/A11yInfoProvider'
7
-
8
- // Used to remove the "Animated: `useNativeDriver` is not supported because the native animated module is missing." warnings
9
- jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper')
10
-
11
- const render = (jsx) => baseRender(jsx, { wrapper: Theme })
12
-
13
- describe('ActivityIndicator', () => {
14
- it('has an accessible label', async () => {
15
- const { getByA11yLabel } = render(<ActivityIndicator label="I'm a loader" />)
16
-
17
- expect(getByA11yLabel("I'm a loader")).toBeTruthy()
18
- })
19
-
20
- it('has a role of progressbar', async () => {
21
- const { getByRole } = render(<ActivityIndicator label="I'm a loader" />)
22
-
23
- expect(getByRole('progressbar')).toBeTruthy()
24
- })
25
-
26
- it('has an a11y state of busy', async () => {
27
- const { getAllByAccessibilityState } = render(<ActivityIndicator label="I'm a loader" />)
28
- expect(getAllByAccessibilityState({ busy: true })).toBeTruthy()
29
- })
30
-
31
- it("doesn't render regular text for the label", async () => {
32
- const { getByText } = render(<ActivityIndicator label="I'm a loader" />)
33
- expect(() => getByText("I'm a loader")).toThrow()
34
- })
35
-
36
- it("doesn't animate when reduced motion is enabled", async () => {
37
- jest
38
- .spyOn(A11yInfoProvider, 'useA11yInfo')
39
- .mockImplementation(() => ({ reduceMotionEnabled: true }))
40
- // TODO: this won't be called until cross-platform Jest tests are configured
41
- // see https://github.com/telus/universal-design-system/issues/319
42
- if (Platform.OS === 'web') {
43
- const { container } = render(<ActivityIndicator label="I'm a loader" />)
44
- expect(container.querySelector('[attributeName="transform"]')).not.toBeInTheDocument()
45
- expect(container.querySelector('[attributeName="stroke-dashoffset"]')).not.toBeInTheDocument()
46
- expect(container.querySelector('[attributeName="stroke-dasharray"]')).not.toBeInTheDocument()
47
- } else {
48
- const component = render(<ActivityIndicator label="I'm a loader" />)
49
- expect(component).toMatchSnapshot()
50
- }
51
- })
52
- it("animates when reduced motion isn't enabled", async () => {
53
- jest
54
- .spyOn(A11yInfoProvider, 'useA11yInfo')
55
- .mockImplementation(() => ({ reduceMotionEnabled: false }))
56
- // TODO: this won't be called until cross-platform Jest tests are configured
57
- // see https://github.com/telus/universal-design-system/issues/319
58
- if (Platform.OS === 'web') {
59
- const { container } = render(<ActivityIndicator label="I'm a loader" />)
60
- expect(container.querySelector('[attributeName="transform"]')).toBeInTheDocument()
61
- expect(container.querySelector('[attributeName="stroke-dashoffset"]')).toBeInTheDocument()
62
- expect(container.querySelector('[attributeName="stroke-dasharray"]')).toBeInTheDocument()
63
- } else {
64
- const component = render(<ActivityIndicator label="I'm a loader" />)
65
- expect(component).toMatchSnapshot()
66
- }
67
- })
68
- })
@@ -1,299 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`ActivityIndicator animates when reduced motion isn't enabled 1`] = `
4
- <View
5
- accessibilityLabel="I'm a loader"
6
- accessibilityRole="progressbar"
7
- accessibilityState={
8
- Object {
9
- "busy": true,
10
- }
11
- }
12
- accessible={true}
13
- style={
14
- Array [
15
- Object {
16
- "flexGrow": 0,
17
- "flexShrink": 0,
18
- },
19
- ]
20
- }
21
- >
22
- <View
23
- collapsable={false}
24
- style={
25
- Object {
26
- "height": 24,
27
- "width": 24,
28
- }
29
- }
30
- >
31
- <View
32
- collapsable={false}
33
- style={
34
- Object {
35
- "alignItems": "center",
36
- "bottom": 0,
37
- "justifyContent": "center",
38
- "left": 0,
39
- "position": "absolute",
40
- "right": 0,
41
- "top": 0,
42
- }
43
- }
44
- >
45
- <View
46
- collapsable={false}
47
- style={
48
- Object {
49
- "height": 24,
50
- "transform": Array [
51
- Object {
52
- "rotate": "45deg",
53
- },
54
- ],
55
- "width": 24,
56
- }
57
- }
58
- >
59
- <View
60
- collapsable={false}
61
- style={
62
- Object {
63
- "height": 12,
64
- "overflow": "hidden",
65
- "width": 24,
66
- }
67
- }
68
- >
69
- <View
70
- collapsable={false}
71
- style={
72
- Object {
73
- "height": 24,
74
- "transform": Array [
75
- Object {
76
- "translateY": 0,
77
- },
78
- Object {
79
- "rotate": "-165deg",
80
- },
81
- ],
82
- "width": 24,
83
- }
84
- }
85
- >
86
- <View
87
- collapsable={false}
88
- style={
89
- Object {
90
- "height": 12,
91
- "overflow": "hidden",
92
- "width": 24,
93
- }
94
- }
95
- >
96
- <View
97
- collapsable={false}
98
- style={
99
- Object {
100
- "borderColor": "#0e6ac8",
101
- "borderRadius": 12,
102
- "borderWidth": 2,
103
- "height": 24,
104
- "width": 24,
105
- }
106
- }
107
- />
108
- </View>
109
- </View>
110
- </View>
111
- </View>
112
- </View>
113
- <View
114
- collapsable={false}
115
- style={
116
- Object {
117
- "alignItems": "center",
118
- "bottom": 0,
119
- "justifyContent": "center",
120
- "left": 0,
121
- "position": "absolute",
122
- "right": 0,
123
- "top": 0,
124
- }
125
- }
126
- >
127
- <View
128
- collapsable={false}
129
- style={
130
- Object {
131
- "height": 24,
132
- "transform": Array [
133
- Object {
134
- "rotate": "45deg",
135
- },
136
- ],
137
- "width": 24,
138
- }
139
- }
140
- >
141
- <View
142
- collapsable={false}
143
- style={
144
- Object {
145
- "height": 12,
146
- "overflow": "hidden",
147
- "top": 12,
148
- "width": 24,
149
- }
150
- }
151
- >
152
- <View
153
- collapsable={false}
154
- style={
155
- Object {
156
- "height": 24,
157
- "transform": Array [
158
- Object {
159
- "translateY": -12,
160
- },
161
- Object {
162
- "rotate": "345deg",
163
- },
164
- ],
165
- "width": 24,
166
- }
167
- }
168
- >
169
- <View
170
- collapsable={false}
171
- style={
172
- Object {
173
- "height": 12,
174
- "overflow": "hidden",
175
- "width": 24,
176
- }
177
- }
178
- >
179
- <View
180
- collapsable={false}
181
- style={
182
- Object {
183
- "borderColor": "#0e6ac8",
184
- "borderRadius": 12,
185
- "borderWidth": 2,
186
- "height": 24,
187
- "width": 24,
188
- }
189
- }
190
- />
191
- </View>
192
- </View>
193
- </View>
194
- </View>
195
- </View>
196
- </View>
197
- </View>
198
- `;
199
-
200
- exports[`ActivityIndicator doesn't animate when reduced motion is enabled 1`] = `
201
- <View
202
- accessibilityLabel="I'm a loader"
203
- accessibilityRole="progressbar"
204
- accessibilityState={
205
- Object {
206
- "busy": true,
207
- }
208
- }
209
- accessible={true}
210
- style={
211
- Array [
212
- Object {
213
- "flexGrow": 0,
214
- "flexShrink": 0,
215
- },
216
- ]
217
- }
218
- >
219
- <View
220
- collapsable={false}
221
- style={
222
- Object {
223
- "height": 24,
224
- "width": 24,
225
- }
226
- }
227
- >
228
- <View
229
- collapsable={false}
230
- style={
231
- Object {
232
- "alignItems": "center",
233
- "bottom": 0,
234
- "justifyContent": "center",
235
- "left": 0,
236
- "position": "absolute",
237
- "right": 0,
238
- "top": 0,
239
- }
240
- }
241
- >
242
- <View
243
- collapsable={false}
244
- style={
245
- Object {
246
- "height": 24,
247
- "width": 24,
248
- }
249
- }
250
- >
251
- <View
252
- collapsable={false}
253
- style={
254
- Object {
255
- "height": 16,
256
- "overflow": "hidden",
257
- "width": 24,
258
- }
259
- }
260
- >
261
- <View
262
- collapsable={false}
263
- style={
264
- Object {
265
- "height": 24,
266
- "width": 24,
267
- }
268
- }
269
- >
270
- <View
271
- collapsable={false}
272
- style={
273
- Object {
274
- "height": 16,
275
- "overflow": "hidden",
276
- "width": 24,
277
- }
278
- }
279
- >
280
- <View
281
- collapsable={false}
282
- style={
283
- Object {
284
- "borderColor": "#0e6ac8",
285
- "borderRadius": 12,
286
- "borderWidth": 2,
287
- "height": 24,
288
- "width": 24,
289
- }
290
- }
291
- />
292
- </View>
293
- </View>
294
- </View>
295
- </View>
296
- </View>
297
- </View>
298
- </View>
299
- `;
@@ -1,111 +0,0 @@
1
- import React from 'react'
2
- import { Text } from 'react-native'
3
- import { render, fireEvent } from '@testing-library/react-native'
4
- import { Box } from '../../src'
5
- import Theme from '../../__fixtures__/Theme'
6
-
7
- const textContent = 'Some text content'
8
-
9
- // Based on testTheme
10
- const expectedScale = [0, 4, 8, 16, 24, 32, 36]
11
-
12
- describe('Box', () => {
13
- it('is scrollable if scroll props provided', async () => {
14
- const onScroll = jest.fn()
15
- const { getByText } = render(
16
- <Theme>
17
- <Box scroll={{ onScroll }}>
18
- <Text>{textContent}</Text>
19
- </Box>
20
- </Theme>
21
- )
22
- const content = getByText(textContent)
23
-
24
- expect(onScroll).toHaveBeenCalledTimes(0)
25
- await fireEvent.scroll(content)
26
- expect(onScroll).toHaveBeenCalledTimes(1)
27
- })
28
-
29
- it('maps regular props to RN styles', () => {
30
- const props = {
31
- top: 1,
32
- bottom: 2,
33
- left: 3,
34
- right: 4
35
- }
36
- const { getByText } = render(
37
- <Theme>
38
- <Box {...props}>
39
- <Text>{textContent}</Text>
40
- </Box>
41
- </Theme>
42
- )
43
- expect(getByText(textContent).parent).toHaveStyle({
44
- paddingTop: expectedScale[1],
45
- paddingBottom: expectedScale[2],
46
- paddingLeft: expectedScale[3],
47
- paddingRight: expectedScale[4]
48
- })
49
- })
50
-
51
- it(`maps horizontal and vertical props to RN styles`, () => {
52
- const props = {
53
- horizontal: 1,
54
- vertical: 2
55
- }
56
- const { getByText } = render(
57
- <Theme>
58
- <Box {...props}>
59
- <Text>{textContent}</Text>
60
- </Box>
61
- </Theme>
62
- )
63
- expect(getByText(textContent).parent).toHaveStyle({
64
- paddingLeft: expectedScale[1],
65
- paddingRight: expectedScale[1],
66
- paddingTop: expectedScale[2],
67
- paddingBottom: expectedScale[2]
68
- })
69
- })
70
-
71
- it(`maps all-sides space prop to RN styles`, () => {
72
- const props = {
73
- space: 3
74
- }
75
- const { getByText } = render(
76
- <Theme>
77
- <Box {...props}>
78
- <Text>{textContent}</Text>
79
- </Box>
80
- </Theme>
81
- )
82
- expect(getByText(textContent).parent).toHaveStyle({
83
- paddingLeft: expectedScale[3],
84
- paddingRight: expectedScale[3],
85
- paddingTop: expectedScale[3],
86
- paddingBottom: expectedScale[3]
87
- })
88
- })
89
-
90
- it(`applies side overrides in increasing specificity`, () => {
91
- const props = {
92
- space: 1,
93
- horizontal: 2,
94
- top: 3,
95
- right: 4
96
- }
97
- const { getByText } = render(
98
- <Theme>
99
- <Box {...props}>
100
- <Text>{textContent}</Text>
101
- </Box>
102
- </Theme>
103
- )
104
- expect(getByText(textContent).parent).toHaveStyle({
105
- paddingLeft: expectedScale[2],
106
- paddingRight: expectedScale[4],
107
- paddingTop: expectedScale[3],
108
- paddingBottom: expectedScale[1]
109
- })
110
- })
111
- })
@@ -1,86 +0,0 @@
1
- import React from 'react'
2
- import { render, fireEvent } from '@testing-library/react-native'
3
- import { StyleSheet } from 'react-native'
4
- import testTheme from '../../__fixtures__/testTheme'
5
-
6
- import Theme from '../../__fixtures__/Theme'
7
- import Button from '../../src/Button/Button'
8
-
9
- const label = 'Test label text'
10
-
11
- describe('Button', () => {
12
- it('renders a labelled, pressable button', async () => {
13
- const handlePress = jest.fn()
14
- const { getByRole } = render(
15
- <Theme>
16
- <Button onPress={handlePress}>{label}</Button>
17
- </Theme>
18
- )
19
-
20
- const button = getByRole('button')
21
- expect(button).toHaveTextContent(label)
22
-
23
- expect(handlePress).toHaveBeenCalledTimes(0)
24
- await fireEvent.press(button)
25
- expect(handlePress).toHaveBeenCalledTimes(1)
26
- })
27
-
28
- it('applies theme variants', () => {
29
- const { tokens } = testTheme.components.Button
30
- const { getByText } = render(
31
- <Theme>
32
- <Button onPress={() => {}}>regular</Button>
33
- <Button variant={{ solid: true }} onPress={() => {}}>
34
- solid
35
- </Button>
36
- </Theme>
37
- )
38
-
39
- expect(getByText('regular')).toHaveStyle({ color: tokens.color })
40
- expect(getByText('solid')).toHaveStyle({ color: '#ffffff' })
41
- })
42
-
43
- it('maintains size if border width changes as state changes', async () => {
44
- // React Native Testing Library doesn't seem to support Pressable states
45
- // so we have to simulate the pressed-in state
46
- const { getByText } = render(
47
- <Theme>
48
- <Button onPress={() => {}}>default</Button>
49
- <Button variant={{ pressed: true }} onPress={() => {}}>
50
- pressed
51
- </Button>
52
- </Theme>
53
- )
54
- const defaultButton = getByText('default')
55
- const pressedButton = getByText('pressed')
56
-
57
- const getStyle = (element) => StyleSheet.flatten(element.props.style)
58
- const getElementHeight = ({
59
- borderWidth = 0,
60
- paddingVertical = 0,
61
- paddingTop = 0,
62
- paddingBottom = 0,
63
- lineHeight = 0
64
- }) =>
65
- borderWidth * 2 +
66
- (paddingTop || paddingVertical) +
67
- (paddingBottom || paddingVertical) +
68
- lineHeight
69
- const getTotalHeight = (element) =>
70
- getElementHeight(getStyle(element)) +
71
- getElementHeight(getStyle(element.parent.parent)) +
72
- getElementHeight(getStyle(element.parent.parent.parent))
73
-
74
- const containerStyle = getStyle(defaultButton.parent.parent.parent)
75
- const pressedContainerStyle = getStyle(pressedButton.parent.parent.parent)
76
-
77
- // test theme has border width that increases during pressed state
78
- expect(containerStyle.borderWidth).toEqual(2)
79
- expect(pressedContainerStyle.borderWidth).toEqual(8)
80
-
81
- // ensure that the overall height is balanced to not change
82
- const expectedHeight = 56
83
- expect(getTotalHeight(defaultButton)).toBe(expectedHeight)
84
- expect(getTotalHeight(pressedButton)).toBe(expectedHeight)
85
- })
86
- })