@dxc-technology/halstack-react 0.0.0-9bd9511 → 0.0.0-9c20370
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/BackgroundColorContext.d.ts +3 -3
- package/BackgroundColorContext.js +12 -2
- package/HalstackContext.d.ts +1330 -7
- package/HalstackContext.js +84 -67
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +74 -55
- package/accordion/Accordion.stories.tsx +3 -101
- package/accordion/Accordion.test.js +34 -19
- package/accordion/types.d.ts +4 -16
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +49 -42
- package/accordion-group/AccordionGroup.stories.tsx +77 -76
- package/accordion-group/AccordionGroup.test.js +62 -54
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +43 -0
- package/accordion-group/types.d.ts +6 -18
- package/alert/Alert.js +47 -20
- package/alert/Alert.test.js +46 -29
- package/alert/types.d.ts +3 -3
- package/badge/Badge.js +14 -2
- package/badge/types.d.ts +1 -1
- package/bleed/Bleed.js +21 -13
- package/bleed/Bleed.stories.tsx +1 -0
- package/bleed/types.d.ts +2 -2
- package/box/Box.d.ts +1 -1
- package/box/Box.js +33 -33
- package/box/Box.stories.tsx +25 -53
- package/box/Box.test.js +7 -2
- package/box/types.d.ts +3 -15
- package/bulleted-list/BulletedList.js +36 -9
- package/bulleted-list/BulletedList.stories.tsx +7 -1
- package/bulleted-list/types.d.ts +32 -5
- package/button/Button.d.ts +1 -1
- package/button/Button.js +83 -71
- package/button/Button.stories.tsx +4 -4
- package/button/Button.test.js +28 -8
- package/button/types.d.ts +8 -4
- package/card/Card.d.ts +1 -1
- package/card/Card.js +67 -62
- package/card/Card.stories.tsx +12 -42
- package/card/Card.test.js +22 -11
- package/card/types.d.ts +4 -10
- package/checkbox/Checkbox.js +71 -27
- package/checkbox/Checkbox.test.js +60 -33
- package/checkbox/types.d.ts +4 -4
- package/chip/Chip.js +51 -48
- package/chip/Chip.stories.tsx +25 -17
- package/chip/Chip.test.js +29 -17
- package/chip/types.d.ts +4 -4
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +146 -0
- package/common/coreTokens.js +167 -0
- package/common/utils.d.ts +1 -0
- package/common/utils.js +8 -3
- package/common/variables.d.ts +226 -175
- package/common/variables.js +956 -1133
- package/date-input/Calendar.js +55 -12
- package/date-input/DateInput.js +82 -35
- package/date-input/DateInput.test.js +351 -164
- package/date-input/DatePicker.js +38 -8
- package/date-input/Icons.js +12 -0
- package/date-input/YearPicker.js +30 -5
- package/date-input/types.d.ts +7 -7
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +83 -86
- package/dialog/Dialog.stories.tsx +127 -221
- package/dialog/Dialog.test.js +331 -18
- package/dialog/types.d.ts +1 -14
- package/dropdown/Dropdown.js +86 -32
- package/dropdown/Dropdown.test.js +211 -104
- package/dropdown/DropdownMenu.js +22 -8
- package/dropdown/DropdownMenuItem.js +15 -6
- package/dropdown/types.d.ts +8 -8
- package/file-input/FileInput.js +218 -134
- package/file-input/FileInput.test.js +343 -331
- package/file-input/FileItem.js +39 -12
- package/file-input/types.d.ts +10 -10
- package/flex/Flex.js +39 -25
- package/flex/Flex.stories.tsx +35 -26
- package/flex/types.d.ts +74 -9
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +80 -68
- package/footer/Footer.stories.tsx +12 -89
- package/footer/Footer.test.js +47 -40
- package/footer/Icons.js +4 -0
- package/footer/types.d.ts +15 -17
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +91 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/header/Header.d.ts +4 -3
- package/header/Header.js +72 -55
- package/header/Header.stories.tsx +7 -71
- package/header/Header.test.js +26 -13
- package/header/Icons.js +4 -0
- package/header/types.d.ts +2 -16
- package/heading/Heading.js +28 -7
- package/heading/Heading.test.js +88 -71
- package/heading/types.d.ts +3 -3
- package/inset/Inset.js +21 -13
- package/inset/Inset.stories.tsx +2 -1
- package/inset/types.d.ts +2 -2
- package/layout/ApplicationLayout.d.ts +5 -5
- package/layout/ApplicationLayout.js +57 -15
- package/layout/Icons.js +10 -0
- package/layout/SidenavContext.d.ts +1 -1
- package/layout/SidenavContext.js +4 -0
- package/layout/types.d.ts +5 -6
- package/link/Link.js +41 -21
- package/link/Link.test.js +42 -26
- package/link/types.d.ts +4 -4
- package/main.d.ts +2 -1
- package/main.js +55 -0
- package/nav-tabs/NavTabs.d.ts +2 -2
- package/nav-tabs/NavTabs.js +43 -16
- package/nav-tabs/NavTabs.stories.tsx +14 -0
- package/nav-tabs/NavTabs.test.js +44 -37
- package/nav-tabs/Tab.js +71 -45
- package/nav-tabs/types.d.ts +10 -11
- package/number-input/NumberInput.js +30 -20
- package/number-input/NumberInput.test.js +249 -113
- package/number-input/NumberInputContext.js +5 -0
- package/number-input/numberInputContextTypes.d.ts +1 -1
- package/number-input/types.d.ts +4 -4
- package/package.json +7 -7
- package/paginator/Icons.js +10 -0
- package/paginator/Paginator.js +39 -17
- package/paginator/Paginator.test.js +156 -104
- package/paginator/types.d.ts +1 -1
- package/paragraph/Paragraph.d.ts +3 -4
- package/paragraph/Paragraph.js +18 -8
- package/password-input/PasswordInput.js +51 -22
- package/password-input/PasswordInput.test.js +94 -51
- package/password-input/types.d.ts +4 -4
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +39 -14
- package/progress-bar/ProgressBar.test.js +53 -36
- package/progress-bar/types.d.ts +4 -3
- package/quick-nav/QuickNav.js +24 -2
- package/quick-nav/types.d.ts +2 -2
- package/radio-group/Radio.js +53 -22
- package/radio-group/RadioGroup.js +84 -41
- package/radio-group/RadioGroup.test.js +288 -186
- package/radio-group/types.d.ts +4 -4
- package/resultsetTable/Icons.js +3 -0
- package/resultsetTable/ResultsetTable.js +56 -21
- package/resultsetTable/ResultsetTable.test.js +75 -42
- package/resultsetTable/types.d.ts +5 -5
- package/select/Icons.js +3 -0
- package/select/Listbox.js +35 -10
- package/select/Option.js +24 -8
- package/select/Select.js +143 -56
- package/select/Select.test.js +839 -456
- package/select/types.d.ts +12 -12
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +51 -0
- package/sidenav/Sidenav.d.ts +2 -2
- package/sidenav/Sidenav.js +116 -104
- package/sidenav/Sidenav.stories.tsx +60 -60
- package/sidenav/Sidenav.test.js +10 -3
- package/sidenav/types.d.ts +26 -23
- package/slider/Slider.js +84 -38
- package/slider/Slider.test.js +104 -76
- package/slider/types.d.ts +4 -4
- package/spinner/Spinner.js +51 -28
- package/spinner/Spinner.stories.jsx +28 -28
- package/spinner/Spinner.test.js +35 -26
- package/spinner/types.d.ts +3 -3
- package/switch/Switch.js +66 -24
- package/switch/Switch.test.js +97 -52
- package/switch/types.d.ts +4 -4
- package/table/Table.js +22 -4
- package/table/Table.test.js +7 -2
- package/table/types.d.ts +3 -3
- package/tabs/Tab.js +39 -22
- package/tabs/Tabs.js +131 -62
- package/tabs/Tabs.test.js +122 -67
- package/tabs/types.d.ts +8 -8
- package/tag/Tag.js +54 -27
- package/tag/Tag.test.js +31 -20
- package/tag/types.d.ts +7 -7
- package/text-input/Icons.js +3 -0
- package/text-input/Suggestion.js +24 -8
- package/text-input/Suggestions.js +36 -11
- package/text-input/TextInput.js +144 -59
- package/text-input/TextInput.stories.tsx +1 -1
- package/text-input/TextInput.test.js +858 -539
- package/text-input/types.d.ts +9 -9
- package/textarea/Textarea.js +73 -38
- package/textarea/Textarea.test.js +173 -98
- package/textarea/types.d.ts +4 -4
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +59 -21
- package/toggle-group/ToggleGroup.test.js +72 -40
- package/toggle-group/types.d.ts +11 -11
- package/typography/Typography.d.ts +2 -2
- package/typography/Typography.js +23 -110
- package/typography/Typography.stories.tsx +1 -1
- package/typography/types.d.ts +1 -1
- package/useTheme.d.ts +1234 -1
- package/useTheme.js +6 -0
- package/useTranslatedLabels.d.ts +84 -2
- package/useTranslatedLabels.js +5 -0
- package/utils/BaseTypography.d.ts +21 -0
- package/utils/BaseTypography.js +108 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +138 -0
- package/wizard/Wizard.js +47 -13
- package/wizard/Wizard.test.js +81 -54
- package/wizard/types.d.ts +7 -8
- package/card/ice-cream.jpg +0 -0
- package/translatedLabelsType.d.ts +0 -82
- /package/{translatedLabelsType.js → grid/types.js} +0 -0
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
5
7
|
var _react2 = require("@testing-library/react");
|
|
8
|
+
|
|
6
9
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
10
|
+
|
|
7
11
|
var _RadioGroup = _interopRequireDefault(require("./RadioGroup.tsx"));
|
|
12
|
+
|
|
8
13
|
var options = [{
|
|
9
14
|
label: "Option 01",
|
|
10
15
|
value: "1"
|
|
@@ -47,14 +52,15 @@ var singleDisabledOptions = [{
|
|
|
47
52
|
describe("Radio Group component tests", function () {
|
|
48
53
|
test("Initial render has correct aria attributes and tabIndex", function () {
|
|
49
54
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
label: "test-radioGroup-label",
|
|
56
|
+
options: options,
|
|
57
|
+
error: ""
|
|
58
|
+
})),
|
|
59
|
+
getByRole = _render.getByRole,
|
|
60
|
+
getAllByRole = _render.getAllByRole,
|
|
61
|
+
getByText = _render.getByText,
|
|
62
|
+
container = _render.container;
|
|
63
|
+
|
|
58
64
|
var radioGroup = getByRole("radiogroup");
|
|
59
65
|
var radios = getAllByRole("radio");
|
|
60
66
|
var errorId = "error-".concat(getByText("test-radioGroup-label").id.replace("label-", ""));
|
|
@@ -67,7 +73,7 @@ describe("Radio Group component tests", function () {
|
|
|
67
73
|
expect(error.getAttribute("aria-live")).toBe("off");
|
|
68
74
|
radios.forEach(function (radio, index) {
|
|
69
75
|
// if no option was previously selected, first option is the focusable one
|
|
70
|
-
index === 0
|
|
76
|
+
if (index === 0) expect(radio.tabIndex).toBe(0);else expect(radio.tabIndex).toBe(-1);
|
|
71
77
|
expect(radio.getAttribute("aria-checked")).toBe("false");
|
|
72
78
|
expect(radio.getAttribute("aria-disabled")).toBe("false");
|
|
73
79
|
expect(radio.getAttribute("aria-labelledby")).toBe(getByText("Option 0".concat(index + 1)).id);
|
|
@@ -75,11 +81,12 @@ describe("Radio Group component tests", function () {
|
|
|
75
81
|
});
|
|
76
82
|
test("aria-orientation attribute changes depending on stacking prop value", function () {
|
|
77
83
|
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
label: "test-radioGroup-label",
|
|
85
|
+
options: options,
|
|
86
|
+
stacking: "row"
|
|
87
|
+
})),
|
|
88
|
+
getByRole = _render2.getByRole;
|
|
89
|
+
|
|
83
90
|
var radioGroup = getByRole("radiogroup");
|
|
84
91
|
expect(radioGroup.getAttribute("aria-orientation")).toBe("horizontal");
|
|
85
92
|
});
|
|
@@ -92,86 +99,100 @@ describe("Radio Group component tests", function () {
|
|
|
92
99
|
radiogroup: "5"
|
|
93
100
|
});
|
|
94
101
|
});
|
|
102
|
+
|
|
95
103
|
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement("form", {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
onSubmit: handlerOnSubmit
|
|
105
|
+
}, /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
106
|
+
name: "radiogroup",
|
|
107
|
+
label: "test-radio-group-label",
|
|
108
|
+
options: options
|
|
109
|
+
}), /*#__PURE__*/_react["default"].createElement("button", {
|
|
110
|
+
type: "submit"
|
|
111
|
+
}, "Submit"))),
|
|
112
|
+
getByText = _render3.getByText,
|
|
113
|
+
getByRole = _render3.getByRole,
|
|
114
|
+
getAllByRole = _render3.getAllByRole;
|
|
115
|
+
|
|
107
116
|
var radioGroup = getByRole("radiogroup");
|
|
108
117
|
var submit = getByText("Submit");
|
|
118
|
+
|
|
109
119
|
_userEvent["default"].click(radioGroup);
|
|
120
|
+
|
|
110
121
|
_userEvent["default"].click(getAllByRole("radio")[4]);
|
|
122
|
+
|
|
111
123
|
_userEvent["default"].click(submit);
|
|
112
124
|
});
|
|
113
125
|
test("Disabled state renders with correct aria attribute, correct tabIndex values and it is not focusable by keyboard", function () {
|
|
114
126
|
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
127
|
+
label: "test-radioGroup-label",
|
|
128
|
+
options: options,
|
|
129
|
+
disabled: true
|
|
130
|
+
})),
|
|
131
|
+
getByRole = _render4.getByRole,
|
|
132
|
+
getAllByRole = _render4.getAllByRole;
|
|
133
|
+
|
|
121
134
|
var radioGroup = getByRole("radiogroup");
|
|
122
135
|
var radios = getAllByRole("radio");
|
|
123
136
|
expect(radioGroup.getAttribute("aria-disabled")).toBe("true");
|
|
124
137
|
radios.forEach(function (radio) {
|
|
125
138
|
expect(radio.tabIndex).toBe(-1);
|
|
126
139
|
});
|
|
140
|
+
|
|
127
141
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
128
142
|
key: " ",
|
|
129
143
|
code: "Space",
|
|
130
144
|
keyCode: 13,
|
|
131
145
|
charCode: 13
|
|
132
146
|
});
|
|
147
|
+
|
|
133
148
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
134
149
|
key: "ArrowLeft",
|
|
135
150
|
code: "ArrowLeft",
|
|
136
151
|
keyCode: 37,
|
|
137
152
|
charCode: 37
|
|
138
153
|
});
|
|
154
|
+
|
|
139
155
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
140
156
|
key: "ArrowDown",
|
|
141
157
|
code: "ArrowDown",
|
|
142
158
|
keyCode: 40,
|
|
143
159
|
charCode: 40
|
|
144
160
|
});
|
|
161
|
+
|
|
145
162
|
radios.forEach(function (radio) {
|
|
146
163
|
expect(radio.tabIndex).toBe(-1);
|
|
147
164
|
});
|
|
148
165
|
});
|
|
149
166
|
test("Disabled option renders with correct aria attribute, correct tabIndex value and it is not focusable by keyboard (focus 'jumps' the disabled option)", function () {
|
|
150
167
|
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
168
|
+
name: "test",
|
|
169
|
+
label: "test-radioGroup-label",
|
|
170
|
+
options: singleDisabledOptions
|
|
171
|
+
})),
|
|
172
|
+
getByRole = _render5.getByRole,
|
|
173
|
+
getAllByRole = _render5.getAllByRole;
|
|
174
|
+
|
|
157
175
|
var radioGroup = getByRole("radiogroup");
|
|
158
176
|
var radios = getAllByRole("radio");
|
|
159
177
|
expect(radios[2].getAttribute("aria-disabled")).toBe("true");
|
|
160
178
|
expect(radios[0].tabIndex).toBe(0);
|
|
161
179
|
expect(radios[1].tabIndex).toBe(-1);
|
|
162
180
|
expect(radios[2].tabIndex).toBe(-1);
|
|
181
|
+
|
|
163
182
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
164
183
|
key: "ArrowDown",
|
|
165
184
|
code: "ArrowDown",
|
|
166
185
|
keyCode: 40,
|
|
167
186
|
charCode: 40
|
|
168
187
|
});
|
|
188
|
+
|
|
169
189
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
170
190
|
key: "ArrowDown",
|
|
171
191
|
code: "ArrowDown",
|
|
172
192
|
keyCode: 40,
|
|
173
193
|
charCode: 40
|
|
174
194
|
});
|
|
195
|
+
|
|
175
196
|
expect(radios[0].tabIndex).toBe(0);
|
|
176
197
|
expect(radios[1].tabIndex).toBe(-1);
|
|
177
198
|
expect(radios[2].tabIndex).toBe(-1);
|
|
@@ -183,29 +204,33 @@ describe("Radio Group component tests", function () {
|
|
|
183
204
|
var formProps = Object.fromEntries(formData);
|
|
184
205
|
expect(formProps).toStrictEqual({});
|
|
185
206
|
});
|
|
207
|
+
|
|
186
208
|
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement("form", {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
209
|
+
onSubmit: handlerOnSubmit
|
|
210
|
+
}, /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
211
|
+
name: "radiogroup",
|
|
212
|
+
defaultValue: "1",
|
|
213
|
+
disabled: true,
|
|
214
|
+
label: "test-radio-group-label",
|
|
215
|
+
options: options
|
|
216
|
+
}), /*#__PURE__*/_react["default"].createElement("button", {
|
|
217
|
+
type: "submit"
|
|
218
|
+
}, "Submit"))),
|
|
219
|
+
getByText = _render6.getByText;
|
|
220
|
+
|
|
198
221
|
var submit = getByText("Submit");
|
|
222
|
+
|
|
199
223
|
_userEvent["default"].click(submit);
|
|
200
224
|
});
|
|
201
225
|
test("Error state renders with correct aria attributes", function () {
|
|
202
226
|
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
227
|
+
label: "test-radioGroup-label",
|
|
228
|
+
options: options,
|
|
229
|
+
error: "Error message"
|
|
230
|
+
})),
|
|
231
|
+
getByRole = _render7.getByRole,
|
|
232
|
+
getByText = _render7.getByText;
|
|
233
|
+
|
|
209
234
|
var radioGroup = getByRole("radiogroup");
|
|
210
235
|
var errorMessage = getByText("Error message");
|
|
211
236
|
expect(radioGroup.getAttribute("aria-errormessage")).toBe(errorMessage.id);
|
|
@@ -215,24 +240,33 @@ describe("Radio Group component tests", function () {
|
|
|
215
240
|
test("Radio group with required constraint and 'undefined' as value, sends an error", function () {
|
|
216
241
|
var onChange = jest.fn();
|
|
217
242
|
var onBlur = jest.fn();
|
|
243
|
+
|
|
218
244
|
var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
245
|
+
label: "test-radioGroup-label",
|
|
246
|
+
options: options,
|
|
247
|
+
onChange: onChange,
|
|
248
|
+
onBlur: onBlur
|
|
249
|
+
})),
|
|
250
|
+
getByRole = _render8.getByRole,
|
|
251
|
+
getAllByRole = _render8.getAllByRole;
|
|
252
|
+
|
|
226
253
|
var radioGroup = getByRole("radiogroup");
|
|
227
254
|
expect(radioGroup.getAttribute("aria-required")).toBe("true");
|
|
255
|
+
|
|
228
256
|
_react2.fireEvent.blur(radioGroup);
|
|
257
|
+
|
|
229
258
|
expect(onBlur).toHaveBeenCalledWith({
|
|
230
259
|
error: "This field is required. Please, choose an option."
|
|
231
260
|
});
|
|
261
|
+
|
|
232
262
|
_userEvent["default"].click(radioGroup);
|
|
263
|
+
|
|
233
264
|
_userEvent["default"].click(getAllByRole("radio")[0]);
|
|
265
|
+
|
|
234
266
|
expect(onChange).toHaveBeenCalledWith("1");
|
|
267
|
+
|
|
235
268
|
_react2.fireEvent.blur(radioGroup);
|
|
269
|
+
|
|
236
270
|
expect(onBlur).toHaveBeenCalledWith({
|
|
237
271
|
value: "1"
|
|
238
272
|
});
|
|
@@ -240,37 +274,45 @@ describe("Radio Group component tests", function () {
|
|
|
240
274
|
test("Radio group with required constraint and empty string as value, sends an error", function () {
|
|
241
275
|
var onChange = jest.fn();
|
|
242
276
|
var onBlur = jest.fn();
|
|
277
|
+
|
|
243
278
|
var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
279
|
+
label: "test-radioGroup-label",
|
|
280
|
+
value: "",
|
|
281
|
+
options: options,
|
|
282
|
+
onChange: onChange,
|
|
283
|
+
onBlur: onBlur
|
|
284
|
+
})),
|
|
285
|
+
getByRole = _render9.getByRole,
|
|
286
|
+
getAllByRole = _render9.getAllByRole;
|
|
287
|
+
|
|
252
288
|
var radioGroup = getByRole("radiogroup");
|
|
253
289
|
expect(radioGroup.getAttribute("aria-required")).toBe("true");
|
|
290
|
+
|
|
254
291
|
_react2.fireEvent.blur(radioGroup);
|
|
292
|
+
|
|
255
293
|
expect(onBlur).toHaveBeenCalledWith({
|
|
256
294
|
value: "",
|
|
257
295
|
error: "This field is required. Please, choose an option."
|
|
258
296
|
});
|
|
297
|
+
|
|
259
298
|
_userEvent["default"].click(getAllByRole("radio")[0]);
|
|
299
|
+
|
|
260
300
|
expect(onChange).toHaveBeenCalledWith("1");
|
|
261
301
|
});
|
|
262
302
|
test("The 'defaultValue' gives the radio group an initial value when it is uncontrolled", function () {
|
|
263
303
|
var onChange = jest.fn();
|
|
304
|
+
|
|
264
305
|
var _render10 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
306
|
+
defaultValue: "2",
|
|
307
|
+
name: "test",
|
|
308
|
+
label: "test-radio-group-label",
|
|
309
|
+
helperText: "test-radio-group-helper-text",
|
|
310
|
+
options: options,
|
|
311
|
+
onChange: onChange
|
|
312
|
+
})),
|
|
313
|
+
getAllByRole = _render10.getAllByRole,
|
|
314
|
+
container = _render10.container;
|
|
315
|
+
|
|
274
316
|
var radio = getAllByRole("radio")[1];
|
|
275
317
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
276
318
|
expect(radio.tabIndex).toBe(0);
|
|
@@ -280,75 +322,91 @@ describe("Radio Group component tests", function () {
|
|
|
280
322
|
test("Optional radio group conditions: onBlur event doesn't send an error when no radio was checked, has correct aria attributes, custom label and its value is the empty string", function () {
|
|
281
323
|
var onChange = jest.fn();
|
|
282
324
|
var onBlur = jest.fn();
|
|
325
|
+
|
|
283
326
|
var _render11 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
327
|
+
name: "test",
|
|
328
|
+
label: "test-radio-group-label",
|
|
329
|
+
helperText: "test-radio-group-helper-text",
|
|
330
|
+
options: options,
|
|
331
|
+
onChange: onChange,
|
|
332
|
+
onBlur: onBlur,
|
|
333
|
+
optional: true,
|
|
334
|
+
optionalItemLabel: "No selection"
|
|
335
|
+
})),
|
|
336
|
+
getByRole = _render11.getByRole,
|
|
337
|
+
getByText = _render11.getByText,
|
|
338
|
+
container = _render11.container;
|
|
339
|
+
|
|
296
340
|
var radioGroup = getByRole("radiogroup");
|
|
297
341
|
expect(radioGroup.getAttribute("aria-required")).toBe("false");
|
|
342
|
+
|
|
298
343
|
_react2.fireEvent.blur(radioGroup);
|
|
344
|
+
|
|
299
345
|
expect(onBlur).toHaveBeenCalledWith({});
|
|
300
346
|
expect(radioGroup.getAttribute("aria-invalid")).toBe("false");
|
|
301
347
|
var optionalLabel = getByText("No selection");
|
|
302
348
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
349
|
+
|
|
303
350
|
_userEvent["default"].click(optionalLabel);
|
|
351
|
+
|
|
304
352
|
expect(onChange).toHaveBeenCalledWith("");
|
|
305
353
|
expect(submitInput.value).toBe("");
|
|
306
354
|
});
|
|
307
355
|
test("Controlled radio group", function () {
|
|
308
356
|
var onChange = jest.fn();
|
|
309
357
|
var onBlur = jest.fn();
|
|
358
|
+
|
|
310
359
|
var _render12 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
360
|
+
name: "test",
|
|
361
|
+
value: "2",
|
|
362
|
+
label: "test-radio-group-label",
|
|
363
|
+
helperText: "test-radio-group-helper-text",
|
|
364
|
+
options: options,
|
|
365
|
+
onChange: onChange,
|
|
366
|
+
onBlur: onBlur
|
|
367
|
+
})),
|
|
368
|
+
getByRole = _render12.getByRole,
|
|
369
|
+
getAllByRole = _render12.getAllByRole,
|
|
370
|
+
container = _render12.container;
|
|
371
|
+
|
|
322
372
|
var radioGroup = getByRole("radiogroup");
|
|
323
373
|
var radios = getAllByRole("radio");
|
|
324
374
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
325
375
|
expect(submitInput.value).toBe("2");
|
|
326
376
|
expect(radios[1].tabIndex).toBe(0);
|
|
327
377
|
expect(radios[1].getAttribute("aria-checked")).toBe("true");
|
|
378
|
+
|
|
328
379
|
_userEvent["default"].click(radios[6]);
|
|
380
|
+
|
|
329
381
|
expect(onChange).toHaveBeenCalledWith("7");
|
|
382
|
+
|
|
330
383
|
_react2.fireEvent.blur(radioGroup);
|
|
384
|
+
|
|
331
385
|
expect(onBlur).toHaveBeenCalledWith({
|
|
332
386
|
value: "2"
|
|
333
387
|
});
|
|
334
388
|
});
|
|
335
389
|
test("Select an option by clicking on its label", function () {
|
|
336
390
|
var onChange = jest.fn();
|
|
391
|
+
|
|
337
392
|
var _render13 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
393
|
+
name: "test",
|
|
394
|
+
label: "test-radio-group-label",
|
|
395
|
+
helperText: "test-radio-group-helper-text",
|
|
396
|
+
options: options,
|
|
397
|
+
onChange: onChange
|
|
398
|
+
})),
|
|
399
|
+
getByText = _render13.getByText,
|
|
400
|
+
getAllByRole = _render13.getAllByRole,
|
|
401
|
+
container = _render13.container;
|
|
402
|
+
|
|
347
403
|
var radioLabel = getByText("Option 09");
|
|
348
404
|
var checkedRadio = getAllByRole("radio")[8];
|
|
349
405
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
350
406
|
expect(checkedRadio.tabIndex).toBe(-1);
|
|
407
|
+
|
|
351
408
|
_userEvent["default"].click(radioLabel);
|
|
409
|
+
|
|
352
410
|
expect(onChange).toHaveBeenCalledWith("9");
|
|
353
411
|
expect(checkedRadio.getAttribute("aria-checked")).toBe("true");
|
|
354
412
|
expect(checkedRadio.tabIndex).toBe(0);
|
|
@@ -357,19 +415,23 @@ describe("Radio Group component tests", function () {
|
|
|
357
415
|
});
|
|
358
416
|
test("Select an option by clicking on its radio input", function () {
|
|
359
417
|
var onChange = jest.fn();
|
|
418
|
+
|
|
360
419
|
var _render14 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
420
|
+
name: "test",
|
|
421
|
+
label: "test-radio-group-label",
|
|
422
|
+
helperText: "test-radio-group-helper-text",
|
|
423
|
+
options: options,
|
|
424
|
+
onChange: onChange
|
|
425
|
+
})),
|
|
426
|
+
getAllByRole = _render14.getAllByRole,
|
|
427
|
+
container = _render14.container;
|
|
428
|
+
|
|
369
429
|
var checkedRadio = getAllByRole("radio")[6];
|
|
370
430
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
371
431
|
expect(checkedRadio.tabIndex).toBe(-1);
|
|
432
|
+
|
|
372
433
|
_userEvent["default"].click(checkedRadio);
|
|
434
|
+
|
|
373
435
|
expect(onChange).toHaveBeenCalledWith("7");
|
|
374
436
|
expect(checkedRadio.getAttribute("aria-checked")).toBe("true");
|
|
375
437
|
expect(checkedRadio.tabIndex).toBe(0);
|
|
@@ -378,43 +440,51 @@ describe("Radio Group component tests", function () {
|
|
|
378
440
|
});
|
|
379
441
|
test("Select an option that is already checked does not call onChange event but gives the focus", function () {
|
|
380
442
|
var onChange = jest.fn();
|
|
443
|
+
|
|
381
444
|
var _render15 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
445
|
+
defaultValue: "2",
|
|
446
|
+
name: "test",
|
|
447
|
+
label: "test-radio-group-label",
|
|
448
|
+
helperText: "test-radio-group-helper-text",
|
|
449
|
+
options: options,
|
|
450
|
+
onChange: onChange
|
|
451
|
+
})),
|
|
452
|
+
getAllByRole = _render15.getAllByRole;
|
|
453
|
+
|
|
390
454
|
var checkedRadio = getAllByRole("radio")[1];
|
|
391
455
|
expect(checkedRadio.tabIndex).toBe(0);
|
|
392
456
|
expect(checkedRadio.getAttribute("aria-checked")).toBe("true");
|
|
457
|
+
|
|
393
458
|
_userEvent["default"].click(checkedRadio);
|
|
459
|
+
|
|
394
460
|
expect(onChange).not.toHaveBeenCalled();
|
|
395
461
|
expect(document.activeElement).toEqual(checkedRadio);
|
|
396
462
|
});
|
|
397
463
|
test("The 'space' key checks the current focused option if anyone is checked", function () {
|
|
398
464
|
var onChange = jest.fn();
|
|
465
|
+
|
|
399
466
|
var _render16 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
467
|
+
name: "test",
|
|
468
|
+
label: "test-radio-group-label",
|
|
469
|
+
helperText: "test-radio-group-helper-text",
|
|
470
|
+
options: options,
|
|
471
|
+
onChange: onChange
|
|
472
|
+
})),
|
|
473
|
+
getByRole = _render16.getByRole,
|
|
474
|
+
getAllByRole = _render16.getAllByRole,
|
|
475
|
+
container = _render16.container;
|
|
476
|
+
|
|
409
477
|
var radioGroup = getByRole("radiogroup");
|
|
410
478
|
var checkedRadio = getAllByRole("radio")[0];
|
|
411
479
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
480
|
+
|
|
412
481
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
413
482
|
key: " ",
|
|
414
483
|
code: "Space",
|
|
415
484
|
keyCode: 32,
|
|
416
485
|
charCode: 32
|
|
417
486
|
});
|
|
487
|
+
|
|
418
488
|
expect(onChange).toHaveBeenCalledWith("1");
|
|
419
489
|
expect(checkedRadio.getAttribute("aria-checked")).toBe("true");
|
|
420
490
|
expect(checkedRadio.tabIndex).toBe(0);
|
|
@@ -423,33 +493,39 @@ describe("Radio Group component tests", function () {
|
|
|
423
493
|
test("When the radio group gains the focus by keyboard ('tab' key), it goes to the first option (if no one was previously selected), without selecting it", function () {
|
|
424
494
|
var onChange = jest.fn();
|
|
425
495
|
var onBlur = jest.fn();
|
|
496
|
+
|
|
426
497
|
var _render17 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
498
|
+
name: "test",
|
|
499
|
+
label: "test-radio-group-label",
|
|
500
|
+
helperText: "test-radio-group-helper-text",
|
|
501
|
+
options: options,
|
|
502
|
+
onChange: onChange,
|
|
503
|
+
onBlur: onBlur
|
|
504
|
+
})),
|
|
505
|
+
getByRole = _render17.getByRole,
|
|
506
|
+
getAllByRole = _render17.getAllByRole,
|
|
507
|
+
container = _render17.container;
|
|
508
|
+
|
|
437
509
|
var radioGroup = getByRole("radiogroup");
|
|
438
510
|
var radios = getAllByRole("radio");
|
|
439
511
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
440
512
|
var checkedRadio = getAllByRole("radio")[0];
|
|
513
|
+
|
|
441
514
|
_userEvent["default"].tab();
|
|
515
|
+
|
|
442
516
|
expect(onChange).not.toHaveBeenCalled();
|
|
443
517
|
expect(submitInput.value).toBe("");
|
|
444
518
|
expect(checkedRadio.tabIndex).toBe(0);
|
|
445
519
|
expect(checkedRadio.getAttribute("aria-checked")).toBe("false");
|
|
446
520
|
expect(document.activeElement).toEqual(checkedRadio);
|
|
521
|
+
|
|
447
522
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
448
523
|
key: "ArrowRight",
|
|
449
524
|
code: "ArrowRight",
|
|
450
525
|
keyCode: 39,
|
|
451
526
|
charCode: 39
|
|
452
527
|
});
|
|
528
|
+
|
|
453
529
|
expect(onBlur).not.toHaveBeenCalled();
|
|
454
530
|
expect(onChange).toHaveBeenCalledTimes(1);
|
|
455
531
|
expect(radios[1].getAttribute("aria-checked")).toBe("true");
|
|
@@ -460,39 +536,45 @@ describe("Radio Group component tests", function () {
|
|
|
460
536
|
test("The 'arrowDown' and 'arrowRight' keys move the selection to the next radio. When the last radio is reached, moves the selection to the first one", function () {
|
|
461
537
|
var onChange = jest.fn();
|
|
462
538
|
var onBlur = jest.fn();
|
|
539
|
+
|
|
463
540
|
var _render18 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
541
|
+
defaultValue: "8",
|
|
542
|
+
name: "test",
|
|
543
|
+
label: "test-radio-group-label",
|
|
544
|
+
helperText: "test-radio-group-helper-text",
|
|
545
|
+
options: options,
|
|
546
|
+
onChange: onChange,
|
|
547
|
+
onBlur: onBlur
|
|
548
|
+
})),
|
|
549
|
+
getByRole = _render18.getByRole,
|
|
550
|
+
getAllByRole = _render18.getAllByRole,
|
|
551
|
+
container = _render18.container;
|
|
552
|
+
|
|
475
553
|
var radioGroup = getByRole("radiogroup");
|
|
476
554
|
var radios = getAllByRole("radio");
|
|
477
555
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
556
|
+
|
|
478
557
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
479
558
|
key: "ArrowDown",
|
|
480
559
|
code: "ArrowDown",
|
|
481
560
|
keyCode: 40,
|
|
482
561
|
charCode: 40
|
|
483
562
|
});
|
|
563
|
+
|
|
484
564
|
expect(onBlur).not.toHaveBeenCalled();
|
|
485
565
|
expect(onChange).toHaveBeenCalledTimes(1);
|
|
486
566
|
expect(radios[8].getAttribute("aria-checked")).toBe("true");
|
|
487
567
|
expect(document.activeElement).toEqual(radios[8]);
|
|
488
568
|
expect(radios[8].tabIndex).toBe(0);
|
|
489
569
|
expect(submitInput.value).toBe("9");
|
|
570
|
+
|
|
490
571
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
491
572
|
key: "ArrowRight",
|
|
492
573
|
code: "ArrowRight",
|
|
493
574
|
keyCode: 39,
|
|
494
575
|
charCode: 39
|
|
495
576
|
});
|
|
577
|
+
|
|
496
578
|
expect(onBlur).not.toHaveBeenCalled();
|
|
497
579
|
expect(onChange).toHaveBeenCalledTimes(2);
|
|
498
580
|
expect(radios[0].getAttribute("aria-checked")).toBe("true");
|
|
@@ -503,39 +585,45 @@ describe("Radio Group component tests", function () {
|
|
|
503
585
|
test("The 'arrowUp' and 'arrowLeft' keys move the selection to the previous radio. When the first radio is reached, moves the selection to the last one", function () {
|
|
504
586
|
var onChange = jest.fn();
|
|
505
587
|
var onBlur = jest.fn();
|
|
588
|
+
|
|
506
589
|
var _render19 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
590
|
+
defaultValue: "2",
|
|
591
|
+
name: "test",
|
|
592
|
+
label: "test-radio-group-label",
|
|
593
|
+
helperText: "test-radio-group-helper-text",
|
|
594
|
+
options: options,
|
|
595
|
+
onChange: onChange,
|
|
596
|
+
onBlur: onBlur
|
|
597
|
+
})),
|
|
598
|
+
getByRole = _render19.getByRole,
|
|
599
|
+
getAllByRole = _render19.getAllByRole,
|
|
600
|
+
container = _render19.container;
|
|
601
|
+
|
|
518
602
|
var radioGroup = getByRole("radiogroup");
|
|
519
603
|
var radios = getAllByRole("radio");
|
|
520
604
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
605
|
+
|
|
521
606
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
522
607
|
key: "ArrowUp",
|
|
523
608
|
code: "ArrowUp",
|
|
524
609
|
keyCode: 38,
|
|
525
610
|
charCode: 38
|
|
526
611
|
});
|
|
612
|
+
|
|
527
613
|
expect(onBlur).not.toHaveBeenCalled();
|
|
528
614
|
expect(onChange).toHaveBeenCalledTimes(1);
|
|
529
615
|
expect(radios[0].getAttribute("aria-checked")).toBe("true");
|
|
530
616
|
expect(document.activeElement).toEqual(radios[0]);
|
|
531
617
|
expect(radios[0].tabIndex).toBe(0);
|
|
532
618
|
expect(submitInput.value).toBe("1");
|
|
619
|
+
|
|
533
620
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
534
621
|
key: "ArrowLeft",
|
|
535
622
|
code: "ArrowLeft",
|
|
536
623
|
keyCode: 37,
|
|
537
624
|
charCode: 37
|
|
538
625
|
});
|
|
626
|
+
|
|
539
627
|
expect(onBlur).not.toHaveBeenCalled();
|
|
540
628
|
expect(onChange).toHaveBeenCalledTimes(2);
|
|
541
629
|
expect(radios[8].getAttribute("aria-checked")).toBe("true");
|
|
@@ -545,38 +633,46 @@ describe("Radio Group component tests", function () {
|
|
|
545
633
|
});
|
|
546
634
|
test("Keyboard focus movement continues from the last radio input clicked", function () {
|
|
547
635
|
var onChange = jest.fn();
|
|
636
|
+
|
|
548
637
|
var _render20 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
638
|
+
name: "test",
|
|
639
|
+
label: "test-radio-group-label",
|
|
640
|
+
helperText: "test-radio-group-helper-text",
|
|
641
|
+
options: options,
|
|
642
|
+
onChange: onChange
|
|
643
|
+
})),
|
|
644
|
+
getByRole = _render20.getByRole,
|
|
645
|
+
getAllByRole = _render20.getAllByRole,
|
|
646
|
+
container = _render20.container;
|
|
647
|
+
|
|
558
648
|
var radioGroup = getByRole("radiogroup");
|
|
559
649
|
var radios = getAllByRole("radio");
|
|
560
650
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
651
|
+
|
|
561
652
|
_userEvent["default"].click(radios[3]);
|
|
653
|
+
|
|
562
654
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
563
655
|
key: "ArrowDown",
|
|
564
656
|
code: "ArrowDown",
|
|
565
657
|
keyCode: 40,
|
|
566
658
|
charCode: 40
|
|
567
659
|
});
|
|
660
|
+
|
|
568
661
|
expect(onChange).toHaveBeenCalledWith("5");
|
|
569
662
|
expect(radios[4].getAttribute("aria-checked")).toBe("true");
|
|
570
663
|
expect(document.activeElement).toEqual(radios[4]);
|
|
571
664
|
expect(radios[4].tabIndex).toBe(0);
|
|
572
665
|
expect(submitInput.value).toBe("5");
|
|
666
|
+
|
|
573
667
|
_userEvent["default"].click(radios[8]);
|
|
668
|
+
|
|
574
669
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
575
670
|
key: "ArrowLeft",
|
|
576
671
|
code: "ArrowLeft",
|
|
577
672
|
keyCode: 37,
|
|
578
673
|
charCode: 37
|
|
579
674
|
});
|
|
675
|
+
|
|
580
676
|
expect(onChange).toHaveBeenCalledWith("8");
|
|
581
677
|
expect(radios[7].getAttribute("aria-checked")).toBe("true");
|
|
582
678
|
expect(document.activeElement).toEqual(radios[7]);
|
|
@@ -585,32 +681,38 @@ describe("Radio Group component tests", function () {
|
|
|
585
681
|
});
|
|
586
682
|
test("Readonly radio group lets the user move the focus, but neither click nor keyboard press changes the value", function () {
|
|
587
683
|
var onChange = jest.fn();
|
|
684
|
+
|
|
588
685
|
var _render21 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
686
|
+
name: "test",
|
|
687
|
+
label: "test-radio-group-label",
|
|
688
|
+
helperText: "test-radio-group-helper-text",
|
|
689
|
+
options: options,
|
|
690
|
+
onChange: onChange,
|
|
691
|
+
readonly: true
|
|
692
|
+
})),
|
|
693
|
+
getByRole = _render21.getByRole,
|
|
694
|
+
getAllByRole = _render21.getAllByRole,
|
|
695
|
+
container = _render21.container;
|
|
696
|
+
|
|
599
697
|
var radioGroup = getByRole("radiogroup");
|
|
600
698
|
var radios = getAllByRole("radio");
|
|
601
699
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
700
|
+
|
|
602
701
|
_userEvent["default"].click(radios[5]);
|
|
702
|
+
|
|
603
703
|
expect(onChange).not.toHaveBeenCalled();
|
|
604
704
|
expect(radios[5].getAttribute("aria-checked")).toBe("false");
|
|
605
705
|
expect(document.activeElement).toEqual(radios[5]);
|
|
606
706
|
expect(radios[5].tabIndex).toBe(0);
|
|
607
707
|
expect(submitInput.value).toBe("");
|
|
708
|
+
|
|
608
709
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
609
710
|
key: "ArrowUp",
|
|
610
711
|
code: "ArrowUp",
|
|
611
712
|
keyCode: 38,
|
|
612
713
|
charCode: 38
|
|
613
714
|
});
|
|
715
|
+
|
|
614
716
|
expect(onChange).not.toHaveBeenCalled();
|
|
615
717
|
expect(radios[4].getAttribute("aria-checked")).toBe("false");
|
|
616
718
|
expect(document.activeElement).toEqual(radios[4]);
|