@instructure/ui-flex 10.19.2-snapshot-3 → 10.19.2-snapshot-4

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.
@@ -1,60 +0,0 @@
1
- /*
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2015 - present Instructure, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
- import { render, waitFor } from '@testing-library/react'
26
- import { vi } from 'vitest'
27
-
28
- import '@testing-library/jest-dom'
29
- import { runAxeCheck } from '@instructure/ui-axe-check'
30
- import { Item } from '../index'
31
-
32
- describe('<Item />', () => {
33
- it('should render children', async () => {
34
- const { container } = render(<Item>Flex item 1</Item>)
35
- const item = container.querySelector('[class*="-flexItem"]')
36
-
37
- expect(item).toBeInTheDocument()
38
- expect(item).toHaveTextContent('Flex item 1')
39
- })
40
-
41
- it('should support an elementRef prop', async () => {
42
- const elementRef = vi.fn()
43
-
44
- const { container } = render(
45
- <Item elementRef={elementRef}>Flex item 2</Item>
46
- )
47
- const item = container.querySelector('[class*="-flexItem"]')
48
-
49
- await waitFor(() => {
50
- expect(elementRef).toHaveBeenCalledWith(item)
51
- })
52
- })
53
-
54
- it('should meet a11y standards', async () => {
55
- const { container } = render(<Item>Flex item 3</Item>)
56
- const axeCheck = await runAxeCheck(container)
57
-
58
- expect(axeCheck).toBe(true)
59
- })
60
- })
@@ -1,256 +0,0 @@
1
- /*
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2015 - present Instructure, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
- import { render, screen, waitFor } from '@testing-library/react'
26
- import { vi } from 'vitest'
27
-
28
- import '@testing-library/jest-dom'
29
- import { runAxeCheck } from '@instructure/ui-axe-check'
30
- import { Flex } from '../index'
31
-
32
- describe('<Flex />', () => {
33
- it('should render Flex.Items as children', async () => {
34
- const { container } = render(
35
- <Flex>
36
- <Flex.Item>Flex item 1</Flex.Item>
37
- <Flex.Item>Flex item 2</Flex.Item>
38
- <Flex.Item>Flex item 3</Flex.Item>
39
- <Flex.Item>Flex item 4</Flex.Item>
40
- </Flex>
41
- )
42
- const flex = container.querySelector('[class*="flex"]')
43
- expect(flex).toBeInTheDocument()
44
-
45
- const items = flex?.querySelectorAll('[class*="-flexItem"]')
46
- expect(items?.length).toBe(4)
47
- })
48
-
49
- it('should render other markup as children', async () => {
50
- const { container } = render(
51
- <Flex>
52
- <div>foo</div>
53
- <div>bar</div>
54
- <div>baz</div>
55
- </Flex>
56
- )
57
- const flex = container.querySelector('[class*="flex"]')
58
- const childs = flex?.childNodes
59
-
60
- expect(childs?.length).toBe(3)
61
- })
62
-
63
- it('should render children when children is a function', async () => {
64
- render(<Flex>{() => <div>hello world</div>}</Flex>)
65
- const child = screen.getByText('hello world')
66
-
67
- expect(child).toBeInTheDocument()
68
- })
69
-
70
- it('should render no markup if there are no children', async () => {
71
- const { container } = render(<Flex></Flex>)
72
- const flex = container.querySelector('[class*="flex"]')
73
-
74
- expect(flex).not.toBeInTheDocument()
75
- })
76
-
77
- it('should accept width and height as props', async () => {
78
- const { container } = render(
79
- <Flex width="400px" height="200px">
80
- <Flex.Item>Flex item 1</Flex.Item>
81
- <Flex.Item>Flex item 2</Flex.Item>
82
- <Flex.Item>Flex item 3</Flex.Item>
83
- <Flex.Item>Flex item 4</Flex.Item>
84
- </Flex>
85
- )
86
- const flex = container.querySelector('[class*="flex"]')!
87
- const flexStyle = window.getComputedStyle(flex)
88
-
89
- expect(flexStyle.width).toBe('400px')
90
- expect(flexStyle.height).toBe('200px')
91
- })
92
-
93
- it('should set flex-direction with the direction property', async () => {
94
- const { container } = render(
95
- <Flex direction="column">
96
- <Flex.Item>Flex item 1</Flex.Item>
97
- <Flex.Item>Flex item 2</Flex.Item>
98
- </Flex>
99
- )
100
- const flex = container.querySelector('[class*="flex"]')!
101
- const flexStyle = window.getComputedStyle(flex)
102
-
103
- expect(flexStyle.flexDirection).toBe('column')
104
- })
105
-
106
- it('should render an inline-flex container with the display property', async () => {
107
- const { container } = render(
108
- <Flex display="inline-flex">
109
- <Flex.Item>Flex item 1</Flex.Item>
110
- <Flex.Item>Flex item 2</Flex.Item>
111
- </Flex>
112
- )
113
- const flex = container.querySelector(
114
- '[class*="inlineFlex"][class*="flex"]'
115
- )!
116
- const flexStyle = window.getComputedStyle(flex)
117
-
118
- expect(flexStyle.display).toBe('inline-flex')
119
- })
120
-
121
- it('should set align-items with the alignItems property', async () => {
122
- const { container } = render(
123
- <Flex alignItems="start">
124
- <Flex.Item>Flex item 1</Flex.Item>
125
- <Flex.Item>Flex item 2</Flex.Item>
126
- </Flex>
127
- )
128
- const flex = container.querySelector('[class*="flex"]')!
129
- const flexStyle = window.getComputedStyle(flex)
130
-
131
- expect(flexStyle.alignItems).toBe('flex-start')
132
- })
133
-
134
- it('should set justify-content with the justifyItems property', async () => {
135
- const { container } = render(
136
- <Flex justifyItems="space-between">
137
- <Flex.Item>Flex item 1</Flex.Item>
138
- <Flex.Item>Flex item 2</Flex.Item>
139
- </Flex>
140
- )
141
- const flex = container.querySelector('[class*="flex"]')!
142
- const flexStyle = window.getComputedStyle(flex)
143
-
144
- expect(flexStyle.justifyContent).toBe('space-between')
145
- })
146
-
147
- it('should set flex-wrap with the wrap property', async () => {
148
- const { container } = render(
149
- <Flex wrap="wrap">
150
- <Flex.Item>Flex item 1</Flex.Item>
151
- <Flex.Item>Flex item 2</Flex.Item>
152
- </Flex>
153
- )
154
- const flex = container.querySelector('[class*="flex"]')!
155
- const flexStyle = window.getComputedStyle(flex)
156
-
157
- expect(flexStyle.flexWrap).toBe('wrap')
158
- })
159
-
160
- it('should let Flex.Items align themselves with the align property', async () => {
161
- const { container } = render(
162
- <Flex alignItems="end">
163
- <Flex.Item align="stretch">Flex item 1</Flex.Item>
164
- <Flex.Item>Flex item 2</Flex.Item>
165
- </Flex>
166
- )
167
- const flex = container.querySelector('[class*="flex"]')!
168
- const item = screen.getByText('Flex item 1')
169
-
170
- const flexStyle = window.getComputedStyle(flex)
171
- const itemStyle = window.getComputedStyle(item)
172
-
173
- expect(flexStyle.alignItems).toBe('flex-end')
174
- expect(itemStyle.alignSelf).toBe('stretch')
175
- })
176
-
177
- it('should let Flex.Items flex-grow with the shouldGrow property', async () => {
178
- render(
179
- <Flex>
180
- <Flex.Item>Flex item 1</Flex.Item>
181
- <Flex.Item shouldGrow>Flex item 2</Flex.Item>
182
- </Flex>
183
- )
184
- const item1 = screen.getByText('Flex item 1')
185
- const item2 = screen.getByText('Flex item 2')
186
-
187
- const item1Style = window.getComputedStyle(item1)
188
- const item2Style = window.getComputedStyle(item2)
189
-
190
- expect(item1Style.flexGrow).toBe('')
191
- expect(item2Style.flexGrow).toBe('1')
192
- })
193
-
194
- it('should let Flex.Items flex-shrink with the shouldShrink property', async () => {
195
- render(
196
- <Flex>
197
- <Flex.Item>Flex item 1</Flex.Item>
198
- <Flex.Item shouldShrink>Flex item 2</Flex.Item>
199
- </Flex>
200
- )
201
- const item1 = screen.getByText('Flex item 1')
202
- const item2 = screen.getByText('Flex item 2')
203
-
204
- const item1Style = window.getComputedStyle(item1)
205
- const item2Style = window.getComputedStyle(item2)
206
-
207
- expect(item1Style.flexShrink).toBe('0')
208
- expect(item2Style.flexShrink).toBe('1')
209
- })
210
-
211
- it('should set flex-basis and min-width on Flex.Items with the size property', async () => {
212
- render(
213
- <Flex>
214
- <Flex.Item>Flex item 1</Flex.Item>
215
- <Flex.Item>Flex item 2</Flex.Item>
216
- <Flex.Item size="100px">Flex item 3</Flex.Item>
217
- </Flex>
218
- )
219
- const item2 = screen.getByText('Flex item 2')
220
- const item3 = screen.getByText('Flex item 3')
221
-
222
- const item2Style = window.getComputedStyle(item2)
223
- const item3Style = window.getComputedStyle(item3)
224
-
225
- expect(item2Style.flexBasis).toBe('')
226
- expect(item3Style.flexBasis).toBe('100px')
227
- expect(item3Style.minWidth).toBe('100px')
228
- })
229
-
230
- it('should support an elementRef prop', async () => {
231
- const elementRef = vi.fn()
232
-
233
- const { container } = render(
234
- <Flex elementRef={elementRef}>
235
- <Flex.Item>Flex item</Flex.Item>
236
- </Flex>
237
- )
238
- const flex = container.querySelector('[class*="flex"]')
239
-
240
- await waitFor(() => {
241
- expect(elementRef).toHaveBeenCalledWith(flex)
242
- })
243
- })
244
-
245
- it('should meet a11y standards', async () => {
246
- const { container } = render(
247
- <Flex>
248
- <Flex.Item>Flex item 1</Flex.Item>
249
- <Flex.Item>Flex item 2</Flex.Item>
250
- </Flex>
251
- )
252
- const axeCheck = await runAxeCheck(container)
253
-
254
- expect(axeCheck).toBe(true)
255
- })
256
- })
@@ -1,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=FlexItem.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FlexItem.test.d.ts","sourceRoot":"","sources":["../../../../src/Flex/Item/__new-tests__/FlexItem.test.tsx"],"names":[],"mappings":"AA2BA,OAAO,2BAA2B,CAAA"}
@@ -1,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=Flex.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Flex.test.d.ts","sourceRoot":"","sources":["../../../src/Flex/__new-tests__/Flex.test.tsx"],"names":[],"mappings":"AA2BA,OAAO,2BAA2B,CAAA"}