@instructure/ui-view 10.19.2-snapshot-3 → 10.19.2-snapshot-5

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,244 +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 { CSSProperties } from 'react'
26
- import { render, screen } from '@testing-library/react'
27
- import { vi } from 'vitest'
28
- import type { MockInstance } from 'vitest'
29
- import '@testing-library/jest-dom'
30
-
31
- import { View } from '../../index'
32
- import { runAxeCheck } from '@instructure/ui-axe-check'
33
-
34
- describe('<View />', () => {
35
- let consoleWarningMock: ReturnType<typeof vi.spyOn>
36
- let consoleErrorMock: ReturnType<typeof vi.spyOn>
37
-
38
- beforeEach(() => {
39
- // Mocking console to prevent test output pollution and expect for messages
40
- consoleWarningMock = vi
41
- .spyOn(console, 'warn')
42
- .mockImplementation(() => {}) as MockInstance
43
- consoleErrorMock = vi
44
- .spyOn(console, 'error')
45
- .mockImplementation(() => {}) as MockInstance
46
- })
47
-
48
- afterEach(() => {
49
- consoleWarningMock.mockRestore()
50
- consoleErrorMock.mockRestore()
51
- })
52
-
53
- it('should render', () => {
54
- const { container } = render(
55
- <View>
56
- <h1>View Content</h1>
57
- </View>
58
- )
59
- const view = container.querySelector("span[class$='-view']")
60
-
61
- expect(view).toBeInTheDocument()
62
- expect(view).toHaveTextContent('View Content')
63
- })
64
-
65
- it('should render children', () => {
66
- render(
67
- <View>
68
- <h1>View Content</h1>
69
- </View>
70
- )
71
-
72
- const viewContent = screen.getByText('View Content')
73
-
74
- expect(viewContent).toBeInTheDocument()
75
- expect(viewContent.tagName).toBe('H1')
76
- })
77
-
78
- it('should pass whitelisted style attributes', () => {
79
- const styleProps: CSSProperties = {
80
- top: '160px',
81
- left: '5px',
82
- minWidth: '20px',
83
- minHeight: '208px',
84
- position: 'absolute',
85
- transform: 'translate(30px, 15px)',
86
- overflow: 'hidden',
87
- display: 'block',
88
- pointerEvents: 'none'
89
- }
90
-
91
- const { container } = render(
92
- <View style={{ ...styleProps }}>
93
- <h1>View Content</h1>
94
- </View>
95
- )
96
-
97
- const view = container.querySelector("span[class$='-view']")
98
- const styles = getComputedStyle(view!)
99
-
100
- expect(styles['top']).toEqual('160px')
101
- expect(styles['left']).toEqual('5px')
102
- expect(styles['minWidth']).toEqual('20px')
103
- expect(styles['minHeight']).toEqual('208px')
104
- expect(styles['position']).toEqual('absolute')
105
- expect(styles['transform']).toEqual('translate(30px, 15px)')
106
- expect(styles['overflow']).toEqual('hidden')
107
- expect(styles['display']).toEqual('block')
108
- expect(styles['pointerEvents']).toEqual('none')
109
- })
110
-
111
- it('should pass flex style', () => {
112
- const { container } = render(
113
- <View style={{ flexBasis: '200px' }}>
114
- <h1>View Content</h1>
115
- </View>
116
- )
117
-
118
- const view = container.querySelector("span[class$='-view']")
119
- const styles = getComputedStyle(view!)
120
-
121
- expect(styles['flexBasis']).toEqual('200px')
122
- })
123
-
124
- it('should pass className', () => {
125
- const className = 'fooBarBaz'
126
-
127
- const { container } = render(
128
- <View className={className}>
129
- <h1>View Content</h1>
130
- </View>
131
- )
132
-
133
- const view = container.querySelector("span[class$='-view']")
134
-
135
- expect(view!.classList.contains(className)).toEqual(true)
136
- })
137
-
138
- it('should provide an elementRef', () => {
139
- const elementRef = vi.fn()
140
-
141
- const { container } = render(
142
- <View elementRef={elementRef}>
143
- <h1>View Content</h1>
144
- </View>
145
- )
146
- const view = container.querySelector("span[class$='-view']")
147
-
148
- expect(elementRef).toHaveBeenCalledWith(view)
149
- })
150
-
151
- it('should pass cursor', () => {
152
- const cursor = 'cell'
153
-
154
- const { container } = render(
155
- <View cursor={cursor}>
156
- <h1>View Content</h1>
157
- </View>
158
- )
159
-
160
- const view = container.querySelector("span[class$='-view']")
161
- const styles = getComputedStyle(view!)
162
-
163
- expect(styles['cursor']).toEqual(cursor)
164
- })
165
-
166
- it('should set overflow', () => {
167
- const { container } = render(
168
- <View overflowX="hidden" overflowY="auto">
169
- <h1>View Content</h1>
170
- </View>
171
- )
172
-
173
- const view = container.querySelector("span[class$='-view']")
174
- const styles = getComputedStyle(view!)
175
-
176
- expect(styles.overflowX).toEqual('hidden')
177
- expect(styles.overflowY).toEqual('auto')
178
- })
179
-
180
- it('should set CSS position', () => {
181
- const { container } = render(
182
- <View position="fixed">
183
- <h1>View Content</h1>
184
- </View>
185
- )
186
-
187
- const view = container.querySelector("span[class$='-view']")
188
- const styles = getComputedStyle(view!)
189
-
190
- expect(styles.position).toEqual('fixed')
191
- })
192
-
193
- it('should set inline offset (top, bottom, left, right)', () => {
194
- const { container } = render(
195
- <View
196
- insetBlockStart="0"
197
- insetBlockEnd="20px"
198
- insetInlineStart="2px"
199
- insetInlineEnd="3px"
200
- >
201
- <h1>View Content</h1>
202
- </View>
203
- )
204
-
205
- const view = container.querySelector("span[class$='-view']")
206
- const styles = getComputedStyle(view!)
207
-
208
- expect(styles['top']).toEqual('0px')
209
- expect(styles['bottom']).toEqual('20px')
210
- expect(styles['left']).toEqual('2px')
211
- expect(styles['right']).toEqual('3px')
212
- })
213
-
214
- it('should override default max-width', () => {
215
- const { container, rerender } = render(
216
- <View>
217
- <h1>View Content</h1>
218
- </View>
219
- )
220
-
221
- const view = container.querySelector("span[class$='-view']")
222
- const styles = getComputedStyle(view!)
223
-
224
- expect(styles.maxWidth).toEqual('100%')
225
-
226
- rerender(
227
- <View maxWidth="200px">
228
- <h1>View Content</h1>
229
- </View>
230
- )
231
-
232
- const newStyles = getComputedStyle(view!)
233
-
234
- expect(newStyles.maxWidth).toEqual('200px')
235
- })
236
-
237
- it('should meet a11y standards', async () => {
238
- const { container } = render(<View>View Content</View>)
239
-
240
- const axeCheck = await runAxeCheck(container)
241
-
242
- expect(axeCheck).toBe(true)
243
- })
244
- })
@@ -1,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=ContextView.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContextView.test.d.ts","sourceRoot":"","sources":["../../../src/ContextView/__new-tests__/ContextView.test.tsx"],"names":[],"mappings":"AAyBA,OAAO,2BAA2B,CAAA"}
@@ -1,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=View.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"View.test.d.ts","sourceRoot":"","sources":["../../../src/View/__new-tests__/View.test.tsx"],"names":[],"mappings":"AA4BA,OAAO,2BAA2B,CAAA"}