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