@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.
- package/CHANGELOG.md +1 -1
- package/package.json +14 -14
- package/tsconfig.build.tsbuildinfo +1 -1
- package/es/ContextView/__new-tests__/ContextView.test.js +0 -44
- package/es/View/__new-tests__/View.test.js +0 -221
- package/lib/ContextView/__new-tests__/ContextView.test.js +0 -45
- package/lib/View/__new-tests__/View.test.js +0 -222
- package/src/ContextView/__new-tests__/ContextView.test.tsx +0 -46
- package/src/View/__new-tests__/View.test.tsx +0 -244
- package/types/ContextView/__new-tests__/ContextView.test.d.ts +0 -2
- package/types/ContextView/__new-tests__/ContextView.test.d.ts.map +0 -1
- package/types/View/__new-tests__/View.test.d.ts +0 -2
- package/types/View/__new-tests__/View.test.d.ts.map +0 -1
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
var _ContextView, _ContextView2;
|
|
2
|
-
/*
|
|
3
|
-
* The MIT License (MIT)
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
import { render } from '@testing-library/react';
|
|
27
|
-
import '@testing-library/jest-dom';
|
|
28
|
-
import { ContextView } from '../index';
|
|
29
|
-
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
30
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
31
|
-
describe('<ContextView />', () => {
|
|
32
|
-
it('should render', () => {
|
|
33
|
-
const _render = render(_ContextView || (_ContextView = _jsx(ContextView, {}))),
|
|
34
|
-
container = _render.container;
|
|
35
|
-
const contextView = container.querySelector("span[class$='-contextView']");
|
|
36
|
-
expect(contextView).toBeInTheDocument();
|
|
37
|
-
});
|
|
38
|
-
it('should meet a11y standards', async () => {
|
|
39
|
-
const _render2 = render(_ContextView2 || (_ContextView2 = _jsx(ContextView, {}))),
|
|
40
|
-
container = _render2.container;
|
|
41
|
-
const axeCheck = await runAxeCheck(container);
|
|
42
|
-
expect(axeCheck).toBe(true);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
var _View, _View2, _h, _h2, _h3, _h4, _h5, _View3, _View4, _View5, _View6, _View7, _View8;
|
|
2
|
-
/*
|
|
3
|
-
* The MIT License (MIT)
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
import { render, screen } from '@testing-library/react';
|
|
27
|
-
import { vi } from 'vitest';
|
|
28
|
-
import '@testing-library/jest-dom';
|
|
29
|
-
import { View } from '../../index';
|
|
30
|
-
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
31
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
32
|
-
describe('<View />', () => {
|
|
33
|
-
let consoleWarningMock;
|
|
34
|
-
let consoleErrorMock;
|
|
35
|
-
beforeEach(() => {
|
|
36
|
-
// Mocking console to prevent test output pollution and expect for messages
|
|
37
|
-
consoleWarningMock = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
38
|
-
consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
39
|
-
});
|
|
40
|
-
afterEach(() => {
|
|
41
|
-
consoleWarningMock.mockRestore();
|
|
42
|
-
consoleErrorMock.mockRestore();
|
|
43
|
-
});
|
|
44
|
-
it('should render', () => {
|
|
45
|
-
const _render = render(_View || (_View = _jsx(View, {
|
|
46
|
-
children: _jsx("h1", {
|
|
47
|
-
children: "View Content"
|
|
48
|
-
})
|
|
49
|
-
}))),
|
|
50
|
-
container = _render.container;
|
|
51
|
-
const view = container.querySelector("span[class$='-view']");
|
|
52
|
-
expect(view).toBeInTheDocument();
|
|
53
|
-
expect(view).toHaveTextContent('View Content');
|
|
54
|
-
});
|
|
55
|
-
it('should render children', () => {
|
|
56
|
-
render(_View2 || (_View2 = _jsx(View, {
|
|
57
|
-
children: _jsx("h1", {
|
|
58
|
-
children: "View Content"
|
|
59
|
-
})
|
|
60
|
-
})));
|
|
61
|
-
const viewContent = screen.getByText('View Content');
|
|
62
|
-
expect(viewContent).toBeInTheDocument();
|
|
63
|
-
expect(viewContent.tagName).toBe('H1');
|
|
64
|
-
});
|
|
65
|
-
it('should pass whitelisted style attributes', () => {
|
|
66
|
-
const styleProps = {
|
|
67
|
-
top: '160px',
|
|
68
|
-
left: '5px',
|
|
69
|
-
minWidth: '20px',
|
|
70
|
-
minHeight: '208px',
|
|
71
|
-
position: 'absolute',
|
|
72
|
-
transform: 'translate(30px, 15px)',
|
|
73
|
-
overflow: 'hidden',
|
|
74
|
-
display: 'block',
|
|
75
|
-
pointerEvents: 'none'
|
|
76
|
-
};
|
|
77
|
-
const _render2 = render(_jsx(View, {
|
|
78
|
-
style: {
|
|
79
|
-
...styleProps
|
|
80
|
-
},
|
|
81
|
-
children: _h || (_h = _jsx("h1", {
|
|
82
|
-
children: "View Content"
|
|
83
|
-
}))
|
|
84
|
-
})),
|
|
85
|
-
container = _render2.container;
|
|
86
|
-
const view = container.querySelector("span[class$='-view']");
|
|
87
|
-
const styles = getComputedStyle(view);
|
|
88
|
-
expect(styles['top']).toEqual('160px');
|
|
89
|
-
expect(styles['left']).toEqual('5px');
|
|
90
|
-
expect(styles['minWidth']).toEqual('20px');
|
|
91
|
-
expect(styles['minHeight']).toEqual('208px');
|
|
92
|
-
expect(styles['position']).toEqual('absolute');
|
|
93
|
-
expect(styles['transform']).toEqual('translate(30px, 15px)');
|
|
94
|
-
expect(styles['overflow']).toEqual('hidden');
|
|
95
|
-
expect(styles['display']).toEqual('block');
|
|
96
|
-
expect(styles['pointerEvents']).toEqual('none');
|
|
97
|
-
});
|
|
98
|
-
it('should pass flex style', () => {
|
|
99
|
-
const _render3 = render(_jsx(View, {
|
|
100
|
-
style: {
|
|
101
|
-
flexBasis: '200px'
|
|
102
|
-
},
|
|
103
|
-
children: _h2 || (_h2 = _jsx("h1", {
|
|
104
|
-
children: "View Content"
|
|
105
|
-
}))
|
|
106
|
-
})),
|
|
107
|
-
container = _render3.container;
|
|
108
|
-
const view = container.querySelector("span[class$='-view']");
|
|
109
|
-
const styles = getComputedStyle(view);
|
|
110
|
-
expect(styles['flexBasis']).toEqual('200px');
|
|
111
|
-
});
|
|
112
|
-
it('should pass className', () => {
|
|
113
|
-
const className = 'fooBarBaz';
|
|
114
|
-
const _render4 = render(_jsx(View, {
|
|
115
|
-
className: className,
|
|
116
|
-
children: _h3 || (_h3 = _jsx("h1", {
|
|
117
|
-
children: "View Content"
|
|
118
|
-
}))
|
|
119
|
-
})),
|
|
120
|
-
container = _render4.container;
|
|
121
|
-
const view = container.querySelector("span[class$='-view']");
|
|
122
|
-
expect(view.classList.contains(className)).toEqual(true);
|
|
123
|
-
});
|
|
124
|
-
it('should provide an elementRef', () => {
|
|
125
|
-
const elementRef = vi.fn();
|
|
126
|
-
const _render5 = render(_jsx(View, {
|
|
127
|
-
elementRef: elementRef,
|
|
128
|
-
children: _h4 || (_h4 = _jsx("h1", {
|
|
129
|
-
children: "View Content"
|
|
130
|
-
}))
|
|
131
|
-
})),
|
|
132
|
-
container = _render5.container;
|
|
133
|
-
const view = container.querySelector("span[class$='-view']");
|
|
134
|
-
expect(elementRef).toHaveBeenCalledWith(view);
|
|
135
|
-
});
|
|
136
|
-
it('should pass cursor', () => {
|
|
137
|
-
const cursor = 'cell';
|
|
138
|
-
const _render6 = render(_jsx(View, {
|
|
139
|
-
cursor: cursor,
|
|
140
|
-
children: _h5 || (_h5 = _jsx("h1", {
|
|
141
|
-
children: "View Content"
|
|
142
|
-
}))
|
|
143
|
-
})),
|
|
144
|
-
container = _render6.container;
|
|
145
|
-
const view = container.querySelector("span[class$='-view']");
|
|
146
|
-
const styles = getComputedStyle(view);
|
|
147
|
-
expect(styles['cursor']).toEqual(cursor);
|
|
148
|
-
});
|
|
149
|
-
it('should set overflow', () => {
|
|
150
|
-
const _render7 = render(_View3 || (_View3 = _jsx(View, {
|
|
151
|
-
overflowX: "hidden",
|
|
152
|
-
overflowY: "auto",
|
|
153
|
-
children: _jsx("h1", {
|
|
154
|
-
children: "View Content"
|
|
155
|
-
})
|
|
156
|
-
}))),
|
|
157
|
-
container = _render7.container;
|
|
158
|
-
const view = container.querySelector("span[class$='-view']");
|
|
159
|
-
const styles = getComputedStyle(view);
|
|
160
|
-
expect(styles.overflowX).toEqual('hidden');
|
|
161
|
-
expect(styles.overflowY).toEqual('auto');
|
|
162
|
-
});
|
|
163
|
-
it('should set CSS position', () => {
|
|
164
|
-
const _render8 = render(_View4 || (_View4 = _jsx(View, {
|
|
165
|
-
position: "fixed",
|
|
166
|
-
children: _jsx("h1", {
|
|
167
|
-
children: "View Content"
|
|
168
|
-
})
|
|
169
|
-
}))),
|
|
170
|
-
container = _render8.container;
|
|
171
|
-
const view = container.querySelector("span[class$='-view']");
|
|
172
|
-
const styles = getComputedStyle(view);
|
|
173
|
-
expect(styles.position).toEqual('fixed');
|
|
174
|
-
});
|
|
175
|
-
it('should set inline offset (top, bottom, left, right)', () => {
|
|
176
|
-
const _render9 = render(_View5 || (_View5 = _jsx(View, {
|
|
177
|
-
insetBlockStart: "0",
|
|
178
|
-
insetBlockEnd: "20px",
|
|
179
|
-
insetInlineStart: "2px",
|
|
180
|
-
insetInlineEnd: "3px",
|
|
181
|
-
children: _jsx("h1", {
|
|
182
|
-
children: "View Content"
|
|
183
|
-
})
|
|
184
|
-
}))),
|
|
185
|
-
container = _render9.container;
|
|
186
|
-
const view = container.querySelector("span[class$='-view']");
|
|
187
|
-
const styles = getComputedStyle(view);
|
|
188
|
-
expect(styles['top']).toEqual('0px');
|
|
189
|
-
expect(styles['bottom']).toEqual('20px');
|
|
190
|
-
expect(styles['left']).toEqual('2px');
|
|
191
|
-
expect(styles['right']).toEqual('3px');
|
|
192
|
-
});
|
|
193
|
-
it('should override default max-width', () => {
|
|
194
|
-
const _render10 = render(_View6 || (_View6 = _jsx(View, {
|
|
195
|
-
children: _jsx("h1", {
|
|
196
|
-
children: "View Content"
|
|
197
|
-
})
|
|
198
|
-
}))),
|
|
199
|
-
container = _render10.container,
|
|
200
|
-
rerender = _render10.rerender;
|
|
201
|
-
const view = container.querySelector("span[class$='-view']");
|
|
202
|
-
const styles = getComputedStyle(view);
|
|
203
|
-
expect(styles.maxWidth).toEqual('100%');
|
|
204
|
-
rerender(_View7 || (_View7 = _jsx(View, {
|
|
205
|
-
maxWidth: "200px",
|
|
206
|
-
children: _jsx("h1", {
|
|
207
|
-
children: "View Content"
|
|
208
|
-
})
|
|
209
|
-
})));
|
|
210
|
-
const newStyles = getComputedStyle(view);
|
|
211
|
-
expect(newStyles.maxWidth).toEqual('200px');
|
|
212
|
-
});
|
|
213
|
-
it('should meet a11y standards', async () => {
|
|
214
|
-
const _render11 = render(_View8 || (_View8 = _jsx(View, {
|
|
215
|
-
children: "View Content"
|
|
216
|
-
}))),
|
|
217
|
-
container = _render11.container;
|
|
218
|
-
const axeCheck = await runAxeCheck(container);
|
|
219
|
-
expect(axeCheck).toBe(true);
|
|
220
|
-
});
|
|
221
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@testing-library/react");
|
|
4
|
-
require("@testing-library/jest-dom");
|
|
5
|
-
var _index = require("../index");
|
|
6
|
-
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
7
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
8
|
-
var _ContextView, _ContextView2;
|
|
9
|
-
/*
|
|
10
|
-
* The MIT License (MIT)
|
|
11
|
-
*
|
|
12
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
13
|
-
*
|
|
14
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
* in the Software without restriction, including without limitation the rights
|
|
17
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
19
|
-
* furnished to do so, subject to the following conditions:
|
|
20
|
-
*
|
|
21
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
22
|
-
* copies or substantial portions of the Software.
|
|
23
|
-
*
|
|
24
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
-
* SOFTWARE.
|
|
31
|
-
*/
|
|
32
|
-
describe('<ContextView />', () => {
|
|
33
|
-
it('should render', () => {
|
|
34
|
-
const _render = (0, _react.render)(_ContextView || (_ContextView = (0, _jsxRuntime.jsx)(_index.ContextView, {}))),
|
|
35
|
-
container = _render.container;
|
|
36
|
-
const contextView = container.querySelector("span[class$='-contextView']");
|
|
37
|
-
expect(contextView).toBeInTheDocument();
|
|
38
|
-
});
|
|
39
|
-
it('should meet a11y standards', async () => {
|
|
40
|
-
const _render2 = (0, _react.render)(_ContextView2 || (_ContextView2 = (0, _jsxRuntime.jsx)(_index.ContextView, {}))),
|
|
41
|
-
container = _render2.container;
|
|
42
|
-
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
43
|
-
expect(axeCheck).toBe(true);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@testing-library/react");
|
|
4
|
-
var _vitest = require("vitest");
|
|
5
|
-
require("@testing-library/jest-dom");
|
|
6
|
-
var _index = require("../../index");
|
|
7
|
-
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
8
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
9
|
-
var _View, _View2, _h, _h2, _h3, _h4, _h5, _View3, _View4, _View5, _View6, _View7, _View8;
|
|
10
|
-
/*
|
|
11
|
-
* The MIT License (MIT)
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
14
|
-
*
|
|
15
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
17
|
-
* in the Software without restriction, including without limitation the rights
|
|
18
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
20
|
-
* furnished to do so, subject to the following conditions:
|
|
21
|
-
*
|
|
22
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
23
|
-
* copies or substantial portions of the Software.
|
|
24
|
-
*
|
|
25
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
-
* SOFTWARE.
|
|
32
|
-
*/
|
|
33
|
-
describe('<View />', () => {
|
|
34
|
-
let consoleWarningMock;
|
|
35
|
-
let consoleErrorMock;
|
|
36
|
-
beforeEach(() => {
|
|
37
|
-
// Mocking console to prevent test output pollution and expect for messages
|
|
38
|
-
consoleWarningMock = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
39
|
-
consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
40
|
-
});
|
|
41
|
-
afterEach(() => {
|
|
42
|
-
consoleWarningMock.mockRestore();
|
|
43
|
-
consoleErrorMock.mockRestore();
|
|
44
|
-
});
|
|
45
|
-
it('should render', () => {
|
|
46
|
-
const _render = (0, _react.render)(_View || (_View = (0, _jsxRuntime.jsx)(_index.View, {
|
|
47
|
-
children: (0, _jsxRuntime.jsx)("h1", {
|
|
48
|
-
children: "View Content"
|
|
49
|
-
})
|
|
50
|
-
}))),
|
|
51
|
-
container = _render.container;
|
|
52
|
-
const view = container.querySelector("span[class$='-view']");
|
|
53
|
-
expect(view).toBeInTheDocument();
|
|
54
|
-
expect(view).toHaveTextContent('View Content');
|
|
55
|
-
});
|
|
56
|
-
it('should render children', () => {
|
|
57
|
-
(0, _react.render)(_View2 || (_View2 = (0, _jsxRuntime.jsx)(_index.View, {
|
|
58
|
-
children: (0, _jsxRuntime.jsx)("h1", {
|
|
59
|
-
children: "View Content"
|
|
60
|
-
})
|
|
61
|
-
})));
|
|
62
|
-
const viewContent = _react.screen.getByText('View Content');
|
|
63
|
-
expect(viewContent).toBeInTheDocument();
|
|
64
|
-
expect(viewContent.tagName).toBe('H1');
|
|
65
|
-
});
|
|
66
|
-
it('should pass whitelisted style attributes', () => {
|
|
67
|
-
const styleProps = {
|
|
68
|
-
top: '160px',
|
|
69
|
-
left: '5px',
|
|
70
|
-
minWidth: '20px',
|
|
71
|
-
minHeight: '208px',
|
|
72
|
-
position: 'absolute',
|
|
73
|
-
transform: 'translate(30px, 15px)',
|
|
74
|
-
overflow: 'hidden',
|
|
75
|
-
display: 'block',
|
|
76
|
-
pointerEvents: 'none'
|
|
77
|
-
};
|
|
78
|
-
const _render2 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.View, {
|
|
79
|
-
style: {
|
|
80
|
-
...styleProps
|
|
81
|
-
},
|
|
82
|
-
children: _h || (_h = (0, _jsxRuntime.jsx)("h1", {
|
|
83
|
-
children: "View Content"
|
|
84
|
-
}))
|
|
85
|
-
})),
|
|
86
|
-
container = _render2.container;
|
|
87
|
-
const view = container.querySelector("span[class$='-view']");
|
|
88
|
-
const styles = getComputedStyle(view);
|
|
89
|
-
expect(styles['top']).toEqual('160px');
|
|
90
|
-
expect(styles['left']).toEqual('5px');
|
|
91
|
-
expect(styles['minWidth']).toEqual('20px');
|
|
92
|
-
expect(styles['minHeight']).toEqual('208px');
|
|
93
|
-
expect(styles['position']).toEqual('absolute');
|
|
94
|
-
expect(styles['transform']).toEqual('translate(30px, 15px)');
|
|
95
|
-
expect(styles['overflow']).toEqual('hidden');
|
|
96
|
-
expect(styles['display']).toEqual('block');
|
|
97
|
-
expect(styles['pointerEvents']).toEqual('none');
|
|
98
|
-
});
|
|
99
|
-
it('should pass flex style', () => {
|
|
100
|
-
const _render3 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.View, {
|
|
101
|
-
style: {
|
|
102
|
-
flexBasis: '200px'
|
|
103
|
-
},
|
|
104
|
-
children: _h2 || (_h2 = (0, _jsxRuntime.jsx)("h1", {
|
|
105
|
-
children: "View Content"
|
|
106
|
-
}))
|
|
107
|
-
})),
|
|
108
|
-
container = _render3.container;
|
|
109
|
-
const view = container.querySelector("span[class$='-view']");
|
|
110
|
-
const styles = getComputedStyle(view);
|
|
111
|
-
expect(styles['flexBasis']).toEqual('200px');
|
|
112
|
-
});
|
|
113
|
-
it('should pass className', () => {
|
|
114
|
-
const className = 'fooBarBaz';
|
|
115
|
-
const _render4 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.View, {
|
|
116
|
-
className: className,
|
|
117
|
-
children: _h3 || (_h3 = (0, _jsxRuntime.jsx)("h1", {
|
|
118
|
-
children: "View Content"
|
|
119
|
-
}))
|
|
120
|
-
})),
|
|
121
|
-
container = _render4.container;
|
|
122
|
-
const view = container.querySelector("span[class$='-view']");
|
|
123
|
-
expect(view.classList.contains(className)).toEqual(true);
|
|
124
|
-
});
|
|
125
|
-
it('should provide an elementRef', () => {
|
|
126
|
-
const elementRef = _vitest.vi.fn();
|
|
127
|
-
const _render5 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.View, {
|
|
128
|
-
elementRef: elementRef,
|
|
129
|
-
children: _h4 || (_h4 = (0, _jsxRuntime.jsx)("h1", {
|
|
130
|
-
children: "View Content"
|
|
131
|
-
}))
|
|
132
|
-
})),
|
|
133
|
-
container = _render5.container;
|
|
134
|
-
const view = container.querySelector("span[class$='-view']");
|
|
135
|
-
expect(elementRef).toHaveBeenCalledWith(view);
|
|
136
|
-
});
|
|
137
|
-
it('should pass cursor', () => {
|
|
138
|
-
const cursor = 'cell';
|
|
139
|
-
const _render6 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.View, {
|
|
140
|
-
cursor: cursor,
|
|
141
|
-
children: _h5 || (_h5 = (0, _jsxRuntime.jsx)("h1", {
|
|
142
|
-
children: "View Content"
|
|
143
|
-
}))
|
|
144
|
-
})),
|
|
145
|
-
container = _render6.container;
|
|
146
|
-
const view = container.querySelector("span[class$='-view']");
|
|
147
|
-
const styles = getComputedStyle(view);
|
|
148
|
-
expect(styles['cursor']).toEqual(cursor);
|
|
149
|
-
});
|
|
150
|
-
it('should set overflow', () => {
|
|
151
|
-
const _render7 = (0, _react.render)(_View3 || (_View3 = (0, _jsxRuntime.jsx)(_index.View, {
|
|
152
|
-
overflowX: "hidden",
|
|
153
|
-
overflowY: "auto",
|
|
154
|
-
children: (0, _jsxRuntime.jsx)("h1", {
|
|
155
|
-
children: "View Content"
|
|
156
|
-
})
|
|
157
|
-
}))),
|
|
158
|
-
container = _render7.container;
|
|
159
|
-
const view = container.querySelector("span[class$='-view']");
|
|
160
|
-
const styles = getComputedStyle(view);
|
|
161
|
-
expect(styles.overflowX).toEqual('hidden');
|
|
162
|
-
expect(styles.overflowY).toEqual('auto');
|
|
163
|
-
});
|
|
164
|
-
it('should set CSS position', () => {
|
|
165
|
-
const _render8 = (0, _react.render)(_View4 || (_View4 = (0, _jsxRuntime.jsx)(_index.View, {
|
|
166
|
-
position: "fixed",
|
|
167
|
-
children: (0, _jsxRuntime.jsx)("h1", {
|
|
168
|
-
children: "View Content"
|
|
169
|
-
})
|
|
170
|
-
}))),
|
|
171
|
-
container = _render8.container;
|
|
172
|
-
const view = container.querySelector("span[class$='-view']");
|
|
173
|
-
const styles = getComputedStyle(view);
|
|
174
|
-
expect(styles.position).toEqual('fixed');
|
|
175
|
-
});
|
|
176
|
-
it('should set inline offset (top, bottom, left, right)', () => {
|
|
177
|
-
const _render9 = (0, _react.render)(_View5 || (_View5 = (0, _jsxRuntime.jsx)(_index.View, {
|
|
178
|
-
insetBlockStart: "0",
|
|
179
|
-
insetBlockEnd: "20px",
|
|
180
|
-
insetInlineStart: "2px",
|
|
181
|
-
insetInlineEnd: "3px",
|
|
182
|
-
children: (0, _jsxRuntime.jsx)("h1", {
|
|
183
|
-
children: "View Content"
|
|
184
|
-
})
|
|
185
|
-
}))),
|
|
186
|
-
container = _render9.container;
|
|
187
|
-
const view = container.querySelector("span[class$='-view']");
|
|
188
|
-
const styles = getComputedStyle(view);
|
|
189
|
-
expect(styles['top']).toEqual('0px');
|
|
190
|
-
expect(styles['bottom']).toEqual('20px');
|
|
191
|
-
expect(styles['left']).toEqual('2px');
|
|
192
|
-
expect(styles['right']).toEqual('3px');
|
|
193
|
-
});
|
|
194
|
-
it('should override default max-width', () => {
|
|
195
|
-
const _render10 = (0, _react.render)(_View6 || (_View6 = (0, _jsxRuntime.jsx)(_index.View, {
|
|
196
|
-
children: (0, _jsxRuntime.jsx)("h1", {
|
|
197
|
-
children: "View Content"
|
|
198
|
-
})
|
|
199
|
-
}))),
|
|
200
|
-
container = _render10.container,
|
|
201
|
-
rerender = _render10.rerender;
|
|
202
|
-
const view = container.querySelector("span[class$='-view']");
|
|
203
|
-
const styles = getComputedStyle(view);
|
|
204
|
-
expect(styles.maxWidth).toEqual('100%');
|
|
205
|
-
rerender(_View7 || (_View7 = (0, _jsxRuntime.jsx)(_index.View, {
|
|
206
|
-
maxWidth: "200px",
|
|
207
|
-
children: (0, _jsxRuntime.jsx)("h1", {
|
|
208
|
-
children: "View Content"
|
|
209
|
-
})
|
|
210
|
-
})));
|
|
211
|
-
const newStyles = getComputedStyle(view);
|
|
212
|
-
expect(newStyles.maxWidth).toEqual('200px');
|
|
213
|
-
});
|
|
214
|
-
it('should meet a11y standards', async () => {
|
|
215
|
-
const _render11 = (0, _react.render)(_View8 || (_View8 = (0, _jsxRuntime.jsx)(_index.View, {
|
|
216
|
-
children: "View Content"
|
|
217
|
-
}))),
|
|
218
|
-
container = _render11.container;
|
|
219
|
-
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
220
|
-
expect(axeCheck).toBe(true);
|
|
221
|
-
});
|
|
222
|
-
});
|
|
@@ -1,46 +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 } from '@testing-library/react'
|
|
26
|
-
import '@testing-library/jest-dom'
|
|
27
|
-
|
|
28
|
-
import { ContextView } from '../index'
|
|
29
|
-
import { runAxeCheck } from '@instructure/ui-axe-check'
|
|
30
|
-
|
|
31
|
-
describe('<ContextView />', () => {
|
|
32
|
-
it('should render', () => {
|
|
33
|
-
const { container } = render(<ContextView />)
|
|
34
|
-
|
|
35
|
-
const contextView = container.querySelector("span[class$='-contextView']")
|
|
36
|
-
expect(contextView).toBeInTheDocument()
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('should meet a11y standards', async () => {
|
|
40
|
-
const { container } = render(<ContextView />)
|
|
41
|
-
|
|
42
|
-
const axeCheck = await runAxeCheck(container)
|
|
43
|
-
|
|
44
|
-
expect(axeCheck).toBe(true)
|
|
45
|
-
})
|
|
46
|
-
})
|