@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,94 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { render, fireEvent } from '@testing-library/react-native'
|
|
3
|
-
|
|
4
|
-
import { Platform } from 'react-native'
|
|
5
|
-
import { Select } from '../../src'
|
|
6
|
-
import Theme from '../../__fixtures__/Theme'
|
|
7
|
-
|
|
8
|
-
describe('Select', () => {
|
|
9
|
-
it('renders', () => {
|
|
10
|
-
render(
|
|
11
|
-
<Select>
|
|
12
|
-
<Select.Item value="item-1">Item 1</Select.Item>
|
|
13
|
-
<Select.Item value="item-2">Item 2</Select.Item>
|
|
14
|
-
</Select>,
|
|
15
|
-
{
|
|
16
|
-
wrapper: Theme
|
|
17
|
-
}
|
|
18
|
-
)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
if (Platform.OS === 'web') {
|
|
22
|
-
it('renders a placeholder', () => {
|
|
23
|
-
const { queryByText } = render(<Select placeholder="Test placeholder value" />, {
|
|
24
|
-
wrapper: Theme
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
expect(queryByText('Non-existing value')).toBeFalsy()
|
|
28
|
-
expect(queryByText('Test placeholder value')).not.toBeFalsy()
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it('changes value when controlled', () => {
|
|
32
|
-
const onChange = jest.fn()
|
|
33
|
-
|
|
34
|
-
const { getByTestId } = render(
|
|
35
|
-
<Select value="item-2" onChange={onChange} testID="Test-Select">
|
|
36
|
-
<Select.Item value="item-1">Item 1</Select.Item>
|
|
37
|
-
<Select.Item value="item-2">Item 2</Select.Item>
|
|
38
|
-
</Select>,
|
|
39
|
-
{
|
|
40
|
-
wrapper: Theme
|
|
41
|
-
}
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
expect(onChange).not.toHaveBeenCalled()
|
|
45
|
-
|
|
46
|
-
fireEvent.change(getByTestId('Test-Select'), { target: { value: 'item-1' } })
|
|
47
|
-
|
|
48
|
-
expect(onChange).toHaveBeenCalledTimes(1)
|
|
49
|
-
expect(onChange).toHaveBeenLastCalledWith('item-1')
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it('changes value when uncontrolled', () => {
|
|
53
|
-
const onChange = jest.fn()
|
|
54
|
-
|
|
55
|
-
const { getByTestId } = render(
|
|
56
|
-
<Select initialValue="item-2" onChange={onChange} testID="Test-Select">
|
|
57
|
-
<Select.Item value="item-1">Item 1</Select.Item>
|
|
58
|
-
<Select.Item value="item-2">Item 2</Select.Item>
|
|
59
|
-
</Select>,
|
|
60
|
-
{
|
|
61
|
-
wrapper: Theme
|
|
62
|
-
}
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
expect(onChange).not.toHaveBeenCalled()
|
|
66
|
-
|
|
67
|
-
const event = { target: { value: 'item-1' } }
|
|
68
|
-
fireEvent.change(getByTestId('Test-Select'), event)
|
|
69
|
-
|
|
70
|
-
expect(onChange).toHaveBeenCalledTimes(1)
|
|
71
|
-
expect(onChange).toHaveBeenLastCalledWith('item-1', event)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it("doesn't change value when readOnly", () => {
|
|
75
|
-
const onChange = jest.fn()
|
|
76
|
-
|
|
77
|
-
const { getByTestId } = render(
|
|
78
|
-
<Select value="item-2" onChange={onChange} testID="Test-Select" readOnly>
|
|
79
|
-
<Select.Item value="item-1">Item 1</Select.Item>
|
|
80
|
-
<Select.Item value="item-2">Item 2</Select.Item>
|
|
81
|
-
</Select>,
|
|
82
|
-
{
|
|
83
|
-
wrapper: Theme
|
|
84
|
-
}
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
expect(onChange).not.toHaveBeenCalled()
|
|
88
|
-
|
|
89
|
-
fireEvent.change(getByTestId('Test-Select'), { target: { value: 'item-1' } })
|
|
90
|
-
|
|
91
|
-
expect(onChange).not.toHaveBeenCalled()
|
|
92
|
-
})
|
|
93
|
-
}
|
|
94
|
-
})
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { Platform } from 'react-native'
|
|
3
|
-
import { render, fireEvent } from '@testing-library/react-native'
|
|
4
|
-
|
|
5
|
-
import { SideNav } from '../../src'
|
|
6
|
-
import Theme from '../../__fixtures__/Theme'
|
|
7
|
-
|
|
8
|
-
describe('SideNav', () => {
|
|
9
|
-
// TODO: this won't be called until cross-platform Jest tests are configured
|
|
10
|
-
// see https://github.com/telus/universal-design-system/issues/319
|
|
11
|
-
if (Platform.OS === 'web') {
|
|
12
|
-
it('renders group items inaccessible when collapsed', () => {
|
|
13
|
-
const { getByRole } = render(
|
|
14
|
-
<SideNav>
|
|
15
|
-
<SideNav.ItemsGroup label="Test group">
|
|
16
|
-
<SideNav.Item>Test item</SideNav.Item>
|
|
17
|
-
</SideNav.ItemsGroup>
|
|
18
|
-
</SideNav>,
|
|
19
|
-
{
|
|
20
|
-
wrapper: Theme
|
|
21
|
-
}
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
expect(getByRole('link')).toHaveProp('focusable', false)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
it('makes the group items accessible when expanded', () => {
|
|
28
|
-
const { getByRole, getByText } = render(
|
|
29
|
-
<SideNav>
|
|
30
|
-
<SideNav.ItemsGroup label="Test group">
|
|
31
|
-
<SideNav.Item>Test item</SideNav.Item>
|
|
32
|
-
</SideNav.ItemsGroup>
|
|
33
|
-
</SideNav>,
|
|
34
|
-
{
|
|
35
|
-
wrapper: Theme
|
|
36
|
-
}
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
expect(getByRole('link')).toHaveProp('focusable', false) // groups are collapsed by default
|
|
40
|
-
|
|
41
|
-
fireEvent.press(getByText('Test group'))
|
|
42
|
-
|
|
43
|
-
expect(getByRole('link')).not.toHaveProp('focusable')
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
it('expands multiple groups when accordion = false', () => {
|
|
48
|
-
const { getAllByA11yState, getByText } = render(
|
|
49
|
-
<SideNav accordion={false}>
|
|
50
|
-
<SideNav.ItemsGroup label="Test group 1">
|
|
51
|
-
<SideNav.Item>Test item</SideNav.Item>
|
|
52
|
-
</SideNav.ItemsGroup>
|
|
53
|
-
<SideNav.ItemsGroup label="Test group 2">
|
|
54
|
-
<SideNav.Item>Test item</SideNav.Item>
|
|
55
|
-
</SideNav.ItemsGroup>
|
|
56
|
-
</SideNav>,
|
|
57
|
-
{
|
|
58
|
-
wrapper: Theme
|
|
59
|
-
}
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
fireEvent.press(getByText('Test group 1'))
|
|
63
|
-
fireEvent.press(getByText('Test group 2'))
|
|
64
|
-
|
|
65
|
-
expect(getAllByA11yState({ expanded: true }).length).toBe(2)
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
it('expands only one group when accordion = true', () => {
|
|
69
|
-
const { getAllByA11yState, getByText } = render(
|
|
70
|
-
<SideNav accordion>
|
|
71
|
-
<SideNav.ItemsGroup label="Test group 1">
|
|
72
|
-
<SideNav.Item>Test item</SideNav.Item>
|
|
73
|
-
</SideNav.ItemsGroup>
|
|
74
|
-
<SideNav.ItemsGroup label="Test group 2">
|
|
75
|
-
<SideNav.Item>Test item</SideNav.Item>
|
|
76
|
-
</SideNav.ItemsGroup>
|
|
77
|
-
</SideNav>,
|
|
78
|
-
{
|
|
79
|
-
wrapper: Theme
|
|
80
|
-
}
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
fireEvent.press(getByText('Test group 1'))
|
|
84
|
-
fireEvent.press(getByText('Test group 2'))
|
|
85
|
-
|
|
86
|
-
expect(getAllByA11yState({ expanded: true }).length).toBe(1)
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
describe('Item', () => {
|
|
90
|
-
it('triggers the onPress callback when pressed', () => {
|
|
91
|
-
const itemId = 'item-id'
|
|
92
|
-
const groupId = 'group-id'
|
|
93
|
-
const onPress = jest.fn()
|
|
94
|
-
|
|
95
|
-
const { getByText } = render(
|
|
96
|
-
<SideNav.Item onPress={onPress} itemId={itemId} groupId={groupId}>
|
|
97
|
-
Test item
|
|
98
|
-
</SideNav.Item>,
|
|
99
|
-
{
|
|
100
|
-
wrapper: Theme
|
|
101
|
-
}
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
fireEvent.press(getByText('Test item'))
|
|
105
|
-
|
|
106
|
-
expect(onPress).toHaveBeenCalledTimes(1)
|
|
107
|
-
expect(onPress).toHaveBeenLastCalledWith(itemId, groupId)
|
|
108
|
-
})
|
|
109
|
-
})
|
|
110
|
-
})
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { render } from '@testing-library/react-native'
|
|
3
|
-
|
|
4
|
-
import { Skeleton } from '../../src'
|
|
5
|
-
import Theme from '../../__fixtures__/Theme'
|
|
6
|
-
import testTheme from '../../__fixtures__/testTheme'
|
|
7
|
-
|
|
8
|
-
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper')
|
|
9
|
-
const { tokens } = testTheme.components.Skeleton
|
|
10
|
-
|
|
11
|
-
const setup = ({ size = 10, characters, lines, shape } = {}) =>
|
|
12
|
-
render(
|
|
13
|
-
<Theme>
|
|
14
|
-
<Skeleton
|
|
15
|
-
size={size}
|
|
16
|
-
characters={characters}
|
|
17
|
-
lines={lines}
|
|
18
|
-
shape={shape}
|
|
19
|
-
aria-label="loader"
|
|
20
|
-
/>
|
|
21
|
-
</Theme>
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
describe('Skeleton', () => {
|
|
25
|
-
it('should calculate line width based on baseWidth', () => {
|
|
26
|
-
const { getByTestId } = setup()
|
|
27
|
-
const { characters, baseWidth } = tokens
|
|
28
|
-
const lineWidth = characters * baseWidth
|
|
29
|
-
|
|
30
|
-
const element = getByTestId('skeleton')
|
|
31
|
-
|
|
32
|
-
expect(element).toHaveStyle({ width: lineWidth })
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('render a circle', () => {
|
|
36
|
-
const { getByTestId } = setup({ shape: 'circle' })
|
|
37
|
-
const { radius } = tokens
|
|
38
|
-
|
|
39
|
-
const element = getByTestId('skeleton')
|
|
40
|
-
|
|
41
|
-
expect(element.width).toEqual(element.height)
|
|
42
|
-
expect(element).toHaveStyle({ borderRadius: radius })
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('render a square', () => {
|
|
46
|
-
const { getByTestId } = setup({ shape: 'box' })
|
|
47
|
-
|
|
48
|
-
const element = getByTestId('skeleton')
|
|
49
|
-
|
|
50
|
-
expect(element.width).toEqual(element.height)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
it('render multiple lines', () => {
|
|
54
|
-
const lines = 8
|
|
55
|
-
const { queryAllByTestId } = setup({ lines })
|
|
56
|
-
|
|
57
|
-
const elements = queryAllByTestId('skeleton')
|
|
58
|
-
|
|
59
|
-
expect(elements.length).toEqual(lines)
|
|
60
|
-
})
|
|
61
|
-
})
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { render } from '@testing-library/react-native'
|
|
3
|
-
|
|
4
|
-
import { Text } from 'react-native'
|
|
5
|
-
import { SkipLink } from '../../src'
|
|
6
|
-
import Theme from '../../__fixtures__/Theme'
|
|
7
|
-
import testTheme from '../../__fixtures__/testTheme'
|
|
8
|
-
|
|
9
|
-
const href = '#prefered-content'
|
|
10
|
-
const content = 'Skip to main content'
|
|
11
|
-
|
|
12
|
-
const setup = ({ tokens } = {}) =>
|
|
13
|
-
render(
|
|
14
|
-
<Theme>
|
|
15
|
-
<SkipLink href={href} tokens={tokens}>
|
|
16
|
-
{content}
|
|
17
|
-
</SkipLink>
|
|
18
|
-
</Theme>
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
describe('SkipLink', () => {
|
|
22
|
-
it('renders a skip link', () => {
|
|
23
|
-
const { getByText } = setup()
|
|
24
|
-
const skipLinkContent = getByText(content)
|
|
25
|
-
expect(skipLinkContent).toBeTruthy()
|
|
26
|
-
expect(skipLinkContent).toHaveTextContent(content)
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('renders skip link with the default style when focused', () => {
|
|
30
|
-
const { color, ...containerStyle } = testTheme.components.SkipLink.tokens
|
|
31
|
-
const { getByText } = setup()
|
|
32
|
-
const skipLink = getByText(content)
|
|
33
|
-
const container = skipLink.parent
|
|
34
|
-
|
|
35
|
-
expect(container).toHaveStyle(containerStyle)
|
|
36
|
-
expect(skipLink).toHaveStyle({ color })
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('renders content when passed a React element', () => {
|
|
40
|
-
const { getByText } = render(
|
|
41
|
-
<SkipLink>
|
|
42
|
-
<Text href={href}>{content}</Text>
|
|
43
|
-
</SkipLink>,
|
|
44
|
-
{ wrapper: Theme }
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
const skipContent = getByText(content)
|
|
48
|
-
expect(skipContent).toBeTruthy()
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
it('renders a card with custom tokens', () => {
|
|
52
|
-
const customStyle = {
|
|
53
|
-
backgroundColor: '#cecfcd',
|
|
54
|
-
paddingVertical: 99
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const { getByText } = setup({ tokens: customStyle })
|
|
58
|
-
const skipLink = getByText(content).parent
|
|
59
|
-
expect(skipLink).toHaveStyle({ ...customStyle })
|
|
60
|
-
})
|
|
61
|
-
})
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { render } from '@testing-library/react-native'
|
|
3
|
-
|
|
4
|
-
import { Spacer } from '../../src'
|
|
5
|
-
import Theme from '../../__fixtures__/Theme'
|
|
6
|
-
|
|
7
|
-
const testID = 'spacer'
|
|
8
|
-
|
|
9
|
-
describe('Spacer', () => {
|
|
10
|
-
it('has smallest size from spacing scale by default', () => {
|
|
11
|
-
const expectedSize = 4 // from __fixtures__/testTheme.js
|
|
12
|
-
const { getByTestId } = render(<Spacer testID={testID} />, { wrapper: Theme })
|
|
13
|
-
expect(getByTestId(testID)).toHaveStyle({
|
|
14
|
-
height: expectedSize
|
|
15
|
-
})
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it('has size from spacing scale if space prop passed', () => {
|
|
19
|
-
const expectedSize = 8 // from __fixtures__/testTheme.js
|
|
20
|
-
const { getByTestId } = render(<Spacer space={2} testID={testID} />, { wrapper: Theme })
|
|
21
|
-
expect(getByTestId(testID)).toHaveStyle({
|
|
22
|
-
height: expectedSize
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('has no size if 0 passed in', () => {
|
|
27
|
-
const expectedSize = 0
|
|
28
|
-
const { getByTestId } = render(<Spacer space={0} testID={testID} />, { wrapper: Theme })
|
|
29
|
-
expect(getByTestId(testID)).toHaveStyle({
|
|
30
|
-
height: expectedSize
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
describe('Spacer (row)', () => {
|
|
36
|
-
it('has smallest size from spacing scale by default', () => {
|
|
37
|
-
const expectedSize = 4 // from __fixtures__/testTheme.js
|
|
38
|
-
const { getByTestId } = render(<Spacer testID={testID} direction="row" />, { wrapper: Theme })
|
|
39
|
-
expect(getByTestId(testID)).toHaveStyle({
|
|
40
|
-
width: expectedSize
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
it('has size from spacing scale if space prop passed', () => {
|
|
45
|
-
const expectedSize = 8 // from __fixtures__/testTheme.js
|
|
46
|
-
const { getByTestId } = render(<Spacer space={2} testID={testID} direction="row" />, {
|
|
47
|
-
wrapper: Theme
|
|
48
|
-
})
|
|
49
|
-
expect(getByTestId(testID)).toHaveStyle({
|
|
50
|
-
width: expectedSize
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('has no size if 0 passed in', () => {
|
|
55
|
-
const expectedSize = 0
|
|
56
|
-
const { getByTestId } = render(<Spacer space={0} testID={testID} direction="row" />, {
|
|
57
|
-
wrapper: Theme
|
|
58
|
-
})
|
|
59
|
-
expect(getByTestId(testID)).toHaveStyle({
|
|
60
|
-
width: expectedSize
|
|
61
|
-
})
|
|
62
|
-
})
|
|
63
|
-
})
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { render } from '@testing-library/react-native'
|
|
3
|
-
|
|
4
|
-
import { Spacer, StackView, Typography } from '../../src'
|
|
5
|
-
import Theme from '../../__fixtures__/Theme'
|
|
6
|
-
import testTheme from '../../__fixtures__/testTheme'
|
|
7
|
-
import { getFirstAncestorOfType } from '../../__fixtures__/test-utils'
|
|
8
|
-
|
|
9
|
-
describe('StackView', () => {
|
|
10
|
-
it('renders separators and children as direct children of a flex column by default', () => {
|
|
11
|
-
const expectedStyle = { flexDirection: 'column' }
|
|
12
|
-
|
|
13
|
-
const { getByTestId } = render(
|
|
14
|
-
<StackView space={2}>
|
|
15
|
-
<Typography>A</Typography>
|
|
16
|
-
<Typography>B</Typography>
|
|
17
|
-
</StackView>,
|
|
18
|
-
{ wrapper: Theme }
|
|
19
|
-
)
|
|
20
|
-
const { parent } = getFirstAncestorOfType(getByTestId('Stack-Spacer-1'), Spacer)
|
|
21
|
-
expect(parent.type).toBe('View')
|
|
22
|
-
expect(parent).toHaveStyle(expectedStyle)
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
it('renders separators and children as direct children of a flex column if direction is "column-reverse"', () => {
|
|
26
|
-
const expectedStyle = { flexDirection: 'column-reverse' }
|
|
27
|
-
|
|
28
|
-
const { getByTestId } = render(
|
|
29
|
-
<StackView direction="column-reverse" space={2}>
|
|
30
|
-
<Typography>A</Typography>
|
|
31
|
-
<Typography>B</Typography>
|
|
32
|
-
</StackView>,
|
|
33
|
-
{ wrapper: Theme }
|
|
34
|
-
)
|
|
35
|
-
const { parent } = getFirstAncestorOfType(getByTestId('Stack-Spacer-1'), Spacer)
|
|
36
|
-
expect(parent.type).toBe('View')
|
|
37
|
-
expect(parent).toHaveStyle(expectedStyle)
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
it('renders separators and children as direct children of a flex row if direction is "row"', () => {
|
|
41
|
-
const expectedStyle = { flexDirection: 'row' }
|
|
42
|
-
|
|
43
|
-
const { getByTestId } = render(
|
|
44
|
-
<StackView direction="row" space={2}>
|
|
45
|
-
<Typography>A</Typography>
|
|
46
|
-
<Typography>B</Typography>
|
|
47
|
-
</StackView>,
|
|
48
|
-
{ wrapper: Theme }
|
|
49
|
-
)
|
|
50
|
-
const { parent } = getFirstAncestorOfType(getByTestId('Stack-Spacer-1'), Spacer)
|
|
51
|
-
expect(parent.type).toBe('View')
|
|
52
|
-
expect(parent).toHaveStyle(expectedStyle)
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('renders separators and children as direct children of a flex row if direction is "row-reverse"', () => {
|
|
56
|
-
const expectedStyle = { flexDirection: 'row-reverse' }
|
|
57
|
-
|
|
58
|
-
const { getByTestId } = render(
|
|
59
|
-
<StackView direction="row-reverse" space={2}>
|
|
60
|
-
<Typography>A</Typography>
|
|
61
|
-
<Typography>B</Typography>
|
|
62
|
-
</StackView>,
|
|
63
|
-
{ wrapper: Theme }
|
|
64
|
-
)
|
|
65
|
-
const { parent } = getFirstAncestorOfType(getByTestId('Stack-Spacer-1'), Spacer)
|
|
66
|
-
expect(parent.type).toBe('View')
|
|
67
|
-
expect(parent).toHaveStyle(expectedStyle)
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it('renders horizontal dividers by default', () => {
|
|
71
|
-
const expectedSize = 4 // from __fixtures__/testTheme.js
|
|
72
|
-
const expectedStyle = { height: expectedSize }
|
|
73
|
-
const { color } = testTheme.components.Divider.tokens
|
|
74
|
-
|
|
75
|
-
const { getByTestId } = render(
|
|
76
|
-
<StackView divider>
|
|
77
|
-
<Typography>A</Typography>
|
|
78
|
-
<Typography>B</Typography>
|
|
79
|
-
<Typography>C</Typography>
|
|
80
|
-
</StackView>,
|
|
81
|
-
{ wrapper: Theme }
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
expect(getByTestId('Stack-Divider-1')).toHaveStyle({ borderBottomColor: color })
|
|
85
|
-
expect(getByTestId('Stack-Divider-2')).toHaveStyle({ borderBottomColor: color })
|
|
86
|
-
|
|
87
|
-
expect(getByTestId('Stack-Divider-1')).not.toHaveStyle({ borderRightColor: color })
|
|
88
|
-
expect(getByTestId('Stack-Divider-2')).not.toHaveStyle({ borderRightColor: color })
|
|
89
|
-
|
|
90
|
-
expect(getByTestId('Stack-Divider-1-Spacer-before')).toHaveStyle(expectedStyle)
|
|
91
|
-
expect(getByTestId('Stack-Divider-1-Spacer-after')).toHaveStyle(expectedStyle)
|
|
92
|
-
expect(getByTestId('Stack-Divider-2-Spacer-before')).toHaveStyle(expectedStyle)
|
|
93
|
-
expect(getByTestId('Stack-Divider-2-Spacer-after')).toHaveStyle(expectedStyle)
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
it('renders horizontal dividers if direction is "column-reverse"', () => {
|
|
97
|
-
const expectedSize = 4 // from __fixtures__/testTheme.js
|
|
98
|
-
const expectedStyle = { height: expectedSize }
|
|
99
|
-
const { color } = testTheme.components.Divider.tokens
|
|
100
|
-
|
|
101
|
-
const { getByTestId } = render(
|
|
102
|
-
<StackView direction="column-reverse" divider>
|
|
103
|
-
<Typography>A</Typography>
|
|
104
|
-
<Typography>B</Typography>
|
|
105
|
-
<Typography>C</Typography>
|
|
106
|
-
</StackView>,
|
|
107
|
-
{ wrapper: Theme }
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
expect(getByTestId('Stack-Divider-1')).toHaveStyle({ borderBottomColor: color })
|
|
111
|
-
expect(getByTestId('Stack-Divider-2')).toHaveStyle({ borderBottomColor: color })
|
|
112
|
-
|
|
113
|
-
expect(getByTestId('Stack-Divider-1')).not.toHaveStyle({ borderRightColor: color })
|
|
114
|
-
expect(getByTestId('Stack-Divider-2')).not.toHaveStyle({ borderRightColor: color })
|
|
115
|
-
|
|
116
|
-
expect(getByTestId('Stack-Divider-1-Spacer-before')).toHaveStyle(expectedStyle)
|
|
117
|
-
expect(getByTestId('Stack-Divider-1-Spacer-after')).toHaveStyle(expectedStyle)
|
|
118
|
-
expect(getByTestId('Stack-Divider-2-Spacer-before')).toHaveStyle(expectedStyle)
|
|
119
|
-
expect(getByTestId('Stack-Divider-2-Spacer-after')).toHaveStyle(expectedStyle)
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
it('renders vertical dividers if direction is "row"', () => {
|
|
123
|
-
const { color } = testTheme.components.Divider.tokens
|
|
124
|
-
const expectedSize = 4 // from __fixtures__/testTheme.js
|
|
125
|
-
const expectedStyle = { width: expectedSize }
|
|
126
|
-
|
|
127
|
-
const { getByTestId } = render(
|
|
128
|
-
<StackView divider direction="row">
|
|
129
|
-
<Typography>A</Typography>
|
|
130
|
-
<Typography>B</Typography>
|
|
131
|
-
<Typography>C</Typography>
|
|
132
|
-
</StackView>,
|
|
133
|
-
{ wrapper: Theme }
|
|
134
|
-
)
|
|
135
|
-
|
|
136
|
-
expect(getByTestId('Stack-Divider-1')).not.toHaveStyle({ borderBottomColor: color })
|
|
137
|
-
expect(getByTestId('Stack-Divider-2')).not.toHaveStyle({ borderBottomColor: color })
|
|
138
|
-
|
|
139
|
-
expect(getByTestId('Stack-Divider-1')).toHaveStyle({ borderRightColor: color })
|
|
140
|
-
expect(getByTestId('Stack-Divider-2')).toHaveStyle({ borderRightColor: color })
|
|
141
|
-
|
|
142
|
-
expect(getByTestId('Stack-Divider-1-Spacer-before')).toHaveStyle(expectedStyle)
|
|
143
|
-
expect(getByTestId('Stack-Divider-1-Spacer-after')).toHaveStyle(expectedStyle)
|
|
144
|
-
expect(getByTestId('Stack-Divider-2-Spacer-before')).toHaveStyle(expectedStyle)
|
|
145
|
-
expect(getByTestId('Stack-Divider-2-Spacer-after')).toHaveStyle(expectedStyle)
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
it('renders vertical dividers if direction is "row-reverse"', () => {
|
|
149
|
-
const { color } = testTheme.components.Divider.tokens
|
|
150
|
-
const expectedSize = 4 // from __fixtures__/testTheme.js
|
|
151
|
-
const expectedStyle = { width: expectedSize }
|
|
152
|
-
|
|
153
|
-
const { getByTestId } = render(
|
|
154
|
-
<StackView divider direction="row-reverse">
|
|
155
|
-
<Typography>A</Typography>
|
|
156
|
-
<Typography>B</Typography>
|
|
157
|
-
<Typography>C</Typography>
|
|
158
|
-
</StackView>,
|
|
159
|
-
{ wrapper: Theme }
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
expect(getByTestId('Stack-Divider-1')).not.toHaveStyle({ borderBottomColor: color })
|
|
163
|
-
expect(getByTestId('Stack-Divider-2')).not.toHaveStyle({ borderBottomColor: color })
|
|
164
|
-
|
|
165
|
-
expect(getByTestId('Stack-Divider-1')).toHaveStyle({ borderRightColor: color })
|
|
166
|
-
expect(getByTestId('Stack-Divider-2')).toHaveStyle({ borderRightColor: color })
|
|
167
|
-
|
|
168
|
-
expect(getByTestId('Stack-Divider-1-Spacer-before')).toHaveStyle(expectedStyle)
|
|
169
|
-
expect(getByTestId('Stack-Divider-1-Spacer-after')).toHaveStyle(expectedStyle)
|
|
170
|
-
expect(getByTestId('Stack-Divider-2-Spacer-before')).toHaveStyle(expectedStyle)
|
|
171
|
-
expect(getByTestId('Stack-Divider-2-Spacer-after')).toHaveStyle(expectedStyle)
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
it('renders row spacers if direction is "row"', () => {
|
|
175
|
-
const expectedSize = 8 // from __fixtures__/testTheme.js
|
|
176
|
-
|
|
177
|
-
const { getByTestId } = render(
|
|
178
|
-
<StackView direction="row" space={2}>
|
|
179
|
-
<Typography>A</Typography>
|
|
180
|
-
<Typography>B</Typography>
|
|
181
|
-
<Typography>C</Typography>
|
|
182
|
-
</StackView>,
|
|
183
|
-
{ wrapper: Theme }
|
|
184
|
-
)
|
|
185
|
-
|
|
186
|
-
expect(getByTestId('Stack-Spacer-1')).not.toHaveStyle({ height: expectedSize })
|
|
187
|
-
expect(getByTestId('Stack-Spacer-2')).not.toHaveStyle({ height: expectedSize })
|
|
188
|
-
|
|
189
|
-
expect(getByTestId('Stack-Spacer-1')).toHaveStyle({ width: expectedSize })
|
|
190
|
-
expect(getByTestId('Stack-Spacer-2')).toHaveStyle({ width: expectedSize })
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
it('renders row spacers if direction is "row-reverse"', () => {
|
|
194
|
-
const expectedSize = 8 // from __fixtures__/testTheme.js
|
|
195
|
-
|
|
196
|
-
const { getByTestId } = render(
|
|
197
|
-
<StackView direction="row-reverse" space={2}>
|
|
198
|
-
<Typography>A</Typography>
|
|
199
|
-
<Typography>B</Typography>
|
|
200
|
-
<Typography>C</Typography>
|
|
201
|
-
</StackView>,
|
|
202
|
-
{ wrapper: Theme }
|
|
203
|
-
)
|
|
204
|
-
|
|
205
|
-
expect(getByTestId('Stack-Spacer-1')).not.toHaveStyle({ height: expectedSize })
|
|
206
|
-
expect(getByTestId('Stack-Spacer-2')).not.toHaveStyle({ height: expectedSize })
|
|
207
|
-
|
|
208
|
-
expect(getByTestId('Stack-Spacer-1')).toHaveStyle({ width: expectedSize })
|
|
209
|
-
expect(getByTestId('Stack-Spacer-2')).toHaveStyle({ width: expectedSize })
|
|
210
|
-
})
|
|
211
|
-
})
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { render } from '@testing-library/react-native'
|
|
3
|
-
|
|
4
|
-
import { StackWrap, Typography } from '../../src'
|
|
5
|
-
import Theme from '../../__fixtures__/Theme'
|
|
6
|
-
|
|
7
|
-
describe('StackWrap', () => {
|
|
8
|
-
it('renders no spacers (because they would wrap badly)', () => {
|
|
9
|
-
const { queryAllByTestId } = render(
|
|
10
|
-
<StackWrap space={2}>
|
|
11
|
-
<Typography>A</Typography>
|
|
12
|
-
<Typography>B</Typography>
|
|
13
|
-
<Typography>C</Typography>
|
|
14
|
-
</StackWrap>,
|
|
15
|
-
{ wrapper: Theme }
|
|
16
|
-
)
|
|
17
|
-
expect(queryAllByTestId(/Spacer/)).toHaveLength(0)
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
it('puts a `gap` between lines which may be different to `space` between items', () => {
|
|
21
|
-
// This test unavoidably hangs on some implementation details,
|
|
22
|
-
// which isn't ideal, but it does test something a user would see.
|
|
23
|
-
const expectedStyle = { paddingBottom: 8, paddingRight: 4 }
|
|
24
|
-
|
|
25
|
-
const { getByTestId } = render(
|
|
26
|
-
<StackWrap space={1} gap={2}>
|
|
27
|
-
<Typography>A</Typography>
|
|
28
|
-
<Typography>B</Typography>
|
|
29
|
-
</StackWrap>,
|
|
30
|
-
{ wrapper: Theme }
|
|
31
|
-
)
|
|
32
|
-
expect(getByTestId('Stack-Box-1')).toHaveStyle(expectedStyle)
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('accepts accessibility props on the container responsible for wrapping content', () => {
|
|
36
|
-
const expectedStyle = { flexWrap: 'wrap' }
|
|
37
|
-
|
|
38
|
-
const { getByRole } = render(
|
|
39
|
-
<StackWrap accessibilityRole="radiogroup">
|
|
40
|
-
<Typography>A</Typography>
|
|
41
|
-
<Typography>B</Typography>
|
|
42
|
-
</StackWrap>,
|
|
43
|
-
{ wrapper: Theme }
|
|
44
|
-
)
|
|
45
|
-
expect(getByRole('radiogroup')).toHaveStyle(expectedStyle)
|
|
46
|
-
})
|
|
47
|
-
})
|