@khanacademy/wonder-blocks-form 4.9.1 → 4.9.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/components/checkbox-core.d.ts +2 -2
  3. package/dist/components/checkbox.d.ts +2 -2
  4. package/dist/components/choice-internal.d.ts +2 -2
  5. package/dist/components/choice.d.ts +2 -2
  6. package/dist/components/radio-core.d.ts +2 -2
  7. package/dist/components/radio.d.ts +2 -2
  8. package/dist/components/text-area.d.ts +2 -2
  9. package/dist/components/text-field.d.ts +4 -1
  10. package/dist/es/index.js +31 -78
  11. package/dist/index.js +31 -78
  12. package/package.json +7 -7
  13. package/src/__tests__/__snapshots__/custom-snapshot.test.tsx.snap +0 -247
  14. package/src/__tests__/custom-snapshot.test.tsx +0 -48
  15. package/src/components/__tests__/checkbox-group.test.tsx +0 -162
  16. package/src/components/__tests__/checkbox.test.tsx +0 -138
  17. package/src/components/__tests__/field-heading.test.tsx +0 -225
  18. package/src/components/__tests__/labeled-text-field.test.tsx +0 -727
  19. package/src/components/__tests__/radio-group.test.tsx +0 -182
  20. package/src/components/__tests__/text-area.test.tsx +0 -1286
  21. package/src/components/__tests__/text-field.test.tsx +0 -562
  22. package/src/components/checkbox-core.tsx +0 -239
  23. package/src/components/checkbox-group.tsx +0 -174
  24. package/src/components/checkbox.tsx +0 -99
  25. package/src/components/choice-internal.tsx +0 -184
  26. package/src/components/choice.tsx +0 -157
  27. package/src/components/field-heading.tsx +0 -169
  28. package/src/components/group-styles.ts +0 -33
  29. package/src/components/labeled-text-field.tsx +0 -317
  30. package/src/components/radio-core.tsx +0 -171
  31. package/src/components/radio-group.tsx +0 -159
  32. package/src/components/radio.tsx +0 -82
  33. package/src/components/text-area.tsx +0 -430
  34. package/src/components/text-field.tsx +0 -437
  35. package/src/index.ts +0 -17
  36. package/src/util/types.ts +0 -85
  37. package/tsconfig-build.json +0 -19
  38. package/tsconfig-build.tsbuildinfo +0 -1
