@instructure/ui-checkbox 9.2.1-snapshot-1 → 9.2.1-snapshot-3
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/es/Checkbox/CheckboxFacade/__new-tests__/CheckboxFacade.test.js +12 -0
- package/es/Checkbox/ToggleFacade/__new-tests__/ToggleFacade.test.js +12 -0
- package/es/Checkbox/__new-tests__/Checkbox.test.js +23 -11
- package/es/CheckboxGroup/__new-tests__/CheckboxGroup.test.js +18 -6
- package/lib/Checkbox/CheckboxFacade/__new-tests__/CheckboxFacade.test.js +12 -0
- package/lib/Checkbox/ToggleFacade/__new-tests__/ToggleFacade.test.js +12 -0
- package/lib/Checkbox/__new-tests__/Checkbox.test.js +23 -11
- package/lib/CheckboxGroup/__new-tests__/CheckboxGroup.test.js +18 -6
- package/package.json +21 -20
- package/src/Checkbox/CheckboxFacade/__new-tests__/CheckboxFacade.test.tsx +19 -0
- package/src/Checkbox/ToggleFacade/__new-tests__/ToggleFacade.test.tsx +19 -0
- package/src/Checkbox/__new-tests__/Checkbox.test.tsx +30 -11
- package/src/CheckboxGroup/__new-tests__/CheckboxGroup.test.tsx +25 -6
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Checkbox/CheckboxFacade/__new-tests__/CheckboxFacade.test.d.ts.map +1 -1
- package/types/Checkbox/ToggleFacade/__new-tests__/ToggleFacade.test.d.ts.map +1 -1
- package/types/Checkbox/__new-tests__/Checkbox.test.d.ts.map +1 -1
- package/types/CheckboxGroup/__new-tests__/CheckboxGroup.test.d.ts.map +1 -1
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
|
-
## [9.2.1-snapshot-
|
|
6
|
+
## [9.2.1-snapshot-3](https://github.com/instructure/instructure-ui/compare/v9.2.0...v9.2.1-snapshot-3) (2024-07-12)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-checkbox
|
|
9
9
|
|
|
@@ -25,11 +25,23 @@ var _CheckboxFacade, _CheckboxFacade2;
|
|
|
25
25
|
|
|
26
26
|
import React from 'react';
|
|
27
27
|
import { render, screen } from '@testing-library/react';
|
|
28
|
+
import { vi } from 'vitest';
|
|
28
29
|
import '@testing-library/jest-dom';
|
|
29
30
|
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
30
31
|
import { CheckboxFacade } from '../index';
|
|
31
32
|
const TEST_TEXT = 'test-text';
|
|
32
33
|
describe('<CheckboxFacade />', () => {
|
|
34
|
+
let consoleWarningMock;
|
|
35
|
+
let consoleErrorMock;
|
|
36
|
+
beforeEach(() => {
|
|
37
|
+
// Mocking console to prevent test output pollution
|
|
38
|
+
consoleWarningMock = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
39
|
+
consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
40
|
+
});
|
|
41
|
+
afterEach(() => {
|
|
42
|
+
consoleWarningMock.mockRestore();
|
|
43
|
+
consoleErrorMock.mockRestore();
|
|
44
|
+
});
|
|
33
45
|
it('should render', () => {
|
|
34
46
|
render(_CheckboxFacade || (_CheckboxFacade = /*#__PURE__*/React.createElement(CheckboxFacade, null, TEST_TEXT)));
|
|
35
47
|
const facade = screen.getByText(TEST_TEXT);
|
|
@@ -25,11 +25,23 @@ var _ToggleFacade, _ToggleFacade2;
|
|
|
25
25
|
|
|
26
26
|
import React from 'react';
|
|
27
27
|
import { render, screen } from '@testing-library/react';
|
|
28
|
+
import { vi } from 'vitest';
|
|
28
29
|
import '@testing-library/jest-dom';
|
|
29
30
|
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
30
31
|
import { ToggleFacade } from '../index';
|
|
31
32
|
const TEST_TEXT = 'test-text';
|
|
32
33
|
describe('<ToggleFacade />', () => {
|
|
34
|
+
let consoleWarningMock;
|
|
35
|
+
let consoleErrorMock;
|
|
36
|
+
beforeEach(() => {
|
|
37
|
+
// Mocking console to prevent test output pollution
|
|
38
|
+
consoleWarningMock = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
39
|
+
consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
40
|
+
});
|
|
41
|
+
afterEach(() => {
|
|
42
|
+
consoleWarningMock.mockRestore();
|
|
43
|
+
consoleErrorMock.mockRestore();
|
|
44
|
+
});
|
|
33
45
|
it('should render', () => {
|
|
34
46
|
render(_ToggleFacade || (_ToggleFacade = /*#__PURE__*/React.createElement(ToggleFacade, null, TEST_TEXT)));
|
|
35
47
|
const facade = screen.getByText(TEST_TEXT);
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
import React from 'react';
|
|
26
26
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
27
|
+
import { vi } from 'vitest';
|
|
27
28
|
import userEvent from '@testing-library/user-event';
|
|
28
29
|
import '@testing-library/jest-dom';
|
|
29
30
|
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
@@ -45,6 +46,17 @@ const renderCheckbox = props => {
|
|
|
45
46
|
return render( /*#__PURE__*/React.createElement(Checkbox, allProps));
|
|
46
47
|
};
|
|
47
48
|
describe('<Checkbox />', () => {
|
|
49
|
+
let consoleWarningMock;
|
|
50
|
+
let consoleErrorMock;
|
|
51
|
+
beforeEach(() => {
|
|
52
|
+
// Mocking console to prevent test output pollution
|
|
53
|
+
consoleWarningMock = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
54
|
+
consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
55
|
+
});
|
|
56
|
+
afterEach(() => {
|
|
57
|
+
consoleWarningMock.mockRestore();
|
|
58
|
+
consoleErrorMock.mockRestore();
|
|
59
|
+
});
|
|
48
60
|
it('renders an input with type "checkbox"', () => {
|
|
49
61
|
renderCheckbox();
|
|
50
62
|
const inputElem = screen.getByRole('checkbox');
|
|
@@ -78,8 +90,8 @@ describe('<Checkbox />', () => {
|
|
|
78
90
|
});
|
|
79
91
|
describe('events', () => {
|
|
80
92
|
it('when clicked, fires onClick and onChange events', async () => {
|
|
81
|
-
const onClick =
|
|
82
|
-
const onChange =
|
|
93
|
+
const onClick = vi.fn();
|
|
94
|
+
const onChange = vi.fn();
|
|
83
95
|
renderCheckbox({
|
|
84
96
|
onClick,
|
|
85
97
|
onChange
|
|
@@ -92,8 +104,8 @@ describe('<Checkbox />', () => {
|
|
|
92
104
|
});
|
|
93
105
|
});
|
|
94
106
|
it('when clicked, does not call onClick or onChange when disabled', async () => {
|
|
95
|
-
const onClick =
|
|
96
|
-
const onChange =
|
|
107
|
+
const onClick = vi.fn();
|
|
108
|
+
const onChange = vi.fn();
|
|
97
109
|
renderCheckbox({
|
|
98
110
|
onClick,
|
|
99
111
|
onChange,
|
|
@@ -108,8 +120,8 @@ describe('<Checkbox />', () => {
|
|
|
108
120
|
});
|
|
109
121
|
});
|
|
110
122
|
it('when clicked, does not call onClick or onChange when readOnly', async () => {
|
|
111
|
-
const onClick =
|
|
112
|
-
const onChange =
|
|
123
|
+
const onClick = vi.fn();
|
|
124
|
+
const onChange = vi.fn();
|
|
113
125
|
renderCheckbox({
|
|
114
126
|
onClick,
|
|
115
127
|
onChange,
|
|
@@ -123,7 +135,7 @@ describe('<Checkbox />', () => {
|
|
|
123
135
|
});
|
|
124
136
|
});
|
|
125
137
|
it('calls onChange when enter key is pressed', async () => {
|
|
126
|
-
const onChange =
|
|
138
|
+
const onChange = vi.fn();
|
|
127
139
|
renderCheckbox({
|
|
128
140
|
onChange
|
|
129
141
|
});
|
|
@@ -134,7 +146,7 @@ describe('<Checkbox />', () => {
|
|
|
134
146
|
});
|
|
135
147
|
});
|
|
136
148
|
it('responds to onBlur event', async () => {
|
|
137
|
-
const onBlur =
|
|
149
|
+
const onBlur = vi.fn();
|
|
138
150
|
renderCheckbox({
|
|
139
151
|
onBlur
|
|
140
152
|
});
|
|
@@ -145,7 +157,7 @@ describe('<Checkbox />', () => {
|
|
|
145
157
|
});
|
|
146
158
|
});
|
|
147
159
|
it('responds to onFocus event', async () => {
|
|
148
|
-
const onFocus =
|
|
160
|
+
const onFocus = vi.fn();
|
|
149
161
|
renderCheckbox({
|
|
150
162
|
onFocus
|
|
151
163
|
});
|
|
@@ -166,7 +178,7 @@ describe('<Checkbox />', () => {
|
|
|
166
178
|
expect(checkboxElement).toHaveFocus();
|
|
167
179
|
});
|
|
168
180
|
it('calls onMouseOver', async () => {
|
|
169
|
-
const onMouseOver =
|
|
181
|
+
const onMouseOver = vi.fn();
|
|
170
182
|
renderCheckbox({
|
|
171
183
|
onMouseOver
|
|
172
184
|
});
|
|
@@ -177,7 +189,7 @@ describe('<Checkbox />', () => {
|
|
|
177
189
|
});
|
|
178
190
|
});
|
|
179
191
|
it('calls onMouseOut', async () => {
|
|
180
|
-
const onMouseOut =
|
|
192
|
+
const onMouseOut = vi.fn();
|
|
181
193
|
renderCheckbox({
|
|
182
194
|
onMouseOut
|
|
183
195
|
});
|
|
@@ -25,6 +25,7 @@ var _Checkbox, _Checkbox2;
|
|
|
25
25
|
|
|
26
26
|
import React from 'react';
|
|
27
27
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
28
|
+
import { vi } from 'vitest';
|
|
28
29
|
import userEvent from '@testing-library/user-event';
|
|
29
30
|
import '@testing-library/jest-dom';
|
|
30
31
|
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
@@ -52,6 +53,17 @@ const renderCheckboxGroup = props => {
|
|
|
52
53
|
}))));
|
|
53
54
|
};
|
|
54
55
|
describe('<CheckboxGroup />', () => {
|
|
56
|
+
let consoleWarningMock;
|
|
57
|
+
let consoleErrorMock;
|
|
58
|
+
beforeEach(() => {
|
|
59
|
+
// Mocking console to prevent test output pollution
|
|
60
|
+
consoleWarningMock = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
61
|
+
consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
62
|
+
});
|
|
63
|
+
afterEach(() => {
|
|
64
|
+
consoleWarningMock.mockRestore();
|
|
65
|
+
consoleErrorMock.mockRestore();
|
|
66
|
+
});
|
|
55
67
|
it('adds the name props to all Checkbox types', () => {
|
|
56
68
|
renderCheckboxGroup({
|
|
57
69
|
name: TEST_NAME
|
|
@@ -85,7 +97,7 @@ describe('<CheckboxGroup />', () => {
|
|
|
85
97
|
expect(legend).toHaveTextContent(TEST_DESCRIPTION);
|
|
86
98
|
});
|
|
87
99
|
it('does not call the onChange prop when disabled', async () => {
|
|
88
|
-
const onChange =
|
|
100
|
+
const onChange = vi.fn();
|
|
89
101
|
renderCheckboxGroup({
|
|
90
102
|
onChange,
|
|
91
103
|
disabled: true
|
|
@@ -98,7 +110,7 @@ describe('<CheckboxGroup />', () => {
|
|
|
98
110
|
});
|
|
99
111
|
});
|
|
100
112
|
it('does not call the onChange prop when readOnly', async () => {
|
|
101
|
-
const onChange =
|
|
113
|
+
const onChange = vi.fn();
|
|
102
114
|
renderCheckboxGroup({
|
|
103
115
|
onChange,
|
|
104
116
|
readOnly: true
|
|
@@ -111,7 +123,7 @@ describe('<CheckboxGroup />', () => {
|
|
|
111
123
|
});
|
|
112
124
|
});
|
|
113
125
|
it('should not update the value when the value prop is set', async () => {
|
|
114
|
-
const onChange =
|
|
126
|
+
const onChange = vi.fn();
|
|
115
127
|
renderCheckboxGroup({
|
|
116
128
|
onChange,
|
|
117
129
|
value: ['tester']
|
|
@@ -127,7 +139,7 @@ describe('<CheckboxGroup />', () => {
|
|
|
127
139
|
});
|
|
128
140
|
});
|
|
129
141
|
it('should add the checkbox value to the value list when it is checked', async () => {
|
|
130
|
-
const onChange =
|
|
142
|
+
const onChange = vi.fn();
|
|
131
143
|
renderCheckboxGroup({
|
|
132
144
|
onChange
|
|
133
145
|
});
|
|
@@ -152,7 +164,7 @@ describe('<CheckboxGroup />', () => {
|
|
|
152
164
|
expect(checkboxes[1]).toBeChecked();
|
|
153
165
|
});
|
|
154
166
|
it('should remove the checkbox value from the value list when it is unchecked', async () => {
|
|
155
|
-
const onChange =
|
|
167
|
+
const onChange = vi.fn();
|
|
156
168
|
const defaultValue = [TEST_VALUE_1, TEST_VALUE_2];
|
|
157
169
|
renderCheckboxGroup({
|
|
158
170
|
onChange,
|
|
@@ -169,7 +181,7 @@ describe('<CheckboxGroup />', () => {
|
|
|
169
181
|
});
|
|
170
182
|
});
|
|
171
183
|
it('passes the array of selected values to onChange handler', async () => {
|
|
172
|
-
const onChange =
|
|
184
|
+
const onChange = vi.fn();
|
|
173
185
|
const defaultValue = [TEST_VALUE_2];
|
|
174
186
|
renderCheckboxGroup({
|
|
175
187
|
onChange,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
var _react = _interopRequireDefault(require("react"));
|
|
5
5
|
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _vitest = require("vitest");
|
|
6
7
|
require("@testing-library/jest-dom");
|
|
7
8
|
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
8
9
|
var _index = require("../index");
|
|
@@ -32,6 +33,17 @@ var _CheckboxFacade, _CheckboxFacade2;
|
|
|
32
33
|
*/
|
|
33
34
|
const TEST_TEXT = 'test-text';
|
|
34
35
|
describe('<CheckboxFacade />', () => {
|
|
36
|
+
let consoleWarningMock;
|
|
37
|
+
let consoleErrorMock;
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
// Mocking console to prevent test output pollution
|
|
40
|
+
consoleWarningMock = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
41
|
+
consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
42
|
+
});
|
|
43
|
+
afterEach(() => {
|
|
44
|
+
consoleWarningMock.mockRestore();
|
|
45
|
+
consoleErrorMock.mockRestore();
|
|
46
|
+
});
|
|
35
47
|
it('should render', () => {
|
|
36
48
|
(0, _react2.render)(_CheckboxFacade || (_CheckboxFacade = /*#__PURE__*/_react.default.createElement(_index.CheckboxFacade, null, TEST_TEXT)));
|
|
37
49
|
const facade = _react2.screen.getByText(TEST_TEXT);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
var _react = _interopRequireDefault(require("react"));
|
|
5
5
|
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _vitest = require("vitest");
|
|
6
7
|
require("@testing-library/jest-dom");
|
|
7
8
|
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
8
9
|
var _index = require("../index");
|
|
@@ -32,6 +33,17 @@ var _ToggleFacade, _ToggleFacade2;
|
|
|
32
33
|
*/
|
|
33
34
|
const TEST_TEXT = 'test-text';
|
|
34
35
|
describe('<ToggleFacade />', () => {
|
|
36
|
+
let consoleWarningMock;
|
|
37
|
+
let consoleErrorMock;
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
// Mocking console to prevent test output pollution
|
|
40
|
+
consoleWarningMock = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
41
|
+
consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
42
|
+
});
|
|
43
|
+
afterEach(() => {
|
|
44
|
+
consoleWarningMock.mockRestore();
|
|
45
|
+
consoleErrorMock.mockRestore();
|
|
46
|
+
});
|
|
35
47
|
it('should render', () => {
|
|
36
48
|
(0, _react2.render)(_ToggleFacade || (_ToggleFacade = /*#__PURE__*/_react.default.createElement(_index.ToggleFacade, null, TEST_TEXT)));
|
|
37
49
|
const facade = _react2.screen.getByText(TEST_TEXT);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
var _react = _interopRequireDefault(require("react"));
|
|
5
5
|
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _vitest = require("vitest");
|
|
6
7
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
7
8
|
require("@testing-library/jest-dom");
|
|
8
9
|
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
@@ -48,6 +49,17 @@ const renderCheckbox = props => {
|
|
|
48
49
|
return (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Checkbox, allProps));
|
|
49
50
|
};
|
|
50
51
|
describe('<Checkbox />', () => {
|
|
52
|
+
let consoleWarningMock;
|
|
53
|
+
let consoleErrorMock;
|
|
54
|
+
beforeEach(() => {
|
|
55
|
+
// Mocking console to prevent test output pollution
|
|
56
|
+
consoleWarningMock = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
57
|
+
consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
58
|
+
});
|
|
59
|
+
afterEach(() => {
|
|
60
|
+
consoleWarningMock.mockRestore();
|
|
61
|
+
consoleErrorMock.mockRestore();
|
|
62
|
+
});
|
|
51
63
|
it('renders an input with type "checkbox"', () => {
|
|
52
64
|
renderCheckbox();
|
|
53
65
|
const inputElem = _react2.screen.getByRole('checkbox');
|
|
@@ -81,8 +93,8 @@ describe('<Checkbox />', () => {
|
|
|
81
93
|
});
|
|
82
94
|
describe('events', () => {
|
|
83
95
|
it('when clicked, fires onClick and onChange events', async () => {
|
|
84
|
-
const onClick =
|
|
85
|
-
const onChange =
|
|
96
|
+
const onClick = _vitest.vi.fn();
|
|
97
|
+
const onChange = _vitest.vi.fn();
|
|
86
98
|
renderCheckbox({
|
|
87
99
|
onClick,
|
|
88
100
|
onChange
|
|
@@ -95,8 +107,8 @@ describe('<Checkbox />', () => {
|
|
|
95
107
|
});
|
|
96
108
|
});
|
|
97
109
|
it('when clicked, does not call onClick or onChange when disabled', async () => {
|
|
98
|
-
const onClick =
|
|
99
|
-
const onChange =
|
|
110
|
+
const onClick = _vitest.vi.fn();
|
|
111
|
+
const onChange = _vitest.vi.fn();
|
|
100
112
|
renderCheckbox({
|
|
101
113
|
onClick,
|
|
102
114
|
onChange,
|
|
@@ -111,8 +123,8 @@ describe('<Checkbox />', () => {
|
|
|
111
123
|
});
|
|
112
124
|
});
|
|
113
125
|
it('when clicked, does not call onClick or onChange when readOnly', async () => {
|
|
114
|
-
const onClick =
|
|
115
|
-
const onChange =
|
|
126
|
+
const onClick = _vitest.vi.fn();
|
|
127
|
+
const onChange = _vitest.vi.fn();
|
|
116
128
|
renderCheckbox({
|
|
117
129
|
onClick,
|
|
118
130
|
onChange,
|
|
@@ -126,7 +138,7 @@ describe('<Checkbox />', () => {
|
|
|
126
138
|
});
|
|
127
139
|
});
|
|
128
140
|
it('calls onChange when enter key is pressed', async () => {
|
|
129
|
-
const onChange =
|
|
141
|
+
const onChange = _vitest.vi.fn();
|
|
130
142
|
renderCheckbox({
|
|
131
143
|
onChange
|
|
132
144
|
});
|
|
@@ -137,7 +149,7 @@ describe('<Checkbox />', () => {
|
|
|
137
149
|
});
|
|
138
150
|
});
|
|
139
151
|
it('responds to onBlur event', async () => {
|
|
140
|
-
const onBlur =
|
|
152
|
+
const onBlur = _vitest.vi.fn();
|
|
141
153
|
renderCheckbox({
|
|
142
154
|
onBlur
|
|
143
155
|
});
|
|
@@ -148,7 +160,7 @@ describe('<Checkbox />', () => {
|
|
|
148
160
|
});
|
|
149
161
|
});
|
|
150
162
|
it('responds to onFocus event', async () => {
|
|
151
|
-
const onFocus =
|
|
163
|
+
const onFocus = _vitest.vi.fn();
|
|
152
164
|
renderCheckbox({
|
|
153
165
|
onFocus
|
|
154
166
|
});
|
|
@@ -169,7 +181,7 @@ describe('<Checkbox />', () => {
|
|
|
169
181
|
expect(checkboxElement).toHaveFocus();
|
|
170
182
|
});
|
|
171
183
|
it('calls onMouseOver', async () => {
|
|
172
|
-
const onMouseOver =
|
|
184
|
+
const onMouseOver = _vitest.vi.fn();
|
|
173
185
|
renderCheckbox({
|
|
174
186
|
onMouseOver
|
|
175
187
|
});
|
|
@@ -180,7 +192,7 @@ describe('<Checkbox />', () => {
|
|
|
180
192
|
});
|
|
181
193
|
});
|
|
182
194
|
it('calls onMouseOut', async () => {
|
|
183
|
-
const onMouseOut =
|
|
195
|
+
const onMouseOut = _vitest.vi.fn();
|
|
184
196
|
renderCheckbox({
|
|
185
197
|
onMouseOut
|
|
186
198
|
});
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
var _react = _interopRequireDefault(require("react"));
|
|
5
5
|
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _vitest = require("vitest");
|
|
6
7
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
7
8
|
require("@testing-library/jest-dom");
|
|
8
9
|
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
@@ -54,6 +55,17 @@ const renderCheckboxGroup = props => {
|
|
|
54
55
|
}))));
|
|
55
56
|
};
|
|
56
57
|
describe('<CheckboxGroup />', () => {
|
|
58
|
+
let consoleWarningMock;
|
|
59
|
+
let consoleErrorMock;
|
|
60
|
+
beforeEach(() => {
|
|
61
|
+
// Mocking console to prevent test output pollution
|
|
62
|
+
consoleWarningMock = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
63
|
+
consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
64
|
+
});
|
|
65
|
+
afterEach(() => {
|
|
66
|
+
consoleWarningMock.mockRestore();
|
|
67
|
+
consoleErrorMock.mockRestore();
|
|
68
|
+
});
|
|
57
69
|
it('adds the name props to all Checkbox types', () => {
|
|
58
70
|
renderCheckboxGroup({
|
|
59
71
|
name: TEST_NAME
|
|
@@ -87,7 +99,7 @@ describe('<CheckboxGroup />', () => {
|
|
|
87
99
|
expect(legend).toHaveTextContent(TEST_DESCRIPTION);
|
|
88
100
|
});
|
|
89
101
|
it('does not call the onChange prop when disabled', async () => {
|
|
90
|
-
const onChange =
|
|
102
|
+
const onChange = _vitest.vi.fn();
|
|
91
103
|
renderCheckboxGroup({
|
|
92
104
|
onChange,
|
|
93
105
|
disabled: true
|
|
@@ -100,7 +112,7 @@ describe('<CheckboxGroup />', () => {
|
|
|
100
112
|
});
|
|
101
113
|
});
|
|
102
114
|
it('does not call the onChange prop when readOnly', async () => {
|
|
103
|
-
const onChange =
|
|
115
|
+
const onChange = _vitest.vi.fn();
|
|
104
116
|
renderCheckboxGroup({
|
|
105
117
|
onChange,
|
|
106
118
|
readOnly: true
|
|
@@ -113,7 +125,7 @@ describe('<CheckboxGroup />', () => {
|
|
|
113
125
|
});
|
|
114
126
|
});
|
|
115
127
|
it('should not update the value when the value prop is set', async () => {
|
|
116
|
-
const onChange =
|
|
128
|
+
const onChange = _vitest.vi.fn();
|
|
117
129
|
renderCheckboxGroup({
|
|
118
130
|
onChange,
|
|
119
131
|
value: ['tester']
|
|
@@ -129,7 +141,7 @@ describe('<CheckboxGroup />', () => {
|
|
|
129
141
|
});
|
|
130
142
|
});
|
|
131
143
|
it('should add the checkbox value to the value list when it is checked', async () => {
|
|
132
|
-
const onChange =
|
|
144
|
+
const onChange = _vitest.vi.fn();
|
|
133
145
|
renderCheckboxGroup({
|
|
134
146
|
onChange
|
|
135
147
|
});
|
|
@@ -154,7 +166,7 @@ describe('<CheckboxGroup />', () => {
|
|
|
154
166
|
expect(checkboxes[1]).toBeChecked();
|
|
155
167
|
});
|
|
156
168
|
it('should remove the checkbox value from the value list when it is unchecked', async () => {
|
|
157
|
-
const onChange =
|
|
169
|
+
const onChange = _vitest.vi.fn();
|
|
158
170
|
const defaultValue = [TEST_VALUE_1, TEST_VALUE_2];
|
|
159
171
|
renderCheckboxGroup({
|
|
160
172
|
onChange,
|
|
@@ -171,7 +183,7 @@ describe('<CheckboxGroup />', () => {
|
|
|
171
183
|
});
|
|
172
184
|
});
|
|
173
185
|
it('passes the array of selected values to onChange handler', async () => {
|
|
174
|
-
const onChange =
|
|
186
|
+
const onChange = _vitest.vi.fn();
|
|
175
187
|
const defaultValue = [TEST_VALUE_2];
|
|
176
188
|
renderCheckboxGroup({
|
|
177
189
|
onChange,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-checkbox",
|
|
3
|
-
"version": "9.2.1-snapshot-
|
|
3
|
+
"version": "9.2.1-snapshot-3",
|
|
4
4
|
"description": " styled HTML input type='checkbox' component.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,31 +24,32 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.24.5",
|
|
27
|
-
"@instructure/console": "9.2.1-snapshot-
|
|
28
|
-
"@instructure/emotion": "9.2.1-snapshot-
|
|
29
|
-
"@instructure/shared-types": "9.2.1-snapshot-
|
|
30
|
-
"@instructure/ui-dom-utils": "9.2.1-snapshot-
|
|
31
|
-
"@instructure/ui-form-field": "9.2.1-snapshot-
|
|
32
|
-
"@instructure/ui-icons": "9.2.1-snapshot-
|
|
33
|
-
"@instructure/ui-prop-types": "9.2.1-snapshot-
|
|
34
|
-
"@instructure/ui-react-utils": "9.2.1-snapshot-
|
|
35
|
-
"@instructure/ui-svg-images": "9.2.1-snapshot-
|
|
36
|
-
"@instructure/ui-testable": "9.2.1-snapshot-
|
|
37
|
-
"@instructure/ui-utils": "9.2.1-snapshot-
|
|
38
|
-
"@instructure/ui-view": "9.2.1-snapshot-
|
|
39
|
-
"@instructure/uid": "9.2.1-snapshot-
|
|
27
|
+
"@instructure/console": "9.2.1-snapshot-3",
|
|
28
|
+
"@instructure/emotion": "9.2.1-snapshot-3",
|
|
29
|
+
"@instructure/shared-types": "9.2.1-snapshot-3",
|
|
30
|
+
"@instructure/ui-dom-utils": "9.2.1-snapshot-3",
|
|
31
|
+
"@instructure/ui-form-field": "9.2.1-snapshot-3",
|
|
32
|
+
"@instructure/ui-icons": "9.2.1-snapshot-3",
|
|
33
|
+
"@instructure/ui-prop-types": "9.2.1-snapshot-3",
|
|
34
|
+
"@instructure/ui-react-utils": "9.2.1-snapshot-3",
|
|
35
|
+
"@instructure/ui-svg-images": "9.2.1-snapshot-3",
|
|
36
|
+
"@instructure/ui-testable": "9.2.1-snapshot-3",
|
|
37
|
+
"@instructure/ui-utils": "9.2.1-snapshot-3",
|
|
38
|
+
"@instructure/ui-view": "9.2.1-snapshot-3",
|
|
39
|
+
"@instructure/uid": "9.2.1-snapshot-3",
|
|
40
40
|
"keycode": "^2.2.1",
|
|
41
41
|
"prop-types": "^15.8.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@instructure/ui-axe-check": "9.2.1-snapshot-
|
|
45
|
-
"@instructure/ui-babel-preset": "9.2.1-snapshot-
|
|
46
|
-
"@instructure/ui-color-utils": "9.2.1-snapshot-
|
|
47
|
-
"@instructure/ui-test-utils": "9.2.1-snapshot-
|
|
48
|
-
"@instructure/ui-themes": "9.2.1-snapshot-
|
|
44
|
+
"@instructure/ui-axe-check": "9.2.1-snapshot-3",
|
|
45
|
+
"@instructure/ui-babel-preset": "9.2.1-snapshot-3",
|
|
46
|
+
"@instructure/ui-color-utils": "9.2.1-snapshot-3",
|
|
47
|
+
"@instructure/ui-test-utils": "9.2.1-snapshot-3",
|
|
48
|
+
"@instructure/ui-themes": "9.2.1-snapshot-3",
|
|
49
49
|
"@testing-library/jest-dom": "^6.4.5",
|
|
50
50
|
"@testing-library/react": "^15.0.7",
|
|
51
|
-
"@testing-library/user-event": "^14.5.2"
|
|
51
|
+
"@testing-library/user-event": "^14.5.2",
|
|
52
|
+
"vitest": "^1.6.0"
|
|
52
53
|
},
|
|
53
54
|
"peerDependencies": {
|
|
54
55
|
"react": ">=16.8 <=18"
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
26
|
import { render, screen } from '@testing-library/react'
|
|
27
|
+
import { vi } from 'vitest'
|
|
27
28
|
import '@testing-library/jest-dom'
|
|
28
29
|
|
|
29
30
|
import { runAxeCheck } from '@instructure/ui-axe-check'
|
|
@@ -32,6 +33,24 @@ import { CheckboxFacade } from '../index'
|
|
|
32
33
|
const TEST_TEXT = 'test-text'
|
|
33
34
|
|
|
34
35
|
describe('<CheckboxFacade />', () => {
|
|
36
|
+
let consoleWarningMock: ReturnType<typeof vi.spyOn>
|
|
37
|
+
let consoleErrorMock: ReturnType<typeof vi.spyOn>
|
|
38
|
+
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
// Mocking console to prevent test output pollution
|
|
41
|
+
consoleWarningMock = vi
|
|
42
|
+
.spyOn(console, 'warn')
|
|
43
|
+
.mockImplementation(() => {}) as any
|
|
44
|
+
consoleErrorMock = vi
|
|
45
|
+
.spyOn(console, 'error')
|
|
46
|
+
.mockImplementation(() => {}) as any
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
afterEach(() => {
|
|
50
|
+
consoleWarningMock.mockRestore()
|
|
51
|
+
consoleErrorMock.mockRestore()
|
|
52
|
+
})
|
|
53
|
+
|
|
35
54
|
it('should render', () => {
|
|
36
55
|
render(<CheckboxFacade>{TEST_TEXT}</CheckboxFacade>)
|
|
37
56
|
const facade = screen.getByText(TEST_TEXT)
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
26
|
import { render, screen } from '@testing-library/react'
|
|
27
|
+
import { vi } from 'vitest'
|
|
27
28
|
import '@testing-library/jest-dom'
|
|
28
29
|
|
|
29
30
|
import { runAxeCheck } from '@instructure/ui-axe-check'
|
|
@@ -32,6 +33,24 @@ import { ToggleFacade } from '../index'
|
|
|
32
33
|
const TEST_TEXT = 'test-text'
|
|
33
34
|
|
|
34
35
|
describe('<ToggleFacade />', () => {
|
|
36
|
+
let consoleWarningMock: ReturnType<typeof vi.spyOn>
|
|
37
|
+
let consoleErrorMock: ReturnType<typeof vi.spyOn>
|
|
38
|
+
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
// Mocking console to prevent test output pollution
|
|
41
|
+
consoleWarningMock = vi
|
|
42
|
+
.spyOn(console, 'warn')
|
|
43
|
+
.mockImplementation(() => {}) as any
|
|
44
|
+
consoleErrorMock = vi
|
|
45
|
+
.spyOn(console, 'error')
|
|
46
|
+
.mockImplementation(() => {}) as any
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
afterEach(() => {
|
|
50
|
+
consoleWarningMock.mockRestore()
|
|
51
|
+
consoleErrorMock.mockRestore()
|
|
52
|
+
})
|
|
53
|
+
|
|
35
54
|
it('should render', () => {
|
|
36
55
|
render(<ToggleFacade>{TEST_TEXT}</ToggleFacade>)
|
|
37
56
|
const facade = screen.getByText(TEST_TEXT)
|