@instructure/ui-view 8.53.3-snapshot-20 → 8.53.3-snapshot-23

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [8.53.3-snapshot-20](https://github.com/instructure/instructure-ui/compare/v8.53.2...v8.53.3-snapshot-20) (2024-03-20)
6
+ ## [8.53.3-snapshot-23](https://github.com/instructure/instructure-ui/compare/v8.53.2...v8.53.3-snapshot-23) (2024-03-20)
7
7
 
8
8
  **Note:** Version bump only for package @instructure/ui-view
9
9
 
@@ -0,0 +1,44 @@
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 React from 'react';
27
+ import { render } from '@testing-library/react';
28
+ import '@testing-library/jest-dom';
29
+ import { ContextView } from '../index';
30
+ import { runAxeCheck } from '@instructure/ui-axe-check';
31
+ describe('<ContextView />', () => {
32
+ it('should render', () => {
33
+ const _render = render(_ContextView || (_ContextView = /*#__PURE__*/React.createElement(ContextView, null))),
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 = /*#__PURE__*/React.createElement(ContextView, null))),
40
+ container = _render2.container;
41
+ const axeCheck = await runAxeCheck(container);
42
+ expect(axeCheck).toBe(true);
43
+ });
44
+ });
@@ -0,0 +1,190 @@
1
+ var _View, _View2, _h, _h2, _h3, _h4, _h5, _View3, _View4, _View5, _View6, _View7, _View8, _View9, _View10;
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 React from 'react';
27
+ import { render, screen } from '@testing-library/react';
28
+ import '@testing-library/jest-dom';
29
+ import { View } from '../../index';
30
+ import { runAxeCheck } from '@instructure/ui-axe-check';
31
+ describe('<View />', () => {
32
+ it('should render', () => {
33
+ const _render = render(_View || (_View = /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement("h1", null, "View Content")))),
34
+ container = _render.container;
35
+ const view = container.querySelector("span[class$='-view']");
36
+ expect(view).toBeInTheDocument();
37
+ expect(view).toHaveTextContent('View Content');
38
+ });
39
+ it('should render children', () => {
40
+ render(_View2 || (_View2 = /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement("h1", null, "View Content"))));
41
+ const viewContent = screen.getByText('View Content');
42
+ expect(viewContent).toBeInTheDocument();
43
+ expect(viewContent.tagName).toBe('H1');
44
+ });
45
+ it('should pass whitelisted style attributes', () => {
46
+ const styleProps = {
47
+ top: '160px',
48
+ left: '5px',
49
+ minWidth: '20px',
50
+ minHeight: '208px',
51
+ position: 'absolute',
52
+ transform: 'translate(30px, 15px)',
53
+ overflow: 'hidden',
54
+ display: 'block',
55
+ pointerEvents: 'none'
56
+ };
57
+ const _render2 = render( /*#__PURE__*/React.createElement(View, {
58
+ style: {
59
+ ...styleProps
60
+ }
61
+ }, _h || (_h = /*#__PURE__*/React.createElement("h1", null, "View Content")))),
62
+ container = _render2.container;
63
+ const view = container.querySelector("span[class$='-view']");
64
+ const styles = getComputedStyle(view);
65
+ expect(styles['top']).toEqual('160px');
66
+ expect(styles['left']).toEqual('5px');
67
+ expect(styles['minWidth']).toEqual('20px');
68
+ expect(styles['minHeight']).toEqual('208px');
69
+ expect(styles['position']).toEqual('absolute');
70
+ expect(styles['transform']).toEqual('translate(30px, 15px)');
71
+ expect(styles['overflow']).toEqual('hidden');
72
+ expect(styles['display']).toEqual('block');
73
+ expect(styles['pointerEvents']).toEqual('none');
74
+ });
75
+ it('should pass flex style', () => {
76
+ const _render3 = render( /*#__PURE__*/React.createElement(View, {
77
+ style: {
78
+ flexBasis: '200px'
79
+ }
80
+ }, _h2 || (_h2 = /*#__PURE__*/React.createElement("h1", null, "View Content")))),
81
+ container = _render3.container;
82
+ const view = container.querySelector("span[class$='-view']");
83
+ const styles = getComputedStyle(view);
84
+ expect(styles['flexBasis']).toEqual('200px');
85
+ });
86
+ it('should pass className', () => {
87
+ const className = 'fooBarBaz';
88
+ const _render4 = render( /*#__PURE__*/React.createElement(View, {
89
+ className: className
90
+ }, _h3 || (_h3 = /*#__PURE__*/React.createElement("h1", null, "View Content")))),
91
+ container = _render4.container;
92
+ const view = container.querySelector("span[class$='-view']");
93
+ expect(view.classList.contains(className));
94
+ });
95
+ it('should provide an elementRef', () => {
96
+ const elementRef = jest.fn();
97
+ const _render5 = render( /*#__PURE__*/React.createElement(View, {
98
+ elementRef: elementRef
99
+ }, _h4 || (_h4 = /*#__PURE__*/React.createElement("h1", null, "View Content")))),
100
+ container = _render5.container;
101
+ const view = container.querySelector("span[class$='-view']");
102
+ expect(elementRef).toHaveBeenCalledWith(view);
103
+ });
104
+ it('should pass cursor', () => {
105
+ const cursor = 'cell';
106
+ const _render6 = render( /*#__PURE__*/React.createElement(View, {
107
+ cursor: cursor
108
+ }, _h5 || (_h5 = /*#__PURE__*/React.createElement("h1", null, "View Content")))),
109
+ container = _render6.container;
110
+ const view = container.querySelector("span[class$='-view']");
111
+ const styles = getComputedStyle(view);
112
+ expect(styles['cursor']).toEqual(cursor);
113
+ });
114
+ it('should set overflow', () => {
115
+ const _render7 = render(_View3 || (_View3 = /*#__PURE__*/React.createElement(View, {
116
+ overflowX: "hidden",
117
+ overflowY: "auto"
118
+ }, /*#__PURE__*/React.createElement("h1", null, "View Content")))),
119
+ container = _render7.container;
120
+ const view = container.querySelector("span[class$='-view']");
121
+ const styles = getComputedStyle(view);
122
+ expect(styles.overflowX).toEqual('hidden');
123
+ expect(styles.overflowY).toEqual('auto');
124
+ });
125
+ it('should set CSS position', () => {
126
+ const _render8 = render(_View4 || (_View4 = /*#__PURE__*/React.createElement(View, {
127
+ position: "fixed"
128
+ }, /*#__PURE__*/React.createElement("h1", null, "View Content")))),
129
+ container = _render8.container;
130
+ const view = container.querySelector("span[class$='-view']");
131
+ const styles = getComputedStyle(view);
132
+ expect(styles.position).toEqual('fixed');
133
+ });
134
+ it('should set inline offset (top, bottom, left, right)', () => {
135
+ const _render9 = render(_View5 || (_View5 = /*#__PURE__*/React.createElement(View, {
136
+ insetBlockStart: "0",
137
+ insetBlockEnd: "20px",
138
+ insetInlineStart: "2px",
139
+ insetInlineEnd: "3px"
140
+ }, /*#__PURE__*/React.createElement("h1", null, "View Content")))),
141
+ container = _render9.container;
142
+ const view = container.querySelector("span[class$='-view']");
143
+ const styles = getComputedStyle(view);
144
+ expect(styles['top']).toEqual('0px');
145
+ expect(styles['bottom']).toEqual('20px');
146
+ expect(styles['left']).toEqual('2px');
147
+ expect(styles['right']).toEqual('3px');
148
+ });
149
+ it('should override default max-width', () => {
150
+ const _render10 = render(_View6 || (_View6 = /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement("h1", null, "View Content")))),
151
+ container = _render10.container,
152
+ rerender = _render10.rerender;
153
+ const view = container.querySelector("span[class$='-view']");
154
+ const styles = getComputedStyle(view);
155
+ expect(styles.maxWidth).toEqual('100%');
156
+ rerender(_View7 || (_View7 = /*#__PURE__*/React.createElement(View, {
157
+ maxWidth: "200px"
158
+ }, /*#__PURE__*/React.createElement("h1", null, "View Content"))));
159
+ const newStyles = getComputedStyle(view);
160
+ expect(newStyles.maxWidth).toEqual('200px');
161
+ });
162
+ describe('withFocusOutline', () => {
163
+ it('should warn when withFocusOutline is true without position=relative', () => {
164
+ const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
165
+ render(_View8 || (_View8 = /*#__PURE__*/React.createElement(View, {
166
+ withFocusOutline: true
167
+ }, /*#__PURE__*/React.createElement("h1", null, "View Content"))));
168
+ const expectedErrorMessage = 'Warning: [View] the focus outline will only show if the `position` prop is `relative`.';
169
+ expect(consoleErrorSpy).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
170
+ consoleErrorSpy.mockRestore();
171
+ });
172
+ it('should warn when withFocusOutline is `true`, display is set to `inline`, and focusPosition is set to `offset`', () => {
173
+ const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
174
+ render(_View9 || (_View9 = /*#__PURE__*/React.createElement(View, {
175
+ withFocusOutline: true,
176
+ display: "inline",
177
+ focusPosition: "offset"
178
+ }, /*#__PURE__*/React.createElement("h1", null, "View Content"))));
179
+ const expectedErrorMessage = 'Warning: [View] when display is set to `inline` the focus outline will only show if `focusPosition` is set to `inset`.';
180
+ expect(consoleErrorSpy).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
181
+ consoleErrorSpy.mockRestore();
182
+ });
183
+ });
184
+ it('should meet a11y standards', async () => {
185
+ const _render11 = render(_View10 || (_View10 = /*#__PURE__*/React.createElement(View, null, "View Content"))),
186
+ container = _render11.container;
187
+ const axeCheck = await runAxeCheck(container);
188
+ expect(axeCheck).toBe(true);
189
+ });
190
+ });
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _react = _interopRequireDefault(require("react"));
5
+ var _react2 = require("@testing-library/react");
6
+ require("@testing-library/jest-dom");
7
+ var _index = require("../index");
8
+ var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
9
+ var _ContextView, _ContextView2;
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('<ContextView />', () => {
34
+ it('should render', () => {
35
+ const _render = (0, _react2.render)(_ContextView || (_ContextView = /*#__PURE__*/_react.default.createElement(_index.ContextView, null))),
36
+ container = _render.container;
37
+ const contextView = container.querySelector("span[class$='-contextView']");
38
+ expect(contextView).toBeInTheDocument();
39
+ });
40
+ it('should meet a11y standards', async () => {
41
+ const _render2 = (0, _react2.render)(_ContextView2 || (_ContextView2 = /*#__PURE__*/_react.default.createElement(_index.ContextView, null))),
42
+ container = _render2.container;
43
+ const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
44
+ expect(axeCheck).toBe(true);
45
+ });
46
+ });
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _react = _interopRequireDefault(require("react"));
5
+ var _react2 = require("@testing-library/react");
6
+ require("@testing-library/jest-dom");
7
+ var _index = require("../../index");
8
+ var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
9
+ var _View, _View2, _h, _h2, _h3, _h4, _h5, _View3, _View4, _View5, _View6, _View7, _View8, _View9, _View10;
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
+ it('should render', () => {
35
+ const _render = (0, _react2.render)(_View || (_View = /*#__PURE__*/_react.default.createElement(_index.View, null, /*#__PURE__*/_react.default.createElement("h1", null, "View Content")))),
36
+ container = _render.container;
37
+ const view = container.querySelector("span[class$='-view']");
38
+ expect(view).toBeInTheDocument();
39
+ expect(view).toHaveTextContent('View Content');
40
+ });
41
+ it('should render children', () => {
42
+ (0, _react2.render)(_View2 || (_View2 = /*#__PURE__*/_react.default.createElement(_index.View, null, /*#__PURE__*/_react.default.createElement("h1", null, "View Content"))));
43
+ const viewContent = _react2.screen.getByText('View Content');
44
+ expect(viewContent).toBeInTheDocument();
45
+ expect(viewContent.tagName).toBe('H1');
46
+ });
47
+ it('should pass whitelisted style attributes', () => {
48
+ const styleProps = {
49
+ top: '160px',
50
+ left: '5px',
51
+ minWidth: '20px',
52
+ minHeight: '208px',
53
+ position: 'absolute',
54
+ transform: 'translate(30px, 15px)',
55
+ overflow: 'hidden',
56
+ display: 'block',
57
+ pointerEvents: 'none'
58
+ };
59
+ const _render2 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.View, {
60
+ style: {
61
+ ...styleProps
62
+ }
63
+ }, _h || (_h = /*#__PURE__*/_react.default.createElement("h1", null, "View Content")))),
64
+ container = _render2.container;
65
+ const view = container.querySelector("span[class$='-view']");
66
+ const styles = getComputedStyle(view);
67
+ expect(styles['top']).toEqual('160px');
68
+ expect(styles['left']).toEqual('5px');
69
+ expect(styles['minWidth']).toEqual('20px');
70
+ expect(styles['minHeight']).toEqual('208px');
71
+ expect(styles['position']).toEqual('absolute');
72
+ expect(styles['transform']).toEqual('translate(30px, 15px)');
73
+ expect(styles['overflow']).toEqual('hidden');
74
+ expect(styles['display']).toEqual('block');
75
+ expect(styles['pointerEvents']).toEqual('none');
76
+ });
77
+ it('should pass flex style', () => {
78
+ const _render3 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.View, {
79
+ style: {
80
+ flexBasis: '200px'
81
+ }
82
+ }, _h2 || (_h2 = /*#__PURE__*/_react.default.createElement("h1", null, "View Content")))),
83
+ container = _render3.container;
84
+ const view = container.querySelector("span[class$='-view']");
85
+ const styles = getComputedStyle(view);
86
+ expect(styles['flexBasis']).toEqual('200px');
87
+ });
88
+ it('should pass className', () => {
89
+ const className = 'fooBarBaz';
90
+ const _render4 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.View, {
91
+ className: className
92
+ }, _h3 || (_h3 = /*#__PURE__*/_react.default.createElement("h1", null, "View Content")))),
93
+ container = _render4.container;
94
+ const view = container.querySelector("span[class$='-view']");
95
+ expect(view.classList.contains(className));
96
+ });
97
+ it('should provide an elementRef', () => {
98
+ const elementRef = jest.fn();
99
+ const _render5 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.View, {
100
+ elementRef: elementRef
101
+ }, _h4 || (_h4 = /*#__PURE__*/_react.default.createElement("h1", null, "View Content")))),
102
+ container = _render5.container;
103
+ const view = container.querySelector("span[class$='-view']");
104
+ expect(elementRef).toHaveBeenCalledWith(view);
105
+ });
106
+ it('should pass cursor', () => {
107
+ const cursor = 'cell';
108
+ const _render6 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.View, {
109
+ cursor: cursor
110
+ }, _h5 || (_h5 = /*#__PURE__*/_react.default.createElement("h1", null, "View Content")))),
111
+ container = _render6.container;
112
+ const view = container.querySelector("span[class$='-view']");
113
+ const styles = getComputedStyle(view);
114
+ expect(styles['cursor']).toEqual(cursor);
115
+ });
116
+ it('should set overflow', () => {
117
+ const _render7 = (0, _react2.render)(_View3 || (_View3 = /*#__PURE__*/_react.default.createElement(_index.View, {
118
+ overflowX: "hidden",
119
+ overflowY: "auto"
120
+ }, /*#__PURE__*/_react.default.createElement("h1", null, "View Content")))),
121
+ container = _render7.container;
122
+ const view = container.querySelector("span[class$='-view']");
123
+ const styles = getComputedStyle(view);
124
+ expect(styles.overflowX).toEqual('hidden');
125
+ expect(styles.overflowY).toEqual('auto');
126
+ });
127
+ it('should set CSS position', () => {
128
+ const _render8 = (0, _react2.render)(_View4 || (_View4 = /*#__PURE__*/_react.default.createElement(_index.View, {
129
+ position: "fixed"
130
+ }, /*#__PURE__*/_react.default.createElement("h1", null, "View Content")))),
131
+ container = _render8.container;
132
+ const view = container.querySelector("span[class$='-view']");
133
+ const styles = getComputedStyle(view);
134
+ expect(styles.position).toEqual('fixed');
135
+ });
136
+ it('should set inline offset (top, bottom, left, right)', () => {
137
+ const _render9 = (0, _react2.render)(_View5 || (_View5 = /*#__PURE__*/_react.default.createElement(_index.View, {
138
+ insetBlockStart: "0",
139
+ insetBlockEnd: "20px",
140
+ insetInlineStart: "2px",
141
+ insetInlineEnd: "3px"
142
+ }, /*#__PURE__*/_react.default.createElement("h1", null, "View Content")))),
143
+ container = _render9.container;
144
+ const view = container.querySelector("span[class$='-view']");
145
+ const styles = getComputedStyle(view);
146
+ expect(styles['top']).toEqual('0px');
147
+ expect(styles['bottom']).toEqual('20px');
148
+ expect(styles['left']).toEqual('2px');
149
+ expect(styles['right']).toEqual('3px');
150
+ });
151
+ it('should override default max-width', () => {
152
+ const _render10 = (0, _react2.render)(_View6 || (_View6 = /*#__PURE__*/_react.default.createElement(_index.View, null, /*#__PURE__*/_react.default.createElement("h1", null, "View Content")))),
153
+ container = _render10.container,
154
+ rerender = _render10.rerender;
155
+ const view = container.querySelector("span[class$='-view']");
156
+ const styles = getComputedStyle(view);
157
+ expect(styles.maxWidth).toEqual('100%');
158
+ rerender(_View7 || (_View7 = /*#__PURE__*/_react.default.createElement(_index.View, {
159
+ maxWidth: "200px"
160
+ }, /*#__PURE__*/_react.default.createElement("h1", null, "View Content"))));
161
+ const newStyles = getComputedStyle(view);
162
+ expect(newStyles.maxWidth).toEqual('200px');
163
+ });
164
+ describe('withFocusOutline', () => {
165
+ it('should warn when withFocusOutline is true without position=relative', () => {
166
+ const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
167
+ (0, _react2.render)(_View8 || (_View8 = /*#__PURE__*/_react.default.createElement(_index.View, {
168
+ withFocusOutline: true
169
+ }, /*#__PURE__*/_react.default.createElement("h1", null, "View Content"))));
170
+ const expectedErrorMessage = 'Warning: [View] the focus outline will only show if the `position` prop is `relative`.';
171
+ expect(consoleErrorSpy).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
172
+ consoleErrorSpy.mockRestore();
173
+ });
174
+ it('should warn when withFocusOutline is `true`, display is set to `inline`, and focusPosition is set to `offset`', () => {
175
+ const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
176
+ (0, _react2.render)(_View9 || (_View9 = /*#__PURE__*/_react.default.createElement(_index.View, {
177
+ withFocusOutline: true,
178
+ display: "inline",
179
+ focusPosition: "offset"
180
+ }, /*#__PURE__*/_react.default.createElement("h1", null, "View Content"))));
181
+ const expectedErrorMessage = 'Warning: [View] when display is set to `inline` the focus outline will only show if `focusPosition` is set to `inset`.';
182
+ expect(consoleErrorSpy).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
183
+ consoleErrorSpy.mockRestore();
184
+ });
185
+ });
186
+ it('should meet a11y standards', async () => {
187
+ const _render11 = (0, _react2.render)(_View10 || (_View10 = /*#__PURE__*/_react.default.createElement(_index.View, null, "View Content"))),
188
+ container = _render11.container;
189
+ const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
190
+ expect(axeCheck).toBe(true);
191
+ });
192
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-view",
3
- "version": "8.53.3-snapshot-20",
3
+ "version": "8.53.3-snapshot-23",
4
4
  "description": "A component for basic styles including spacing, sizing, borders, display, positioning, and focus states.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -24,21 +24,24 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.23.2",
