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