@instructure/ui-react-utils 10.19.2-snapshot-2 → 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.
Files changed (53) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/package.json +7 -7
  3. package/tsconfig.build.tsbuildinfo +1 -1
  4. package/es/__new-tests__/DeterministicIdContext.test.js +0 -109
  5. package/es/__new-tests__/callRenderProp.test.js +0 -138
  6. package/es/__new-tests__/deprecated.test.js +0 -237
  7. package/es/__new-tests__/experimental.test.js +0 -98
  8. package/es/__new-tests__/getInteraction.test.js +0 -117
  9. package/es/__new-tests__/hack.test.js +0 -70
  10. package/es/__new-tests__/omitProps.test.js +0 -91
  11. package/es/__new-tests__/passthroughProps.test.js +0 -100
  12. package/es/__new-tests__/pickProps.test.js +0 -95
  13. package/es/__new-tests__/safeCloneElement.test.js +0 -87
  14. package/lib/__new-tests__/DeterministicIdContext.test.js +0 -110
  15. package/lib/__new-tests__/callRenderProp.test.js +0 -140
  16. package/lib/__new-tests__/deprecated.test.js +0 -240
  17. package/lib/__new-tests__/experimental.test.js +0 -101
  18. package/lib/__new-tests__/getInteraction.test.js +0 -119
  19. package/lib/__new-tests__/hack.test.js +0 -73
  20. package/lib/__new-tests__/omitProps.test.js +0 -94
  21. package/lib/__new-tests__/passthroughProps.test.js +0 -102
  22. package/lib/__new-tests__/pickProps.test.js +0 -98
  23. package/lib/__new-tests__/safeCloneElement.test.js +0 -89
  24. package/src/__new-tests__/DeterministicIdContext.test.tsx +0 -140
  25. package/src/__new-tests__/callRenderProp.test.tsx +0 -136
  26. package/src/__new-tests__/deprecated.test.tsx +0 -358
  27. package/src/__new-tests__/experimental.test.tsx +0 -139
  28. package/src/__new-tests__/getInteraction.test.tsx +0 -119
  29. package/src/__new-tests__/hack.test.tsx +0 -91
  30. package/src/__new-tests__/omitProps.test.tsx +0 -113
  31. package/src/__new-tests__/passthroughProps.test.tsx +0 -100
  32. package/src/__new-tests__/pickProps.test.tsx +0 -111
  33. package/src/__new-tests__/safeCloneElement.test.tsx +0 -96
  34. package/types/__new-tests__/DeterministicIdContext.test.d.ts +0 -2
  35. package/types/__new-tests__/DeterministicIdContext.test.d.ts.map +0 -1
  36. package/types/__new-tests__/callRenderProp.test.d.ts +0 -2
  37. package/types/__new-tests__/callRenderProp.test.d.ts.map +0 -1
  38. package/types/__new-tests__/deprecated.test.d.ts +0 -2
  39. package/types/__new-tests__/deprecated.test.d.ts.map +0 -1
  40. package/types/__new-tests__/experimental.test.d.ts +0 -2
  41. package/types/__new-tests__/experimental.test.d.ts.map +0 -1
  42. package/types/__new-tests__/getInteraction.test.d.ts +0 -2
  43. package/types/__new-tests__/getInteraction.test.d.ts.map +0 -1
  44. package/types/__new-tests__/hack.test.d.ts +0 -2
  45. package/types/__new-tests__/hack.test.d.ts.map +0 -1
  46. package/types/__new-tests__/omitProps.test.d.ts +0 -2
  47. package/types/__new-tests__/omitProps.test.d.ts.map +0 -1
  48. package/types/__new-tests__/passthroughProps.test.d.ts +0 -2
  49. package/types/__new-tests__/passthroughProps.test.d.ts.map +0 -1
  50. package/types/__new-tests__/pickProps.test.d.ts +0 -2
  51. package/types/__new-tests__/pickProps.test.d.ts.map +0 -1
  52. package/types/__new-tests__/safeCloneElement.test.d.ts +0 -2
  53. package/types/__new-tests__/safeCloneElement.test.d.ts.map +0 -1
