@instructure/ui-checkbox 8.46.2-snapshot-0 → 8.46.2-snapshot-2

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 (42) hide show
  1. package/CHANGELOG.md +5 -2
  2. package/es/Checkbox/{locator.js → CheckboxFacade/__new-tests__/CheckboxFacade.test.js} +20 -3
  3. package/es/Checkbox/{CheckboxLocator.js → ToggleFacade/__new-tests__/ToggleFacade.test.js} +20 -5
  4. package/es/Checkbox/__new-tests__/Checkbox.test.js +210 -0
  5. package/es/Checkbox/index.js +1 -1
  6. package/es/CheckboxGroup/__new-tests__/CheckboxGroup.test.js +196 -0
  7. package/lib/Checkbox/{locator.js → CheckboxFacade/__new-tests__/CheckboxFacade.test.js} +21 -13
  8. package/lib/Checkbox/{CheckboxLocator.js → ToggleFacade/__new-tests__/ToggleFacade.test.js} +21 -10
  9. package/lib/Checkbox/__new-tests__/Checkbox.test.js +213 -0
  10. package/lib/Checkbox/index.js +1 -1
  11. package/lib/CheckboxGroup/__new-tests__/CheckboxGroup.test.js +198 -0
  12. package/package.json +22 -19
  13. package/src/{CheckboxGroup/CheckboxGroupLocator.ts → Checkbox/CheckboxFacade/__new-tests__/CheckboxFacade.test.tsx} +22 -4
  14. package/src/Checkbox/{CheckboxLocator.ts → ToggleFacade/__new-tests__/ToggleFacade.test.tsx} +22 -4
  15. package/src/Checkbox/__new-tests__/Checkbox.test.tsx +221 -0
  16. package/src/Checkbox/index.tsx +4 -3
  17. package/src/CheckboxGroup/__new-tests__/CheckboxGroup.test.tsx +202 -0
  18. package/tsconfig.build.json +2 -2
  19. package/tsconfig.build.tsbuildinfo +1 -1
  20. package/types/Checkbox/CheckboxFacade/__new-tests__/CheckboxFacade.test.d.ts +2 -0
  21. package/types/Checkbox/CheckboxFacade/__new-tests__/CheckboxFacade.test.d.ts.map +1 -0
  22. package/types/Checkbox/ToggleFacade/__new-tests__/ToggleFacade.test.d.ts +2 -0
  23. package/types/Checkbox/ToggleFacade/__new-tests__/ToggleFacade.test.d.ts.map +1 -0
  24. package/types/Checkbox/__new-tests__/Checkbox.test.d.ts +2 -0
  25. package/types/Checkbox/__new-tests__/Checkbox.test.d.ts.map +1 -0
  26. package/types/Checkbox/index.d.ts.map +1 -1
  27. package/types/CheckboxGroup/__new-tests__/CheckboxGroup.test.d.ts +2 -0
  28. package/types/CheckboxGroup/__new-tests__/CheckboxGroup.test.d.ts.map +1 -0
  29. package/es/CheckboxGroup/CheckboxGroupLocator.js +0 -29
  30. package/es/CheckboxGroup/locator.js +0 -27
  31. package/lib/CheckboxGroup/CheckboxGroupLocator.js +0 -35
  32. package/lib/CheckboxGroup/locator.js +0 -38
  33. package/src/Checkbox/locator.ts +0 -28
  34. package/src/CheckboxGroup/locator.ts +0 -28
  35. package/types/Checkbox/CheckboxLocator.d.ts +0 -566
  36. package/types/Checkbox/CheckboxLocator.d.ts.map +0 -1
  37. package/types/Checkbox/locator.d.ts +0 -4
  38. package/types/Checkbox/locator.d.ts.map +0 -1
  39. package/types/CheckboxGroup/CheckboxGroupLocator.d.ts +0 -566
  40. package/types/CheckboxGroup/CheckboxGroupLocator.d.ts.map +0 -1
  41. package/types/CheckboxGroup/locator.d.ts +0 -4
  42. package/types/CheckboxGroup/locator.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -3,9 +3,12 @@
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.46.2-snapshot-0](https://github.com/instructure/instructure-ui/compare/v8.46.1...v8.46.2-snapshot-0) (2023-10-13)
6
+ ## [8.46.2-snapshot-2](https://github.com/instructure/instructure-ui/compare/v8.46.1...v8.46.2-snapshot-2) (2023-10-17)
7
7
 
8
- **Note:** Version bump only for package @instructure/ui-checkbox
8
+
9
+ ### Bug Fixes
10
+
11
+ * **ui-checkbox,ui-spinner:** remove hover highlight from disabled checkbox ([3fe755f](https://github.com/instructure/instructure-ui/commit/3fe755f65127e3bd18a7ff2a2d974b386ab831b0))
9
12
 
10
13
 
11
14
 
@@ -1,3 +1,4 @@
1
+ var _CheckboxFacade, _CheckboxFacade2;
1
2
  /*
2
3
  * The MIT License (MIT)
3
4
  *
@@ -22,6 +23,22 @@
22
23
  * SOFTWARE.
23
24
  */
24
25
 
25
- import { CheckboxLocator } from './CheckboxLocator';
26
- export { CheckboxLocator };
27
- export default CheckboxLocator;
26
+ import React from 'react';
27
+ import { render, screen } from '@testing-library/react';
28
+ import '@testing-library/jest-dom/extend-expect';
29
+ import { runAxeCheck } from '@instructure/ui-axe-check';
30
+ import { CheckboxFacade } from '../index';
31
+ const TEST_TEXT = 'test-text';
32
+ describe('<CheckboxFacade />', () => {
33
+ it('should render', () => {
34
+ render(_CheckboxFacade || (_CheckboxFacade = /*#__PURE__*/React.createElement(CheckboxFacade, null, TEST_TEXT)));
35
+ const facade = screen.getByText(TEST_TEXT);
36
+ expect(facade).toBeInTheDocument();
37
+ });
38
+ it('should meet a11y standards', async () => {
39
+ const _render = render(_CheckboxFacade2 || (_CheckboxFacade2 = /*#__PURE__*/React.createElement(CheckboxFacade, null, TEST_TEXT))),
40
+ container = _render.container;
41
+ const axeCheck = await runAxeCheck(container);
42
+ expect(axeCheck).toBe(true);
43
+ });
44
+ });
@@ -1,3 +1,4 @@
1
+ var _ToggleFacade, _ToggleFacade2;
1
2
  /*
2
3
  * The MIT License (MIT)
3
4
  *
@@ -22,8 +23,22 @@
22
23
  * SOFTWARE.
23
24
  */
24
25
 
25
- import { locator } from '@instructure/ui-test-locator';
26
- import { Checkbox } from './index';
27
-
28
- // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
29
- export const CheckboxLocator = locator(Checkbox.selector);
26
+ import React from 'react';
27
+ import { render, screen } from '@testing-library/react';
28
+ import '@testing-library/jest-dom/extend-expect';
29
+ import { runAxeCheck } from '@instructure/ui-axe-check';
30
+ import { ToggleFacade } from '../index';
31
+ const TEST_TEXT = 'test-text';
32
+ describe('<ToggleFacade />', () => {
33
+ it('should render', () => {
34
+ render(_ToggleFacade || (_ToggleFacade = /*#__PURE__*/React.createElement(ToggleFacade, null, TEST_TEXT)));
35
+ const facade = screen.getByText(TEST_TEXT);
36
+ expect(facade).toBeInTheDocument();
37
+ });
38
+ it('should meet a11y standards', async () => {
39
+ const _render = render(_ToggleFacade2 || (_ToggleFacade2 = /*#__PURE__*/React.createElement(ToggleFacade, null, TEST_TEXT))),
40
+ container = _render.container;
41
+ const axeCheck = await runAxeCheck(container);
42
+ expect(axeCheck).toBe(true);
43
+ });
44
+ });
@@ -0,0 +1,210 @@
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 { fireEvent, render, screen, waitFor } from '@testing-library/react';
27
+ import userEvent from '@testing-library/user-event';
28
+ import '@testing-library/jest-dom/extend-expect';
29
+ import { runAxeCheck } from '@instructure/ui-axe-check';
30
+ import { Checkbox } from '../index';
31
+ const TEST_VALUE = 'test-value';
32
+ const TEST_NAME = 'test-name';
33
+ const TEST_LABEL = 'test-label';
34
+ const initProps = {
35
+ label: TEST_LABEL,
36
+ defaultChecked: true,
37
+ value: TEST_VALUE,
38
+ name: TEST_NAME
39
+ };
40
+ const renderCheckbox = props => {
41
+ const allProps = {
42
+ ...initProps,
43
+ ...props
44
+ };
45
+ return render( /*#__PURE__*/React.createElement(Checkbox, allProps));
46
+ };
47
+ describe('<Checkbox />', () => {
48
+ it('renders an input with type "checkbox"', () => {
49
+ renderCheckbox();
50
+ const inputElem = screen.getByRole('checkbox');
51
+ expect(inputElem).toBeInTheDocument();
52
+ expect(inputElem.tagName).toBe('INPUT');
53
+ expect(inputElem).toHaveAttribute('type', 'checkbox');
54
+ });
55
+ it('`simple` variant only displays a checkmark when checked', async () => {
56
+ const _renderCheckbox = renderCheckbox({
57
+ variant: 'simple',
58
+ defaultChecked: false
59
+ }),
60
+ container = _renderCheckbox.container;
61
+ const checkboxElement = container.querySelector('input[type="checkbox"]');
62
+ const svgElement = container.querySelector('svg');
63
+ expect(svgElement).not.toBeInTheDocument();
64
+ userEvent.click(checkboxElement);
65
+ await waitFor(() => {
66
+ const svgElementAfterClick = container.querySelector('svg');
67
+ expect(svgElementAfterClick).toBeInTheDocument();
68
+ });
69
+ });
70
+ it('`simple` variant supports indeterminate/mixed state', () => {
71
+ renderCheckbox({
72
+ variant: 'simple',
73
+ indeterminate: true
74
+ });
75
+ const inputElem = screen.getByRole('checkbox');
76
+ expect(inputElem).toBeInTheDocument();
77
+ expect(inputElem).toHaveAttribute('aria-checked', 'mixed');
78
+ });
79
+ describe('events', () => {
80
+ it('when clicked, fires onClick and onChange events', async () => {
81
+ const onClick = jest.fn();
82
+ const onChange = jest.fn();
83
+ renderCheckbox({
84
+ onClick,
85
+ onChange
86
+ });
87
+ const checkboxElement = screen.getByRole('checkbox');
88
+ userEvent.click(checkboxElement);
89
+ await waitFor(() => {
90
+ expect(onClick).toHaveBeenCalled();
91
+ expect(onChange).toHaveBeenCalled();
92
+ });
93
+ });
94
+ it('when clicked, does not call onClick or onChange when disabled', async () => {
95
+ const onClick = jest.fn();
96
+ const onChange = jest.fn();
97
+ renderCheckbox({
98
+ onClick,
99
+ onChange,
100
+ disabled: true
101
+ });
102
+ const checkboxElement = screen.getByRole('checkbox');
103
+ fireEvent.click(checkboxElement);
104
+ await waitFor(() => {
105
+ expect(onClick).not.toHaveBeenCalled();
106
+ expect(onChange).not.toHaveBeenCalled();
107
+ expect(checkboxElement).toBeDisabled();
108
+ });
109
+ });
110
+ it('when clicked, does not call onClick or onChange when readOnly', async () => {
111
+ const onClick = jest.fn();
112
+ const onChange = jest.fn();
113
+ renderCheckbox({
114
+ onClick,
115
+ onChange,
116
+ readOnly: true
117
+ });
118
+ const checkboxElement = screen.getByRole('checkbox');
119
+ fireEvent.click(checkboxElement);
120
+ await waitFor(() => {
121
+ expect(onClick).not.toHaveBeenCalled();
122
+ expect(onChange).not.toHaveBeenCalled();
123
+ });
124
+ });
125
+ it('calls onChange when enter key is pressed', async () => {
126
+ const onChange = jest.fn();
127
+ renderCheckbox({
128
+ onChange
129
+ });
130
+ const checkboxElement = screen.getByRole('checkbox');
131
+ userEvent.type(checkboxElement, '{enter}');
132
+ await waitFor(() => {
133
+ expect(onChange).toHaveBeenCalled();
134
+ });
135
+ });
136
+ it('responds to onBlur event', async () => {
137
+ const onBlur = jest.fn();
138
+ renderCheckbox({
139
+ onBlur
140
+ });
141
+ userEvent.tab();
142
+ userEvent.tab();
143
+ await waitFor(() => {
144
+ expect(onBlur).toHaveBeenCalled();
145
+ });
146
+ });
147
+ it('responds to onFocus event', async () => {
148
+ const onFocus = jest.fn();
149
+ renderCheckbox({
150
+ onFocus
151
+ });
152
+ userEvent.tab();
153
+ await waitFor(() => {
154
+ expect(onFocus).toHaveBeenCalled();
155
+ });
156
+ });
157
+ it('focuses with the focus helper', () => {
158
+ var _checkboxRef$current;
159
+ const checkboxRef = /*#__PURE__*/React.createRef();
160
+ render( /*#__PURE__*/React.createElement(Checkbox, Object.assign({
161
+ ref: checkboxRef
162
+ }, initProps)));
163
+ const checkboxElement = screen.getByRole('checkbox');
164
+ expect(checkboxElement).not.toHaveFocus();
165
+ (_checkboxRef$current = checkboxRef.current) === null || _checkboxRef$current === void 0 ? void 0 : _checkboxRef$current.focus();
166
+ expect(checkboxElement).toHaveFocus();
167
+ });
168
+ it('calls onMouseOver', async () => {
169
+ const onMouseOver = jest.fn();
170
+ renderCheckbox({
171
+ onMouseOver
172
+ });
173
+ const checkboxElement = screen.getByRole('checkbox');
174
+ userEvent.hover(checkboxElement);
175
+ await waitFor(() => {
176
+ expect(onMouseOver).toHaveBeenCalled();
177
+ });
178
+ });
179
+ it('calls onMouseOut', async () => {
180
+ const onMouseOut = jest.fn();
181
+ renderCheckbox({
182
+ onMouseOut
183
+ });
184
+ const checkboxElement = screen.getByRole('checkbox');
185
+ userEvent.hover(checkboxElement);
186
+ userEvent.unhover(checkboxElement);
187
+ await waitFor(() => {
188
+ expect(onMouseOut).toHaveBeenCalled();
189
+ });
190
+ });
191
+ });
192
+ describe('for a11y', () => {
193
+ it('`simple` variant should meet standards', async () => {
194
+ const _renderCheckbox2 = renderCheckbox({
195
+ variant: 'simple'
196
+ }),
197
+ container = _renderCheckbox2.container;
198
+ const axeCheck = await runAxeCheck(container);
199
+ expect(axeCheck).toBe(true);
200
+ });
201
+ it('`toggle` variant should meet standards', async () => {
202
+ const _renderCheckbox3 = renderCheckbox({
203
+ variant: 'toggle'
204
+ }),
205
+ container = _renderCheckbox3.container;
206
+ const axeCheck = await runAxeCheck(container);
207
+ expect(axeCheck).toBe(true);
208
+ });
209
+ });
210
+ });
@@ -90,7 +90,7 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, n
90
90
  });
91
91
  };