@@ -1,247 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`CheckboxCore type:default checked:false 1`] = `
4
- <div>
5
- <input
6
- aria-checked="false"
7
- aria-invalid="false"
8
- class=""
9
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 3px; background-color: rgb(255, 255, 255); border-color: rgba(33,36,44,0.50);"
10
- type="checkbox"
11
- />
12
- </div>
13
- `;
14
-
15
- exports[`CheckboxCore type:default checked:null 1`] = `
16
- <div>
17
- <input
18
- aria-checked="mixed"
19
- aria-invalid="false"
20
- class=""
21
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 0px; border-radius: 3px; background-color: rgb(24, 101, 242);"
22
- type="checkbox"
23
- />
24
- <span
25
- class=""
26
- style="display: inline-block; vertical-align: text-bottom; flex-shrink: 0; flex-grow: 0; mask-size: 100%; mask-repeat: no-repeat; mask-position: center; background-color: rgb(255, 255, 255); width: 12px; height: 12px; mask-image: url(minus-bold.svg); position: absolute; pointer-events: none; margin: 2px;"
27
- />
28
- </div>
29
- `;
30
-
31
- exports[`CheckboxCore type:default checked:true 1`] = `
32
- <div>
33
- <input
34
- aria-checked="true"
35
- aria-invalid="false"
36
- checked=""
37
- class=""
38
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 0px; border-radius: 3px; background-color: rgb(24, 101, 242);"
39
- type="checkbox"
40
- />
41
- <span
42
- class=""
43
- style="display: inline-block; vertical-align: text-bottom; flex-shrink: 0; flex-grow: 0; mask-size: 100%; mask-repeat: no-repeat; mask-position: center; background-color: rgb(255, 255, 255); width: 12px; height: 12px; mask-image: url(check-bold.svg); position: absolute; pointer-events: none; margin: 2px;"
44
- />
45
- </div>
46
- `;
47
-
48
- exports[`CheckboxCore type:disabled checked:false 1`] = `
49
- <div>
50
- <input
51
- aria-checked="false"
52
- aria-invalid="false"
53
- class=""
54
- disabled=""
55
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 3px; cursor: auto; background-color: rgb(247, 248, 250); border-color: rgba(33,36,44,0.16);"
56
- type="checkbox"
57
- />
58
- </div>
59
- `;
60
-
61
- exports[`CheckboxCore type:disabled checked:null 1`] = `
62
- <div>
63
- <input
64
- aria-checked="mixed"
65
- aria-invalid="false"
66
- class=""
67
- disabled=""
68
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 3px; cursor: auto; background-color: rgb(247, 248, 250); border-color: rgba(33,36,44,0.16);"
69
- type="checkbox"
70
- />
71
- <span
72
- class=""
73
- style="display: inline-block; vertical-align: text-bottom; flex-shrink: 0; flex-grow: 0; mask-size: 100%; mask-repeat: no-repeat; mask-position: center; background-color: rgba(33, 36, 44, 0.32); width: 12px; height: 12px; mask-image: url(minus-bold.svg); position: absolute; pointer-events: none; margin: 2px;"
74
- />
75
- </div>
76
- `;
77
-
78
- exports[`CheckboxCore type:disabled checked:true 1`] = `
79
- <div>
80
- <input
81
- aria-checked="true"
82
- aria-invalid="false"
83
- checked=""
84
- class=""
85
- disabled=""
86
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 3px; cursor: auto; background-color: rgb(247, 248, 250); border-color: rgba(33,36,44,0.16);"
87
- type="checkbox"
88
- />
89
- <span
90
- class=""
91
- style="display: inline-block; vertical-align: text-bottom; flex-shrink: 0; flex-grow: 0; mask-size: 100%; mask-repeat: no-repeat; mask-position: center; background-color: rgba(33, 36, 44, 0.32); width: 12px; height: 12px; mask-image: url(check-bold.svg); position: absolute; pointer-events: none; margin: 2px;"
92
- />
93
- </div>
94
- `;
95
-
96
- exports[`CheckboxCore type:error checked:false 1`] = `
97
- <div>
98
- <input
99
- aria-checked="false"
100
- aria-invalid="true"
101
- class=""
102
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 3px; background-color: rgb(252, 238, 236); border-color: #d92916;"
103
- type="checkbox"
104
- />
105
- </div>
106
- `;
107
-
108
- exports[`CheckboxCore type:error checked:null 1`] = `
109
- <div>
110
- <input
111
- aria-checked="mixed"
112
- aria-invalid="true"
113
- class=""
114
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 0px; border-radius: 3px; background-color: rgb(217, 41, 22);"
115
- type="checkbox"
116
- />
117
- <span
118
- class=""
119
- style="display: inline-block; vertical-align: text-bottom; flex-shrink: 0; flex-grow: 0; mask-size: 100%; mask-repeat: no-repeat; mask-position: center; background-color: rgb(255, 255, 255); width: 12px; height: 12px; mask-image: url(minus-bold.svg); position: absolute; pointer-events: none; margin: 2px;"
120
- />
121
- </div>
122
- `;
123
-
124
- exports[`CheckboxCore type:error checked:true 1`] = `
125
- <div>
126
- <input
127
- aria-checked="true"
128
- aria-invalid="true"
129
- checked=""
130
- class=""
131
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 0px; border-radius: 3px; background-color: rgb(217, 41, 22);"
132
- type="checkbox"
133
- />
134
- <span
135
- class=""
136
- style="display: inline-block; vertical-align: text-bottom; flex-shrink: 0; flex-grow: 0; mask-size: 100%; mask-repeat: no-repeat; mask-position: center; background-color: rgb(255, 255, 255); width: 12px; height: 12px; mask-image: url(check-bold.svg); position: absolute; pointer-events: none; margin: 2px;"
137
- />
138
- </div>
139
- `;
140
-
141
- exports[`RadioCore type:default checked:false 1`] = `
142
- <div>
143
- <input
144
- aria-invalid="false"
145
- class=""
146
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 50%; background-color: rgb(255, 255, 255); border-color: rgba(33,36,44,0.50);"
147
- type="radio"
148
- />
149
- </div>
150
- `;
151
-
152
- exports[`RadioCore type:default checked:null 1`] = `
153
- <div>
154
- <input
155
- aria-invalid="false"
156
- class=""
157
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 50%; background-color: rgb(255, 255, 255); border-color: rgba(33,36,44,0.50);"
158
- type="radio"
159
- />
160
- </div>
161
- `;
162
-
163
- exports[`RadioCore type:default checked:true 1`] = `
164
- <div>
165
- <input
166
- aria-invalid="false"
167
- checked=""
168
- class=""
169
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 4px; border-radius: 50%; background-color: rgb(255, 255, 255); border-color: #1865f2;"
170
- type="radio"
171
- />
172
- </div>
173
- `;
174
-
175
- exports[`RadioCore type:disabled checked:false 1`] = `
176
- <div>
177
- <input
178
- aria-invalid="false"
179
- class=""
180
- disabled=""
181
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 50%; cursor: auto; background-color: rgb(247, 248, 250); border-color: rgba(33,36,44,0.16);"
182
- type="radio"
183
- />
184
- </div>
185
- `;
186
-
187
- exports[`RadioCore type:disabled checked:null 1`] = `
188
- <div>
189
- <input
190
- aria-invalid="false"
191
- class=""
192
- disabled=""
193
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 50%; cursor: auto; background-color: rgb(247, 248, 250); border-color: rgba(33,36,44,0.16);"
194
- type="radio"
195
- />
196
- </div>
197
- `;
198
-
199
- exports[`RadioCore type:disabled checked:true 1`] = `
200
- <div>
201
- <input
202
- aria-invalid="false"
203
- checked=""
204
- class=""
205
- disabled=""
206
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 50%; cursor: auto; background-color: rgb(247, 248, 250); border-color: rgba(33,36,44,0.16);"
207
- type="radio"
208
- />
209
- <span
210
- style="position: absolute; top: 4px; left: 4px; height: 8px; width: 8px; border-radius: 50%; background-color: rgba(33, 36, 44, 0.32);"
211
- />
212
- </div>
213
- `;
214
-
215
- exports[`RadioCore type:error checked:false 1`] = `
216
- <div>
217
- <input
218
- aria-invalid="true"
219
- class=""
220
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 50%; background-color: rgb(252, 238, 236); border-color: #d92916;"
221
- type="radio"
222
- />
223
- </div>
224
- `;
225
-
226
- exports[`RadioCore type:error checked:null 1`] = `
227
- <div>
228
- <input
229
- aria-invalid="true"
230
- class=""
231
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 50%; background-color: rgb(252, 238, 236); border-color: #d92916;"
232
- type="radio"
233
- />
234
- </div>
235
- `;
236
-
237
- exports[`RadioCore type:error checked:true 1`] = `
238
- <div>
239
- <input
240
- aria-invalid="true"
241
- checked=""
242
- class=""
243
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 4px; border-radius: 50%; background-color: rgb(255, 255, 255); border-color: #d92916;"
244
- type="radio"
245
- />
246
- </div>
247
- `;
@@ -1,48 +0,0 @@
1
- import * as React from "react";
2
- import {render} from "@testing-library/react";
3
-
4
- import CheckboxCore from "../components/checkbox-core";
5
- import RadioCore from "../components/radio-core";
6
-
7
- const states = ["default", "error", "disabled"];
8
- const checkedStates = [false, true, null];
9
-
10
- describe("CheckboxCore", () => {
11
- states.forEach((state: any) => {
12
- checkedStates.forEach((checked: any) => {
13
- test(`type:${state} checked:${String(checked)}`, () => {
14
- const disabled = state === "disabled";
15
- const {container} = render(
16
- <CheckboxCore
17
- checked={checked}
18
- disabled={disabled}
19
- error={state === "error"}
20
- onClick={() => {}}
21
- />,
22
- );
23
-
24
- expect(container).toMatchSnapshot();
25
- });
26
- });
27
- });
28
- });
29
-
30
- describe("RadioCore", () => {
31
- states.forEach((state: any) => {
32
- checkedStates.forEach((checked: any) => {
33
- test(`type:${state} checked:${String(checked)}`, () => {
34
- const disabled = state === "disabled";
35
- const {container} = render(
36
- <RadioCore
37
- checked={checked}
38
- disabled={disabled}
39
- error={state === "error"}
40
- onClick={() => {}}
41
- />,
42
- );
43
-
44
- expect(container).toMatchSnapshot();
45
- });
46
- });
47
- });
48
- });
@@ -1,162 +0,0 @@
1
- import * as React from "react";
2
- import {render, screen} from "@testing-library/react";
3
- import {userEvent} from "@testing-library/user-event";
4
-
5
- import CheckboxGroup from "../checkbox-group";
6
- import Choice from "../choice";
7
-
8
- describe("CheckboxGroup", () => {
9
- describe("behavior", () => {
10
- const TestComponent = ({errorMessage}: {errorMessage?: string}) => {
11
- const [selectedValues, setSelectedValue] = React.useState([
12
- "a",
13
- "b",
14
- ]);
15
- const handleChange = (selectedValues: any) => {
16
- setSelectedValue(selectedValues);
17
- };
18
- return (
19
- <CheckboxGroup
20
- label="Test"
21
- description="test description"
22
- groupName="test"
23
- onChange={handleChange}
24
- selectedValues={selectedValues}
25
- errorMessage={errorMessage}
26
- >
27
- <Choice label="a" value="a" aria-labelledby="test-a" />
28
- <Choice label="b" value="b" aria-labelledby="test-b" />
29
- <Choice label="c" value="c" aria-labelledby="test-c" />
30
- </CheckboxGroup>
31
- );
32
- };
33
-
34
- it("has the correct items checked", async () => {
35
- // Arrange, Act
36
- render(<TestComponent />);
37
-
38
- const checkboxes = screen.getAllByRole("checkbox");
39
-
40
- // Assert
41
- // a starts off checked
42
- expect(checkboxes[0]).toBeChecked();
43
- expect(checkboxes[1]).toBeChecked();
44
- expect(checkboxes[2]).not.toBeChecked();
45
- });
46
-
47
- it("clicking a selected choice deselects it", async () => {
48
- // Arrange
49
- render(<TestComponent />);
50
-
51
- const checkboxes = screen.getAllByRole("checkbox");
52
-
53
- // Act
54
- await userEvent.click(checkboxes[0]);
55
-
56
- // Assert
57
- expect(checkboxes[0]).not.toBeChecked();
58
- expect(checkboxes[1]).toBeChecked();
59
- expect(checkboxes[2]).not.toBeChecked();
60
- });
61
-
62
- it("should set aria-invalid on choices when there's an error message", async () => {
63
- // Arrange, Act
64
- render(<TestComponent errorMessage="there's an error" />);
65
-
66
- const checkboxes = screen.getAllByRole("checkbox");
67
-
68
- // Assert
69
- expect(checkboxes[0]).toHaveAttribute("aria-invalid", "true");
70
- expect(checkboxes[1]).toHaveAttribute("aria-invalid", "true");
71
- expect(checkboxes[2]).toHaveAttribute("aria-invalid", "true");
72
- });
73
-
74
- it("checks that aria attributes have been added correctly", async () => {
75
- // Arrange, Act
76
- render(<TestComponent />);
77
-
78
- const checkboxes = screen.getAllByRole("checkbox");
79
-
80
- // Assert
81
- expect(checkboxes[0]).toHaveAttribute("aria-labelledby", "test-a");
82
- expect(checkboxes[1]).toHaveAttribute("aria-labelledby", "test-b");
83
- expect(checkboxes[2]).toHaveAttribute("aria-labelledby", "test-c");
84
- });
85
- });
86
-
87
- describe("flexible props", () => {
88
- it("should render with a React.Node label", async () => {
89
- // Arrange, Act
90
- render(
91
- <CheckboxGroup
92
- label={
93
- <span>
94
- label with <strong>strong</strong> text
95
- </span>
96
- }
97
- groupName="test"
98
- onChange={() => {}}
99
- selectedValues={[]}
100
- >
101
- <Choice label="a" value="a" aria-labelledby="test-a" />
102
- <Choice label="b" value="b" aria-labelledby="test-b" />
103
- <Choice label="c" value="c" aria-labelledby="test-c" />
104
- </CheckboxGroup>,
105
- );
106
-
107
- // Assert
108
- expect(await screen.findByText("strong")).toBeInTheDocument();
109
- });
110
-
111
- it("should render with a React.Node description", async () => {
112
- // Arrange, Act
113
- render(
114
- <CheckboxGroup
115
- label="label"
116
- description={
117
- <span>
118
- description with <strong>strong</strong> text
119
- </span>
120
- }
121
- groupName="test"
122
- onChange={() => {}}
123
- selectedValues={[]}
124
- >
125
- <Choice label="a" value="a" aria-labelledby="test-a" />
126
- <Choice label="b" value="b" aria-labelledby="test-b" />
127
- <Choice label="c" value="c" aria-labelledby="test-c" />
128
- </CheckboxGroup>,
129
- );
130
-
131
- // Assert
132
- expect(await screen.findByText("strong")).toBeInTheDocument();
133
- });
134
-
135
- it("should filter out false-y children when rendering", async () => {
136
- // Arrange, Act
137
- render(
138
- <CheckboxGroup
139
- label="label"
140
- description="description"
141
- groupName="test"
142
- onChange={() => {}}
143
- selectedValues={[]}
144
- >
145
- <Choice label="a" value="a" aria-labelledby="test-a" />
146
- {/* eslint-disable-next-line no-constant-condition */}
147
- {false ? (
148
- <Choice label="b" value="b" aria-labelledby="test-b" />
149
- ) : null}
150
- <Choice label="c" value="c" aria-labelledby="test-c" />
151
- {undefined}
152
- {null}
153
- </CheckboxGroup>,
154
- );
155
-
156
- // Assert
157
- const checkboxes = screen.getAllByRole("checkbox");
158
-
159
- expect(checkboxes).toHaveLength(2);
160
- });
161
- });
162
- });
@@ -1,138 +0,0 @@
1
- import * as React from "react";
2
- import {render, screen} from "@testing-library/react";
3
-
4
- import Checkbox from "../checkbox";
5
-
6
- describe("Checkbox", () => {
7
- test("uses the ID prop when it is specified", () => {
8
- // Arrange, Act
9
- render(
10
- <Checkbox
11
- id="specified-checkbox-id"
12
- label="Receive assignment reminders for Algebra"
13
- description="You will receive a reminder 24 hours before each deadline"
14
- checked={false}
15
- onChange={() => {}}
16
- />,
17
- );
18
-
19
- const checkbox = screen.getByRole("checkbox");
20
-
21
- // Assert
22
- expect(checkbox).toHaveAttribute("id", "specified-checkbox-id");
23
- });
24
-
25
- test("provides a unique ID when the ID prop is not specified", () => {
26
- // Arrange, Act
27
- render(
28
- <Checkbox
29
- label="Receive assignment reminders for Algebra"
30
- description="You will receive a reminder 24 hours before each deadline"
31
- checked={false}
32
- onChange={() => {}}
33
- />,
34
- );
35
-
36
- const checkbox = screen.getByRole("checkbox");
37
-
38
- // Assert
39
- expect(checkbox).toHaveAttribute("id", "uid-choice-1-main");
40
- });
41
-
42
- test("clicking the checkbox triggers `onChange`", () => {
43
- // Arrange
44
- const onChangeSpy = jest.fn();
45
- render(
46
- <Checkbox
47
- label="Receive assignment reminders for Algebra"
48
- description="You will receive a reminder 24 hours before each deadline"
49
- checked={false}
50
- onChange={onChangeSpy}
51
- />,
52
- );
53
-
54
- // Act
55
- const checkbox = screen.getByRole("checkbox");
56
- checkbox.click();
57
-
58
- // Assert
59
- expect(onChangeSpy).toHaveBeenCalled();
60
- });
61
-
62
- test("clicks the label triggers `onChange`", () => {
63
- // Arrange
64
- const onChangeSpy = jest.fn();
65
- render(
66
- <Checkbox
67
- label="Receive assignment reminders for Algebra"
68
- description="You will receive a reminder 24 hours before each deadline"
69
- checked={false}
70
- onChange={onChangeSpy}
71
- />,
72
- );
73
-
74
- // Act
75
- const checkboxLabel = screen.getByText(
76
- "Receive assignment reminders for Algebra",
77
- );
78
- checkboxLabel.click();
79
-
80
- // Assert
81
- expect(onChangeSpy).toHaveBeenCalled();
82
- });
83
-
84
- test.each`
85
- indeterminateValue | checkedValue
86
- ${true} | ${null}
87
- ${false} | ${true}
88
- ${false} | ${false}
89
- `(
90
- "sets the indeterminate property to $indeterminateValue when checked is $checkedValue (with ref)",
91
- ({indeterminateValue, checkedValue}) => {
92
- // Arrange
93
- const ref = React.createRef<HTMLInputElement>();
94
-
95
- // Act
96
- render(
97
- <Checkbox
98
- label="Some label"
99
- description="Some description"
100
- checked={checkedValue}
101
- onChange={() => {}}
102
- ref={ref}
103
- />,
104
- );
105
-
106
- // Assert
107
- expect(ref?.current?.indeterminate).toBe(indeterminateValue);
108
- },
109
- );
110
-
111
- test.each`
112
- indeterminateValue | checkedValue
113
- ${true} | ${null}
114
- ${false} | ${true}
115
- ${false} | ${false}
116
- `(
117
- "sets the indeterminate property to $indeterminateValue when checked is $checkedValue (innerRef)",
118
- ({indeterminateValue, checkedValue}) => {
119
- // Arrange
120
- render(
121
- <Checkbox
122
- label="Some label"
123
- description="Some description"
124
- checked={checkedValue}
125
- onChange={() => {}}
126
- />,
127
- );
128
-
129
- // Act
130
- const inputElement = screen.getByRole(
131
- "checkbox",
132
- ) as HTMLInputElement;
133
-
134
- // Assert
135
- expect(inputElement.indeterminate).toBe(indeterminateValue);
136
- },
137
- );
138
- });