27
- "@instructure/console": "8.53.3-snapshot-20",
28
- "@instructure/emotion": "8.53.3-snapshot-20",
29
- "@instructure/shared-types": "8.53.3-snapshot-20",
30
- "@instructure/ui-color-utils": "8.53.3-snapshot-20",
31
- "@instructure/ui-dom-utils": "8.53.3-snapshot-20",
32
- "@instructure/ui-i18n": "8.53.3-snapshot-20",
33
- "@instructure/ui-position": "8.53.3-snapshot-20",
34
- "@instructure/ui-prop-types": "8.53.3-snapshot-20",
35
- "@instructure/ui-react-utils": "8.53.3-snapshot-20",
27
+ "@instructure/console": "8.53.3-snapshot-23",
28
+ "@instructure/emotion": "8.53.3-snapshot-23",
29
+ "@instructure/shared-types": "8.53.3-snapshot-23",
30
+ "@instructure/ui-color-utils": "8.53.3-snapshot-23",
31
+ "@instructure/ui-dom-utils": "8.53.3-snapshot-23",
32
+ "@instructure/ui-i18n": "8.53.3-snapshot-23",
33
+ "@instructure/ui-position": "8.53.3-snapshot-23",
34
+ "@instructure/ui-prop-types": "8.53.3-snapshot-23",
35
+ "@instructure/ui-react-utils": "8.53.3-snapshot-23",
36
36
  "prop-types": "^15.8.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@instructure/ui-babel-preset": "8.53.3-snapshot-20",