92
92
  this.handleMouseOver = () => {
93
- this.setState({
93
+ !this.props.disabled && this.setState({
94
94
  hovered: true
95
95
  });
96
96
  };
@@ -0,0 +1,196 @@
1
+ var _Checkbox, _Checkbox2;
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 { fireEvent, render, screen, waitFor } from '@testing-library/react';
28
+ import userEvent from '@testing-library/user-event';
29
+ import '@testing-library/jest-dom/extend-expect';
30
+ import { runAxeCheck } from '@instructure/ui-axe-check';
31
+ import { CheckboxGroup } from '../index';
32
+ import { Checkbox } from '../../Checkbox';
33
+ const TEST_NAME = 'test-name';
34
+ const TEST_DESCRIPTION = 'test-description';
35
+ const TEST_ERROR_MESSAGE = 'test-error-message';
36
+ const TEST_VALUE_1 = 'test-value-1';
37
+ const TEST_VALUE_2 = 'test-value-2';
38
+ const TEST_LABEL_1 = 'test-label-1';
39
+ const TEST_LABEL_2 = 'test-label-2';
40
+ const renderCheckboxGroup = props => {
41
+ const allProps = {
42
+ name: TEST_NAME,
43
+ description: TEST_DESCRIPTION,
44
+ ...props
45
+ };
46
+ return render( /*#__PURE__*/React.createElement(CheckboxGroup, allProps, _Checkbox || (_Checkbox = /*#__PURE__*/React.createElement(Checkbox, {
47
+ label: TEST_LABEL_1,
48
+ value: TEST_VALUE_1
49
+ })), _Checkbox2 || (_Checkbox2 = /*#__PURE__*/React.createElement(Checkbox, {
50
+ label: TEST_LABEL_2,
51
+ value: TEST_VALUE_2
52
+ }))));
53
+ };
54
+ describe('<CheckboxGroup />', () => {
55
+ it('adds the name props to all Checkbox types', () => {
56
+ renderCheckboxGroup({
57
+ name: TEST_NAME
58
+ });
59
+ const checkboxes = screen.getAllByRole('checkbox');
60
+ expect(checkboxes.length).toBe(2);
61
+ expect(checkboxes[0]).toHaveAttribute('name', TEST_NAME);
62
+ expect(checkboxes[1]).toHaveAttribute('name', TEST_NAME);
63
+ });
64
+ it('links the messages to the fieldset via aria-describedby', () => {
65
+ const _renderCheckboxGroup = renderCheckboxGroup({
66
+ messages: [{
67
+ text: TEST_ERROR_MESSAGE,
68
+ type: 'error'
69
+ }]
70
+ }),
71
+ container = _renderCheckboxGroup.container;
72
+ const fieldset = screen.getByRole('group');
73
+ const ariaDesc = fieldset.getAttribute('aria-describedby');
74
+ const messageById = container.querySelector(`[id="${ariaDesc}"]`);
75
+ expect(messageById).toBeInTheDocument();
76
+ expect(messageById).toHaveTextContent(TEST_ERROR_MESSAGE);
77
+ });
78
+ it('displays description message inside the legend', () => {
79
+ const _renderCheckboxGroup2 = renderCheckboxGroup({
80
+ description: TEST_DESCRIPTION
81
+ }),
82
+ container = _renderCheckboxGroup2.container;
83
+ const legend = container.querySelector('legend');
84
+ expect(legend).toBeInTheDocument();
85
+ expect(legend).toHaveTextContent(TEST_DESCRIPTION);
86
+ });
87
+ it('does not call the onChange prop when disabled', async () => {
88
+ const onChange = jest.fn();
89
+ renderCheckboxGroup({
90
+ onChange,
91
+ disabled: true
92
+ });
93
+ const checkboxElement = screen.getAllByRole('checkbox')[0];
94
+ fireEvent.click(checkboxElement);
95
+ await waitFor(() => {
96
+ expect(onChange).not.toHaveBeenCalled();
97
+ expect(checkboxElement).toBeDisabled();
98
+ });
99
+ });
100
+ it('does not call the onChange prop when readOnly', async () => {
101
+ const onChange = jest.fn();
102
+ renderCheckboxGroup({
103
+ onChange,
104
+ readOnly: true
105
+ });
106
+ const checkboxElement = screen.getAllByRole('checkbox')[0];
107
+ fireEvent.click(checkboxElement);
108
+ await waitFor(() => {
109
+ expect(onChange).not.toHaveBeenCalled();
110
+ expect(checkboxElement).toBeDisabled();
111
+ });
112
+ });
113
+ it('should not update the value when the value prop is set', async () => {
114
+ const onChange = jest.fn();
115
+ renderCheckboxGroup({
116
+ onChange,
117
+ value: ['tester']
118
+ });
119
+ const checkboxes = screen.getAllByRole('checkbox');
120
+ expect(checkboxes[0]).not.toBeChecked();
121
+ expect(checkboxes[1]).not.toBeChecked();
122
+ userEvent.click(checkboxes[0]);
123
+ await waitFor(() => {
124
+ expect(onChange).not.toHaveBeenCalled();
125
+ expect(checkboxes[0]).not.toBeChecked();
126
+ expect(checkboxes[1]).not.toBeChecked();
127
+ });
128
+ });
129
+ it('should add the checkbox value to the value list when it is checked', async () => {
130
+ const onChange = jest.fn();
131
+ renderCheckboxGroup({
132
+ onChange
133
+ });
134
+ const checkboxes = screen.getAllByRole('checkbox');
135
+ expect(checkboxes[0]).not.toBeChecked();
136
+ expect(checkboxes[1]).not.toBeChecked();
137
+ userEvent.click(checkboxes[0]);
138
+ userEvent.click(checkboxes[1]);
139
+ await waitFor(() => {
140
+ expect(checkboxes[0]).toBeChecked();
141
+ expect(checkboxes[1]).toBeChecked();
142
+ expect(onChange).toHaveBeenCalledWith([TEST_VALUE_1, TEST_VALUE_2]);
143
+ });
144
+ });
145
+ it('should check the checkboxes based on the defaultValue prop', () => {
146
+ const defaultValue = [TEST_VALUE_2];
147
+ renderCheckboxGroup({
148
+ defaultValue
149
+ });
150
+ const checkboxes = screen.getAllByRole('checkbox');
151
+ expect(checkboxes[0]).not.toBeChecked();
152
+ expect(checkboxes[1]).toBeChecked();
153
+ });
154
+ it('should remove the checkbox value from the value list when it is unchecked', async () => {
155
+ const onChange = jest.fn();
156
+ const defaultValue = [TEST_VALUE_1, TEST_VALUE_2];
157
+ renderCheckboxGroup({
158
+ onChange,
159
+ defaultValue
160
+ });
161
+ const checkboxes = screen.getAllByRole('checkbox');
162
+ expect(checkboxes[0]).toBeChecked();
163
+ expect(checkboxes[1]).toBeChecked();
164
+ userEvent.click(checkboxes[0]);
165
+ await waitFor(() => {
166
+ expect(checkboxes[0]).not.toBeChecked();
167
+ expect(checkboxes[1]).toBeChecked();
168
+ expect(onChange).toHaveBeenCalledWith([TEST_VALUE_2]);
169
+ });
170
+ });
171
+ it('passes the array of selected values to onChange handler', async () => {
172
+ const onChange = jest.fn();
173
+ const defaultValue = [TEST_VALUE_2];
174
+ renderCheckboxGroup({
175
+ onChange,
176
+ defaultValue
177
+ });
178
+ const checkboxes = screen.getAllByRole('checkbox');
179
+ expect(checkboxes[0]).not.toBeChecked();
180
+ expect(checkboxes[1]).toBeChecked();
181
+ userEvent.click(checkboxes[0]);
182
+ await waitFor(() => {
183
+ expect(checkboxes[0]).toBeChecked();
184
+ expect(checkboxes[1]).toBeChecked();
185
+ expect(onChange).toHaveBeenCalledWith([TEST_VALUE_2, TEST_VALUE_1]);
186
+ });
187
+ });
188
+ describe('for a11y', () => {
189
+ it('should meet standards', async () => {
190
+ const _renderCheckboxGroup3 = renderCheckboxGroup(),
191
+ container = _renderCheckboxGroup3.container;
192
+ const axeCheck = await runAxeCheck(container);
193
+ expect(axeCheck).toBe(true);
194
+ });
195
+ });
196
+ });
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "CheckboxLocator", {
7
- enumerable: true,
8
- get: function () {
9
- return _CheckboxLocator.CheckboxLocator;
10
- }
11
- });
12
- exports.default = void 0;
13
- var _CheckboxLocator = require("./CheckboxLocator");
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/extend-expect");
7
+ var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
8
+ var _index = require("../index");
9
+ var _CheckboxFacade, _CheckboxFacade2;
14
10
  /*
15
11
  * The MIT License (MIT)
16
12
  *
@@ -34,5 +30,17 @@ var _CheckboxLocator = require("./CheckboxLocator");
34
30
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
31
  * SOFTWARE.
36
32
  */
37
- var _default = _CheckboxLocator.CheckboxLocator;
38
- exports.default = _default;
33
+ const TEST_TEXT = 'test-text';
34
+ describe('<CheckboxFacade />', () => {
35
+ it('should render', () => {
36
+ (0, _react2.render)(_CheckboxFacade || (_CheckboxFacade = /*#__PURE__*/_react.default.createElement(_index.CheckboxFacade, null, TEST_TEXT)));
37
+ const facade = _react2.screen.getByText(TEST_TEXT);
38
+ expect(facade).toBeInTheDocument();
39
+ });
40
+ it('should meet a11y standards', async () => {
41
+ const _render = (0, _react2.render)(_CheckboxFacade2 || (_CheckboxFacade2 = /*#__PURE__*/_react.default.createElement(_index.CheckboxFacade, null, TEST_TEXT))),
42
+ container = _render.container;
43
+ const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
44
+ expect(axeCheck).toBe(true);
45
+ });
46
+ });
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CheckboxLocator = void 0;
7
- var _locator = require("@instructure/ui-test-locator/lib/utils/locator.js");
8
- var _index = require("./index");
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/extend-expect");
7
+ var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
8
+ var _index = require("../index");
9
+ var _ToggleFacade, _ToggleFacade2;
9
10
  /*
10
11
  * The MIT License (MIT)
11
12
  *
@@ -29,7 +30,17 @@ var _index = require("./index");
29
30
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
31
  * SOFTWARE.
31
32
  */
32
-
33
- // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
34
- const CheckboxLocator = (0, _locator.locator)(_index.Checkbox.selector);
35
- exports.CheckboxLocator = CheckboxLocator;
33
+ const TEST_TEXT = 'test-text';
34
+ describe('<ToggleFacade />', () => {
35
+ it('should render', () => {
36
+ (0, _react2.render)(_ToggleFacade || (_ToggleFacade = /*#__PURE__*/_react.default.createElement(_index.ToggleFacade, null, TEST_TEXT)));
37
+ const facade = _react2.screen.getByText(TEST_TEXT);
38
+ expect(facade).toBeInTheDocument();
39
+ });
40
+ it('should meet a11y standards', async () => {
41
+ const _render = (0, _react2.render)(_ToggleFacade2 || (_ToggleFacade2 = /*#__PURE__*/_react.default.createElement(_index.ToggleFacade, null, TEST_TEXT))),
42
+ container = _render.container;
43
+ const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
44
+ expect(axeCheck).toBe(true);
45
+ });
46
+ });