@@ -1,140 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _react = require("react");
5
- var _propTypes = _interopRequireDefault(require("prop-types"));
6
- var _react2 = require("@testing-library/react");
7
- require("@testing-library/jest-dom");
8
- var _callRenderProp = require("../callRenderProp");
9
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
- var _div, _div2;
11
- /*
12
- * The MIT License (MIT)
13
- *
14
- * Copyright (c) 2015 - present Instructure, Inc.
15
- *
16
- * Permission is hereby granted, free of charge, to any person obtaining a copy
17
- * of this software and associated documentation files (the "Software"), to deal
18
- * in the Software without restriction, including without limitation the rights
19
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
- * copies of the Software, and to permit persons to whom the Software is
21
- * furnished to do so, subject to the following conditions:
22
- *
23
- * The above copyright notice and this permission notice shall be included in all
24
- * copies or substantial portions of the Software.
25
- *
26
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
- * SOFTWARE.
33
- */
34
- describe('callRenderProp', () => {
35
- it('strings', () => {
36
- expect((0, _callRenderProp.callRenderProp)('foo')).toEqual('foo');
37
- });
38
- it('numbers', () => {
39
- expect((0, _callRenderProp.callRenderProp)(2)).toEqual(2);
40
- });
41
- it('arrays', () => {
42
- const prop = ['foo', 'bar', 'baz'];
43
- expect((0, _callRenderProp.callRenderProp)(prop)).toStrictEqual(prop);
44
- expect((0, _callRenderProp.callRenderProp)([])).toStrictEqual([]);
45
- });
46
- it('booleans', () => {
47
- expect((0, _callRenderProp.callRenderProp)(false)).toEqual(false);
48
- });
49
- it('JSX literals', () => {
50
- const Foo = () => _div || (_div = (0, _jsxRuntime.jsx)("div", {
51
- children: "hello"
52
- }));
53
- expect((0, _callRenderProp.callRenderProp)((0, _jsxRuntime.jsx)(Foo, {}))).toStrictEqual((0, _jsxRuntime.jsx)(Foo, {}));
54
- });
55
- it('React classes', () => {
56
- class Foo extends _react.Component {
57
- render() {
58
- return _div2 || (_div2 = (0, _jsxRuntime.jsx)("div", {
59
- children: "hello"
60
- }));
61
- }
62
- }
63
- Foo.displayName = "Foo";
64
- const Result = (0, _callRenderProp.callRenderProp)(Foo);
65
- expect(Result).toStrictEqual((0, _jsxRuntime.jsx)(Foo, {}));
66
- const _render = (0, _react2.render)(Result),
67
- getByText = _render.getByText;
68
- expect(getByText('hello')).toBeInTheDocument();
69
- });
70
- it('functions', () => {
71
- const Baz = function () {
72
- return 'some text';
73
- };
74
- const result = (0, _callRenderProp.callRenderProp)(Baz);
75
- const _render2 = (0, _react2.render)((0, _jsxRuntime.jsx)("div", {
76
- children: result
77
- })),
78
- getByText = _render2.getByText;
79
- expect(getByText('some text')).toBeInTheDocument();
80
- });
81
- it('fat arrow functions', () => {
82
- const Baz = () => 'some text';
83
-
84
- // in this test we are trying to test that it works with fat arrow functions,
85
- // but the babel config when we run these tests is currently configured
86
- // to transpile fat arrow functions down to normal functions.
87
- // Real, untranspiled, fat-arrow functions don't have a `prototype` but when
88
- // they are transpiled down they do. So this next line is to make sure
89
- // the thing we are testing really doesn't have a prototype like it would
90
- // if it was a real untranspiled fat arrow function.
91
- if (Baz.prototype) Baz.prototype = void 0;
92
- const result = (0, _callRenderProp.callRenderProp)(Baz);
93
- const _render3 = (0, _react2.render)((0, _jsxRuntime.jsx)("div", {
94
- children: result
95
- })),
96
- getByText = _render3.getByText;
97
- expect(getByText('some text')).toBeInTheDocument();
98
- });
99
- describe('passing props', () => {
100
- it('should pass props correctly to functions', () => {
101
- const someFunc = ({
102
- shape
103
- }) => (0, _jsxRuntime.jsx)("div", {
104
- children: shape
105
- });
106
- const result = (0, _callRenderProp.callRenderProp)(someFunc, {
107
- shape: 'rectangle'
108
- });
109
- const _render4 = (0, _react2.render)((0, _jsxRuntime.jsx)("div", {
110
- children: result
111
- })),
112
- getByText = _render4.getByText;
113
- expect(getByText('rectangle')).toBeInTheDocument();
114
- });
115
- it('should pass props correctly to React classes', () => {
116
- class Foo extends _react.Component {
117
- render() {
118
- return (0, _jsxRuntime.jsx)("div", {
119
- children: this.props.shape
120
- });
121
- }
122
- }
123
- Foo.displayName = "Foo";
124
- Foo.propTypes = {
125
- shape: _propTypes.default.oneOf(['circle', 'rectangle'])
126
- };
127
- Foo.defaultProps = {
128
- shape: 'circle'
129
- };
130
- const result = (0, _callRenderProp.callRenderProp)(Foo, {
131
- shape: 'rectangle'
132
- });
133
- const _render5 = (0, _react2.render)((0, _jsxRuntime.jsx)("div", {
134
- children: result
135
- })),
136
- getByText = _render5.getByText;
137
- expect(getByText('rectangle')).toBeInTheDocument();
138
- });
139
- });
140
- });
@@ -1,240 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _react = require("react");
5
- var _vitest = require("vitest");
6
- var _propTypes = _interopRequireDefault(require("prop-types"));
7
- var _react2 = require("@testing-library/react");
8
- require("@testing-library/jest-dom");
9
- var _deprecated = require("../deprecated");
10
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
11
- /*
12
- * The MIT License (MIT)
13
- *
14
- * Copyright (c) 2015 - present Instructure, Inc.
15
- *
16
- * Permission is hereby granted, free of charge, to any person obtaining a copy
17
- * of this software and associated documentation files (the "Software"), to deal
18
- * in the Software without restriction, including without limitation the rights
19
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
- * copies of the Software, and to permit persons to whom the Software is
21
- * furnished to do so, subject to the following conditions:
22
- *
23
- * The above copyright notice and this permission notice shall be included in all
24
- * copies or substantial portions of the Software.
25
- *
26
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
- * SOFTWARE.
33
- */
34
-
35
- class TestComponent extends _react.Component {
36
- render() {
37
- return (0, _jsxRuntime.jsxs)("div", {
38
- children: [this.props.qux, " ", this.props.bar]
39
- });
40
- }
41
- }
42
- TestComponent.displayName = "TestComponent";
43
- TestComponent.propTypes = {
44
- bar: _propTypes.default.string,
45
- qux: _propTypes.default.string
46
- };
47
- TestComponent.defaultProps = {
48
- bar: null,
49
- qux: 'Hello'
50
- };
51
- describe('@deprecated', () => {
52
- describe('deprecated props', () => {
53
- var _DeprecatedComponent, _DeprecatedComponent2, _DeprecatedComponent3;
54
- const DeprecatedComponent = (0, _deprecated.deprecated)('2.1.0', {
55
- foo: 'bar',
56
- baz: true
57
- })(TestComponent);
58
- it('should warn when suggesting new prop when using old prop', () => {
59
- const consoleWarningSpy = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
60
- (0, _react2.render)(_DeprecatedComponent || (_DeprecatedComponent = (0, _jsxRuntime.jsx)(DeprecatedComponent, {
61
- foo: "Jane"
62
- })));
63
- const expectedWarningMessage = 'Warning: [TestComponent] `foo` is deprecated and will be removed in version 2.1.0. Use `bar` instead. ';
64
- expect(consoleWarningSpy).toHaveBeenCalledWith(expect.stringContaining(expectedWarningMessage), expect.any(String));
65
- consoleWarningSpy.mockRestore();
66
- });
67
- it('should warn when using old prop with no new prop', () => {
68
- const consoleWarningSpy = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
69
- (0, _react2.render)(_DeprecatedComponent2 || (_DeprecatedComponent2 = (0, _jsxRuntime.jsx)(DeprecatedComponent, {
70
- baz: "Goodbye"
71
- })));
72
- const expectedWarningMessage = 'Warning: [TestComponent] `baz` is deprecated and will be removed in version 2.1.0.';
73
- expect(consoleWarningSpy).toHaveBeenCalledWith(expect.stringContaining(expectedWarningMessage), expect.any(String));
74
- consoleWarningSpy.mockRestore();
75
- });
76
- it('should not output a warning using new prop', () => {
77
- const consoleWarningSpy = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
78
- (0, _react2.render)(_DeprecatedComponent3 || (_DeprecatedComponent3 = (0, _jsxRuntime.jsx)(DeprecatedComponent, {
79
- bar: "Jane"
80
- })));
81
- expect(consoleWarningSpy).not.toHaveBeenCalled();
82
- consoleWarningSpy.mockRestore();
83
- });
84
- });
85
- describe('deprecated component', () => {
86
- var _DeprecatedComponent4;
87
- const DeprecatedComponent = (0, _deprecated.deprecated)('3.4.0')(TestComponent);
88
- it('should warn that the entire component is deprecated if no old props are supplied', () => {
89
- const consoleWarningSpy = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
90
- (0, _react2.render)(_DeprecatedComponent4 || (_DeprecatedComponent4 = (0, _jsxRuntime.jsx)(DeprecatedComponent, {})));
91
- const expectedWarningMessage = 'Warning: [TestComponent] is deprecated and will be removed in version 3.4.0.';
92
- expect(consoleWarningSpy).toHaveBeenCalledWith(expect.stringContaining(expectedWarningMessage), expect.any(String));
93
- consoleWarningSpy.mockRestore();
94
- });
95
- });
96
- describe('deprecated component with a changed package message', () => {
97
- var _DeprecatedComponent5;
98
- const DeprecatedComponent = (0, _deprecated.deprecated)('5.0.0', null, _deprecated.deprecated.changedPackageWarning('ui-forms', 'ui-number-input'))(TestComponent);
99
- it('should warn that the component is deprecated and output a warning that the package changed', () => {
100
- const consoleWarningSpy = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
101
- const expectedWarningMessage = 'Warning: [TestComponent] is deprecated and will be removed in version 5.0.0. It has been moved from @instructure/ui-forms to @instructure/ui-number-input.';
102
- (0, _react2.render)(_DeprecatedComponent5 || (_DeprecatedComponent5 = (0, _jsxRuntime.jsx)(DeprecatedComponent, {})));
103
- expect(consoleWarningSpy).toHaveBeenCalledWith(expect.stringContaining(expectedWarningMessage), expect.any(String));
104
- consoleWarningSpy.mockRestore();
105
- });
106
- });
107
- describe('component with deprecated prop values', () => {
108
- it('should not warn when an allowed prop value is supplied', () => {
109
- const consoleWarningSpy = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
110
- class DeprecatedPropValueComponent extends _react.Component {
111
- render() {
112
- return (0, _jsxRuntime.jsx)("div", {
113
- children: this.props.color
114
- });
115
- }
116
- }
117
- DeprecatedPropValueComponent.displayName = "DeprecatedPropValueComponent";
118
- DeprecatedPropValueComponent.propTypes = {
119
- color: _deprecated.deprecated.deprecatePropValues(_propTypes.default.oneOf(['red', 'yellow', 'blue', 'orange', 'gold']), ['blue', 'orange', 'gold'])
120
- };
121
- DeprecatedPropValueComponent.defaultProps = {
122
- color: 'red'
123
- };
124
- (0, _react2.render)((0, _jsxRuntime.jsx)(DeprecatedPropValueComponent, {
125
- color: "yellow"
126
- }));
127
- expect(consoleWarningSpy).not.toHaveBeenCalled();
128
- consoleWarningSpy.mockRestore();
129
- });
130
- it('should warn when a forbidden prop value is supplied', () => {
131
- const consoleWarningSpy = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
132
- const color = 'orange';
133
- class DeprecatedPropValueComponent extends _react.Component {
134
- render() {
135
- return (0, _jsxRuntime.jsx)("div", {
136
- children: this.props.color
137
- });
138
- }
139
- }
140
- DeprecatedPropValueComponent.displayName = "DeprecatedPropValueComponent";
141
- DeprecatedPropValueComponent.propTypes = {
142
- color: _deprecated.deprecated.deprecatePropValues(_propTypes.default.oneOf(['red', 'yellow', 'blue', 'orange', 'gold']), ['blue', 'orange', 'gold'])
143
- };
144
- DeprecatedPropValueComponent.defaultProps = {
145
- color: 'red'
146
- };
147
- (0, _react2.render)((0, _jsxRuntime.jsx)(DeprecatedPropValueComponent, {
148
- color: color
149
- }));
150
- const expectedWarningMessage = `The '${color}' value for the \`color\` prop is deprecated.`;
151
- expect(consoleWarningSpy).toHaveBeenCalledWith(expect.stringContaining(expectedWarningMessage), expect.any(String));
152
- consoleWarningSpy.mockRestore();
153
- });
154
- it('should warn with additional message text when a forbidden prop value is supplied and has message text', () => {
155
- const consoleWarningSpy = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
156
- const color = 'gold';
157
- const message = 'It will be removed in v8.0.0.';
158
- class DeprecatedPropValueComponent extends _react.Component {
159
- render() {
160
- return (0, _jsxRuntime.jsx)("div", {
161
- children: this.props.color
162
- });
163
- }
164
- }
165
- DeprecatedPropValueComponent.displayName = "DeprecatedPropValueComponent";
166
- DeprecatedPropValueComponent.propTypes = {
167
- color: _deprecated.deprecated.deprecatePropValues(_propTypes.default.oneOf(['red', 'yellow', 'blue', 'orange', 'gold']), ['blue', 'orange', 'gold'], 'It will be removed in v8.0.0.')
168
- };
169
- DeprecatedPropValueComponent.defaultProps = {
170
- color: 'red'
171
- };
172
- (0, _react2.render)((0, _jsxRuntime.jsx)(DeprecatedPropValueComponent, {
173
- color: color
174
- }));
175
- const expectedWarningMessage = `The '${color}' value for the \`color\` prop is deprecated. ${message}`;
176
- expect(consoleWarningSpy).toHaveBeenCalledWith(expect.stringContaining(expectedWarningMessage), expect.any(String));
177
- consoleWarningSpy.mockRestore();
178
- });
179
- it('should call functional message with the correct props', () => {
180
- const consoleWarningSpy = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
181
- const messageMock = _vitest.vi.fn();
182
- const color = 'gold';
183
- class DeprecatedPropValueComponent extends _react.Component {
184
- render() {
185
- return (0, _jsxRuntime.jsx)("div", {
186
- children: this.props.color
187
- });
188
- }
189
- }
190
- DeprecatedPropValueComponent.displayName = "DeprecatedPropValueComponent";
191
- DeprecatedPropValueComponent.propTypes = {
192
- color: _deprecated.deprecated.deprecatePropValues(_propTypes.default.oneOf(['red', 'yellow', 'blue', 'orange', 'gold']), ['blue', 'orange', 'gold'], messageMock)
193
- };
194
- DeprecatedPropValueComponent.defaultProps = {
195
- color: 'red'
196
- };
197
- (0, _react2.render)((0, _jsxRuntime.jsx)(DeprecatedPropValueComponent, {
198
- color: color
199
- }));
200
- const _messageMock$mock$cal = messageMock.mock.calls[0][0],
201
- props = _messageMock$mock$cal.props,
202
- propName = _messageMock$mock$cal.propName,
203
- propValue = _messageMock$mock$cal.propValue;
204
- expect(props).toEqual({
205
- color
206
- });
207
- expect(propName).toBe('color');
208
- expect(propValue).toBe(color);
209
- expect(consoleWarningSpy).toHaveBeenCalled();
210
- consoleWarningSpy.mockRestore();
211
- });
212
- it('should warn with a completely custom message when provided message is functional and prop value is forbidden', () => {
213
- const consoleWarningSpy = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
214
- const color = 'gold';
215
- class DeprecatedPropValueComponent extends _react.Component {
216
- render() {
217
- return (0, _jsxRuntime.jsx)("div", {
218
- children: this.props.color
219
- });
220
- }
221
- }
222
- DeprecatedPropValueComponent.displayName = "DeprecatedPropValueComponent";
223
- DeprecatedPropValueComponent.propTypes = {
224
- color: _deprecated.deprecated.deprecatePropValues(_propTypes.default.oneOf(['red', 'yellow', 'blue', 'orange', 'gold']), ['blue', 'orange', 'gold'], ({
225
- propValue,
226
- propName
227
- }) => `The ${propValue} value for ${propName} has been deprecated. Use the FooBar component with the 'baz' prop set instead.`)
228
- };
229
- DeprecatedPropValueComponent.defaultProps = {
230
- color: 'red'
231
- };
232
- (0, _react2.render)((0, _jsxRuntime.jsx)(DeprecatedPropValueComponent, {
233
- color: color
234
- }));
235
- const expectedWarningMessage = `The ${color} value for color has been deprecated. Use the FooBar component with the 'baz' prop set instead.`;
236
- expect(consoleWarningSpy).toHaveBeenCalledWith(expect.stringContaining(expectedWarningMessage), expect.any(String));
237
- consoleWarningSpy.mockRestore();
238
- });
239
- });
240
- });
@@ -1,101 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _react = require("react");
5
- var _vitest = require("vitest");
6
- var _propTypes = _interopRequireDefault(require("prop-types"));
7
- var _react2 = require("@testing-library/react");
8
- require("@testing-library/jest-dom");
9
- var _experimental = require("../experimental");
10
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
11
- /*
12
- * The MIT License (MIT)
13
- *
14
- * Copyright (c) 2015 - present Instructure, Inc.
15
- *
16
- * Permission is hereby granted, free of charge, to any person obtaining a copy
17
- * of this software and associated documentation files (the "Software"), to deal
18
- * in the Software without restriction, including without limitation the rights
19
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
- * copies of the Software, and to permit persons to whom the Software is
21
- * furnished to do so, subject to the following conditions:
22
- *
23
- * The above copyright notice and this permission notice shall be included in all
24
- * copies or substantial portions of the Software.
25
- *
26
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
- * SOFTWARE.
33
- */
34
-
35
- class TestComponent extends _react.Component {
36
- render() {
37
- return (0, _jsxRuntime.jsxs)("div", {
38
- children: [this.props.qux, " ", this.props.bar]
39
- });
40
- }
41
- }
42
- TestComponent.displayName = "TestComponent";
43
- TestComponent.propTypes = {
44
- bar: _propTypes.default.string,
45
- qux: _propTypes.default.string
46
- };
47
- TestComponent.defaultProps = {
48
- bar: void 0,
49
- qux: 'Hello'
50
- };
51
- describe('@experimental', () => {
52
- describe('experimental props', () => {
53
- var _ExperimentalComponen, _ExperimentalComponen2, _ExperimentalComponen3;
54
- const ExperimentalComponent = (0, _experimental.experimental)(['bar'])(TestComponent);
55
- it('should warn when using an experimental prop', () => {
56
- const consoleWarningSpy = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
57
- (0, _react2.render)(_ExperimentalComponen || (_ExperimentalComponen = (0, _jsxRuntime.jsx)(ExperimentalComponent, {
58
- bar: "Jane"
59
- })));
60
- const expectedWarningMessage = 'Warning: [TestComponent] The `bar` prop is experimental and its API could change significantly in a future release.';
61
- expect(consoleWarningSpy).toHaveBeenCalledWith(expect.stringContaining(expectedWarningMessage), expect.any(String));
62
- consoleWarningSpy.mockRestore();
63
- });
64
- it('should not output a warning using a non-experimental prop', () => {
65
- const consoleWarningSpy = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
66
- (0, _react2.render)(_ExperimentalComponen2 || (_ExperimentalComponen2 = (0, _jsxRuntime.jsx)(ExperimentalComponent, {
67
- qux: "Jane"
68
- })));
69
- expect(consoleWarningSpy).not.toHaveBeenCalled();
70
- consoleWarningSpy.mockRestore();
71
- });
72
- it('should not output a warning for an experimental prop when dangerously ignored', () => {
73
- const consoleWarningSpy = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
74
- (0, _react2.render)(_ExperimentalComponen3 || (_ExperimentalComponen3 = (0, _jsxRuntime.jsx)(ExperimentalComponent, {
75
- qux: "Jane",
76
- __dangerouslyIgnoreExperimentalWarnings: true
77
- })));
78
- expect(consoleWarningSpy).not.toHaveBeenCalled();
79
- consoleWarningSpy.mockRestore();
80
- });
81
- });
82
- describe('experimental component', () => {
83
- var _ExperimentalComponen4, _ExperimentalComponen5;
84
- const ExperimentalComponent = (0, _experimental.experimental)()(TestComponent);
85
- it('should warn that the entire component is experimental if no props are supplied', () => {
86
- const consoleWarningSpy = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
87
- (0, _react2.render)(_ExperimentalComponen4 || (_ExperimentalComponen4 = (0, _jsxRuntime.jsx)(ExperimentalComponent, {})));
88
- const expectedWarningMessage = 'Warning: [TestComponent] is experimental and its API could change significantly in a future release.';
89
- expect(consoleWarningSpy).toHaveBeenCalledWith(expect.stringContaining(expectedWarningMessage), expect.any(String));
90
- consoleWarningSpy.mockRestore();
91
- });
92
- it('should not output a warning for a component when dangerously ignored', () => {
93
- const consoleWarningSpy = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
94
- (0, _react2.render)(_ExperimentalComponen5 || (_ExperimentalComponen5 = (0, _jsxRuntime.jsx)(ExperimentalComponent, {
95
- __dangerouslyIgnoreExperimentalWarnings: true
96
- })));
97
- expect(consoleWarningSpy).not.toHaveBeenCalled();
98
- consoleWarningSpy.mockRestore();
99
- });
100
- });
101
- });
@@ -1,119 +0,0 @@
1
- "use strict";
2
-
3
- require("@testing-library/jest-dom");
4
- var _getInteraction = require("../getInteraction");
5
- /*
6
- * The MIT License (MIT)
7
- *
8
- * Copyright (c) 2015 - present Instructure, Inc.
9
- *
10
- * Permission is hereby granted, free of charge, to any person obtaining a copy
11
- * of this software and associated documentation files (the "Software"), to deal
12
- * in the Software without restriction, including without limitation the rights
13
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- * copies of the Software, and to permit persons to whom the Software is
15
- * furnished to do so, subject to the following conditions:
16
- *
17
- * The above copyright notice and this permission notice shall be included in all
18
- * copies or substantial portions of the Software.
19
- *
20
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- * SOFTWARE.
27
- */
28
-
29
- describe('getInteraction', () => {
30
- it("should return 'enabled' when `interaction`, `disabled`, and `readOnly` are not provided", () => {
31
- const props = {
32
- foo: 'foo',
33
- bar: 'bar'
34
- };
35
- expect((0, _getInteraction.getInteraction)({
36
- props
37
- })).toEqual('enabled');
38
- });
39
- it('should return `interaction` value when `interaction` is specified', () => {
40
- const props = {
41
- interaction: 'enabled'
42
- };
43
- expect((0, _getInteraction.getInteraction)({
44
- props
45
- })).toEqual('enabled');
46
- props.interaction = 'disabled';
47
- expect((0, _getInteraction.getInteraction)({
48
- props
49
- })).toEqual('disabled');
50
- props.interaction = 'readonly';
51
- expect((0, _getInteraction.getInteraction)({
52
- props
53
- })).toEqual('readonly');
54
- });
55
- it('should give preference to interaction even when disabled and readonly are also specified', () => {
56
- const props = {
57
- interaction: 'enabled',
58
- disabled: true,
59
- readOnly: true
60
- };
61
- expect((0, _getInteraction.getInteraction)({
62
- props
63
- })).toEqual('enabled');
64
- props.disabled = false;
65
- props.interaction = 'disabled';
66
- expect((0, _getInteraction.getInteraction)({
67
- props
68
- })).toEqual('disabled');
69
- props.readOnly = false;
70
- props.interaction = 'readonly';
71
- expect((0, _getInteraction.getInteraction)({
72
- props
73
- })).toEqual('readonly');
74
- });
75
- it("should return 'disabled' when `disabled` prop is set and `interaction` is not specified", () => {
76
- const props = {
77
- disabled: true
78
- };
79
- expect((0, _getInteraction.getInteraction)({
80
- props
81
- })).toEqual('disabled');
82
- });
83
- it("should return 'disabled' when both `disabled` and `readonly` props are set and `interaction` is not specified", () => {
84
- const props = {
85
- disabled: true,
86
- readOnly: true
87
- };
88
- expect((0, _getInteraction.getInteraction)({
89
- props
90
- })).toEqual('disabled');
91
- });
92
- it("should return 'readonly' when `readonly` prop is set and `interaction` and `disabled` are not specified", () => {
93
- const props = {
94
- disabled: true
95
- };
96
- expect((0, _getInteraction.getInteraction)({
97
- props
98
- })).toEqual('disabled');
99
- });
100
- it('should not include `disabled` if it is not listed in the interactionTypes', () => {
101
- const props = {
102
- disabled: true,
103
- readOnly: true
104
- };
105
- expect((0, _getInteraction.getInteraction)({
106
- props,
107
- interactionTypes: ['readonly']
108
- })).toEqual('readonly');
109
- });
110
- it('should not include `readonly` if it is not listed in the interactionTypes', () => {
111
- const props = {
112
- readOnly: true
113
- };
114
- expect((0, _getInteraction.getInteraction)({
115
- props,
116
- interactionTypes: ['disabled']
117
- })).toEqual('enabled');
118
- });
119
- });
@@ -1,73 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _react = require("react");
5
- var _vitest = require("vitest");
6
- var _propTypes = _interopRequireDefault(require("prop-types"));
7
- var _react2 = require("@testing-library/react");
8
- require("@testing-library/jest-dom");
9
- var _hack = require("../hack");
10
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
11
- /*
12
- * The MIT License (MIT)
13
- *
14
- * Copyright (c) 2015 - present Instructure, Inc.
15
- *
16
- * Permission is hereby granted, free of charge, to any person obtaining a copy
17
- * of this software and associated documentation files (the "Software"), to deal
18
- * in the Software without restriction, including without limitation the rights
19
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
- * copies of the Software, and to permit persons to whom the Software is
21
- * furnished to do so, subject to the following conditions:
22
- *
23
- * The above copyright notice and this permission notice shall be included in all
24
- * copies or substantial portions of the Software.
25
- *
26
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
- * SOFTWARE.
33
- */
34
-
35
- class TestComponent extends _react.Component {
36
- render() {
37
- return (0, _jsxRuntime.jsxs)("div", {
38
- children: [this.props.qux, " ", this.props.bar]
39
- });
40
- }
41
- }
42
- TestComponent.displayName = "TestComponent";
43
- TestComponent.propTypes = {
44
- bar: _propTypes.default.string,
45
- qux: _propTypes.default.string
46
- };
47
- TestComponent.defaultProps = {
48
- bar: void 0,
49
- qux: 'Hello'
50
- };
51
- describe('@hack', () => {
52
- describe('hack props', () => {
53
- var _HackComponent, _HackComponent2;
54
- const HackComponent = (0, _hack.hack)(['bar'])(TestComponent);
55
- it('should warn when using an hack prop', () => {
56
- const consoleWarningSpy = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
57
- (0, _react2.render)(_HackComponent || (_HackComponent = (0, _jsxRuntime.jsx)(HackComponent, {
58
- bar: "Jane"
59
- })));
60
- const expectedWarningMessage = 'Warning: [TestComponent] The `bar` prop is a temporary hack and will be removed in a future release.';
61
- expect(consoleWarningSpy).toHaveBeenCalledWith(expect.stringContaining(expectedWarningMessage), expect.any(String));
62
- consoleWarningSpy.mockRestore();
63
- });
64
- it('should not output a warning using a non-hack prop', () => {
65
- const consoleWarningSpy = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
66
- (0, _react2.render)(_HackComponent2 || (_HackComponent2 = (0, _jsxRuntime.jsx)(HackComponent, {
67
- qux: "Jane"
68
- })));
69
- expect(consoleWarningSpy).not.toHaveBeenCalled();
70
- consoleWarningSpy.mockRestore();
71
- });
72
- });
73
- });