40
- "@instructure/ui-test-utils": "8.53.3-snapshot-20",
41
- "@instructure/ui-themes": "8.53.3-snapshot-20"
39
+ "@instructure/ui-axe-check": "8.53.3-snapshot-23",
40
+ "@instructure/ui-babel-preset": "8.53.3-snapshot-23",
41
+ "@instructure/ui-test-utils": "8.53.3-snapshot-23",
42
+ "@instructure/ui-themes": "8.53.3-snapshot-23",
43
+ "@testing-library/jest-dom": "^6.1.4",
44
+ "@testing-library/react": "^14.0.0"
42
45
  },
43
46
  "peerDependencies": {
44
47
  "react": ">=16.8 <=18"
@@ -0,0 +1,47 @@
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 React from 'react'
26
+ import { render } from '@testing-library/react'
27
+ import '@testing-library/jest-dom'
28
+
29
+ import { ContextView } from '../index'
30
+ import { runAxeCheck } from '@instructure/ui-axe-check'
31
+
32
+ describe('<ContextView />', () => {
33
+ it('should render', () => {
34
+ const { container } = render(<ContextView />)
35
+
36
+ const contextView = container.querySelector("span[class$='-contextView']")
37
+ expect(contextView).toBeInTheDocument()
38
+ })
39
+
40
+ it('should meet a11y standards', async () => {
41
+ const { container } = render(<ContextView />)
42
+
43
+ const axeCheck = await runAxeCheck(container)
44
+
45
+ expect(axeCheck).toBe(true)
46
+ })
47
+ })