@dxc-technology/halstack-react 0.0.0-d3554d7 → 0.0.0-d3624d0
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 +1246 -0
- package/HalstackContext.js +310 -0
- 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 -181
- package/accordion/Accordion.stories.tsx +83 -149
- package/accordion/Accordion.test.js +32 -33
- package/accordion/types.d.ts +10 -17
- package/accordion-group/AccordionGroup.accessibility.test.js +88 -0
- package/accordion-group/AccordionGroup.d.ts +3 -3
- package/accordion-group/AccordionGroup.js +38 -107
- package/accordion-group/AccordionGroup.stories.tsx +95 -68
- package/accordion-group/AccordionGroup.test.js +55 -90
- 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 +16 -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 +40 -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 -40
- package/badge/Badge.stories.tsx +210 -0
- package/badge/Badge.test.js +30 -0
- package/badge/types.d.ts +52 -2
- package/bleed/Bleed.js +14 -55
- package/bleed/Bleed.stories.tsx +95 -95
- package/bleed/types.d.ts +26 -2
- package/box/Box.accessibility.test.js +33 -0
- package/box/Box.d.ts +1 -1
- package/box/Box.js +30 -81
- 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.d.ts +7 -0
- package/bulleted-list/BulletedList.js +92 -0
- package/bulleted-list/BulletedList.stories.tsx +115 -0
- package/bulleted-list/types.d.ts +38 -0
- package/button/Button.accessibility.test.js +127 -0
- package/button/Button.d.ts +1 -1
- package/button/Button.js +63 -113
- 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 +59 -102
- 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 +143 -181
- package/checkbox/Checkbox.stories.tsx +166 -136
- package/checkbox/Checkbox.test.js +163 -29
- package/checkbox/types.d.ts +18 -6
- 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 +1081 -1190
- 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 +170 -306
- package/date-input/DateInput.stories.tsx +210 -56
- package/date-input/DateInput.test.js +708 -369
- 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 +86 -22
- package/dialog/Dialog.accessibility.test.js +69 -0
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +56 -129
- 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 -307
- 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 +246 -393
- package/file-input/FileInput.stories.tsx +123 -12
- package/file-input/FileInput.test.js +292 -367
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +61 -120
- 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/flex/types.js +5 -0
- package/footer/Footer.accessibility.test.js +125 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +73 -191
- 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 +104 -218
- package/header/Header.stories.tsx +168 -63
- package/header/Header.test.js +31 -28
- 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 +14 -55
- package/inset/Inset.stories.tsx +37 -36
- package/inset/types.d.ts +26 -2
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +88 -182
- package/layout/ApplicationLayout.stories.tsx +85 -94
- package/layout/Icons.d.ts +7 -0
- package/layout/Icons.js +41 -48
- package/layout/types.d.ts +19 -35
- package/link/Link.accessibility.test.js +108 -0
- package/link/Link.d.ts +3 -2
- package/link/Link.js +65 -101
- package/link/Link.stories.tsx +157 -55
- package/link/Link.test.js +25 -53
- package/link/types.d.ts +15 -31
- package/main.d.ts +17 -13
- package/main.js +86 -101
- package/nav-tabs/NavTabs.accessibility.test.js +44 -0
- package/nav-tabs/NavTabs.d.ts +7 -0
- package/nav-tabs/NavTabs.js +93 -0
- 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.d.ts +4 -0
- package/nav-tabs/Tab.js +117 -0
- package/nav-tabs/types.d.ts +52 -0
- package/nav-tabs/types.js +5 -0
- package/number-input/NumberInput.accessibility.test.js +228 -0
- package/number-input/NumberInput.js +47 -44
- package/number-input/NumberInput.stories.tsx +44 -28
- package/number-input/NumberInput.test.js +862 -381
- package/number-input/NumberInputContext.d.ts +3 -4
- package/number-input/NumberInputContext.js +3 -14
- package/number-input/types.d.ts +34 -15
- package/package.json +54 -53
- package/paginator/Paginator.accessibility.test.js +79 -0
- package/paginator/Paginator.js +46 -100
- 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 +5 -0
- package/paragraph/Paragraph.js +22 -0
- package/paragraph/Paragraph.stories.tsx +27 -0
- package/password-input/PasswordInput.accessibility.test.js +153 -0
- package/password-input/PasswordInput.js +58 -124
- package/password-input/PasswordInput.stories.tsx +1 -33
- package/password-input/PasswordInput.test.js +162 -147
- package/password-input/types.d.ts +21 -17
- package/progress-bar/ProgressBar.accessibility.test.js +35 -0
- package/progress-bar/ProgressBar.js +68 -92
- package/progress-bar/ProgressBar.stories.tsx +93 -0
- 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.d.ts +4 -0
- package/quick-nav/QuickNav.js +94 -0
- package/quick-nav/QuickNav.stories.tsx +356 -0
- package/quick-nav/types.d.ts +21 -0
- package/quick-nav/types.js +5 -0
- 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 +73 -116
- package/radio-group/RadioGroup.stories.tsx +135 -17
- package/radio-group/RadioGroup.test.js +529 -467
- package/radio-group/types.d.ts +86 -9
- 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 +4 -0
- package/select/Listbox.js +155 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +89 -0
- package/select/Select.accessibility.test.js +228 -0
- package/select/Select.js +237 -504
- package/select/Select.stories.tsx +533 -196
- package/select/Select.test.js +1953 -1588
- package/select/types.d.ts +65 -26
- package/sidenav/Sidenav.accessibility.test.js +59 -0
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +136 -71
- package/sidenav/Sidenav.stories.tsx +246 -151
- package/sidenav/Sidenav.test.js +26 -45
- package/sidenav/SidenavContext.d.ts +5 -0
- package/sidenav/SidenavContext.js +13 -0
- 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 -180
- package/slider/Slider.test.js +198 -73
- package/slider/types.d.ts +11 -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 +149 -114
- package/switch/Switch.stories.tsx +56 -67
- package/switch/Switch.test.js +146 -39
- package/switch/types.d.ts +13 -5
- 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.d.ts +1 -1
- package/tabs/Tabs.js +305 -145
- package/tabs/Tabs.stories.tsx +124 -14
- package/tabs/Tabs.test.js +220 -67
- package/tabs/types.d.ts +31 -17
- package/tag/Tag.accessibility.test.js +69 -0
- package/tag/Tag.js +42 -79
- package/tag/Tag.stories.tsx +24 -10
- package/tag/Tag.test.js +18 -37
- package/tag/types.d.ts +9 -9
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +67 -0
- 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 +332 -557
- package/text-input/TextInput.stories.tsx +282 -282
- package/text-input/TextInput.test.js +1442 -1377
- package/text-input/types.d.ts +70 -24
- package/textarea/Textarea.accessibility.test.js +155 -0
- package/textarea/Textarea.js +83 -134
- package/textarea/Textarea.stories.tsx +174 -0
- package/textarea/Textarea.test.js +168 -198
- package/textarea/types.d.ts +27 -16
- package/toggle-group/ToggleGroup.accessibility.test.js +107 -0
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +94 -106
- package/toggle-group/ToggleGroup.stories.tsx +56 -11
- package/toggle-group/ToggleGroup.test.js +78 -66
- package/toggle-group/types.d.ts +36 -19
- package/typography/Typography.accessibility.test.js +339 -0
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +23 -0
- package/typography/Typography.stories.tsx +198 -0
- package/typography/types.d.ts +18 -0
- package/typography/types.js +5 -0
- package/useTheme.d.ts +1144 -1
- package/useTheme.js +4 -11
- package/useTranslatedLabels.d.ts +85 -0
- package/useTranslatedLabels.js +14 -0
- 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.d.ts +1 -1
- package/wizard/Wizard.js +78 -120
- package/wizard/Wizard.stories.tsx +67 -19
- package/wizard/Wizard.test.js +73 -87
- package/wizard/types.d.ts +14 -10
- package/ThemeContext.d.ts +0 -10
- package/ThemeContext.js +0 -243
- 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/list/List.d.ts +0 -4
- package/list/List.js +0 -47
- package/list/List.stories.tsx +0 -95
- package/list/types.d.ts +0 -7
- package/number-input/numberInputContextTypes.d.ts +0 -19
- package/paginator/Icons.js +0 -66
- package/progress-bar/ProgressBar.stories.jsx +0 -58
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -174
- package/radio/Radio.stories.tsx +0 -192
- package/radio/Radio.test.js +0 -71
- package/radio/types.d.ts +0 -54
- 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 -10
- package/slider/Slider.stories.tsx +0 -177
- 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 -9
- package/table/Table.stories.jsx +0 -277
- package/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
- package/textarea/Textarea.stories.jsx +0 -157
- /package/{list → action-icon}/types.js +0 -0
- /package/{radio → breadcrumbs}/types.js +0 -0
- /package/{resultsetTable → bulleted-list}/types.js +0 -0
- /package/{row → container}/types.js +0 -0
- /package/{stack → contextual-menu}/types.js +0 -0
- /package/{number-input/numberInputContextTypes.js → divider/types.js} +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,409 +49,457 @@ 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
|
-
|
|
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;
|
|
62
60
|
var radioGroup = getByRole("radiogroup");
|
|
63
61
|
var radios = getAllByRole("radio");
|
|
62
|
+
var errorId = "error-".concat(getByText("test-radioGroup-label").id.replace("label-", ""));
|
|
63
|
+
var error = container.querySelector("#".concat(errorId));
|
|
64
64
|
expect(radioGroup.getAttribute("aria-disabled")).toBe("false");
|
|
65
65
|
expect(radioGroup.getAttribute("aria-labelledby")).toBe(getByText("test-radioGroup-label").id);
|
|
66
66
|
expect(radioGroup.getAttribute("aria-invalid")).toBe("false");
|
|
67
67
|
expect(radioGroup.getAttribute("aria-required")).toBe("true");
|
|
68
|
+
expect(radioGroup.getAttribute("aria-orientation")).toBe("vertical");
|
|
69
|
+
expect(error.getAttribute("aria-live")).toBe("off");
|
|
68
70
|
radios.forEach(function (radio, index) {
|
|
69
71
|
// if no option was previously selected, first option is the focusable one
|
|
70
|
-
index === 0
|
|
72
|
+
if (index === 0) expect(radio.tabIndex).toBe(0);else expect(radio.tabIndex).toBe(-1);
|
|
71
73
|
expect(radio.getAttribute("aria-checked")).toBe("false");
|
|
72
74
|
expect(radio.getAttribute("aria-disabled")).toBe("false");
|
|
73
75
|
expect(radio.getAttribute("aria-labelledby")).toBe(getByText("Option 0".concat(index + 1)).id);
|
|
74
76
|
});
|
|
75
77
|
});
|
|
76
|
-
test("
|
|
78
|
+
test("aria-orientation attribute changes depending on stacking prop value", function () {
|
|
77
79
|
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
label: "test-radioGroup-label",
|
|
81
|
+
options: options,
|
|
82
|
+
stacking: "row"
|
|
83
|
+
})),
|
|
84
|
+
getByRole = _render2.getByRole;
|
|
85
|
+
var radioGroup = getByRole("radiogroup");
|
|
86
|
+
expect(radioGroup.getAttribute("aria-orientation")).toBe("horizontal");
|
|
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
|
+
})));
|
|
126
|
+
test("Disabled state renders with correct aria attribute, correct tabIndex values and it is not focusable by keyboard", function () {
|
|
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;
|
|
85
134
|
var radioGroup = getByRole("radiogroup");
|
|
86
135
|
var radios = getAllByRole("radio");
|
|
87
136
|
expect(radioGroup.getAttribute("aria-disabled")).toBe("true");
|
|
88
137
|
radios.forEach(function (radio) {
|
|
89
138
|
expect(radio.tabIndex).toBe(-1);
|
|
90
139
|
});
|
|
91
|
-
|
|
92
140
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
93
|
-
key: "
|
|
94
|
-
code: "
|
|
141
|
+
key: " ",
|
|
142
|
+
code: "Space",
|
|
95
143
|
keyCode: 13,
|
|
96
144
|
charCode: 13
|
|
97
145
|
});
|
|
98
|
-
|
|
99
146
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
100
147
|
key: "ArrowLeft",
|
|
101
148
|
code: "ArrowLeft",
|
|
102
149
|
keyCode: 37,
|
|
103
150
|
charCode: 37
|
|
104
151
|
});
|
|
105
|
-
|
|
106
152
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
107
153
|
key: "ArrowDown",
|
|
108
154
|
code: "ArrowDown",
|
|
109
155
|
keyCode: 40,
|
|
110
156
|
charCode: 40
|
|
111
157
|
});
|
|
112
|
-
|
|
113
158
|
radios.forEach(function (radio) {
|
|
114
159
|
expect(radio.tabIndex).toBe(-1);
|
|
115
160
|
});
|
|
116
161
|
});
|
|
117
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 () {
|
|
118
|
-
var
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
container = _render3.container;
|
|
126
|
-
|
|
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;
|
|
127
170
|
var radioGroup = getByRole("radiogroup");
|
|
128
171
|
var radios = getAllByRole("radio");
|
|
129
172
|
expect(radios[2].getAttribute("aria-disabled")).toBe("true");
|
|
130
173
|
expect(radios[0].tabIndex).toBe(0);
|
|
131
174
|
expect(radios[1].tabIndex).toBe(-1);
|
|
132
175
|
expect(radios[2].tabIndex).toBe(-1);
|
|
133
|
-
|
|
134
176
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
135
177
|
key: "ArrowDown",
|
|
136
178
|
code: "ArrowDown",
|
|
137
179
|
keyCode: 40,
|
|
138
180
|
charCode: 40
|
|
139
181
|
});
|
|
140
|
-
|
|
141
182
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
142
183
|
key: "ArrowDown",
|
|
143
184
|
code: "ArrowDown",
|
|
144
185
|
keyCode: 40,
|
|
145
186
|
charCode: 40
|
|
146
187
|
});
|
|
147
|
-
|
|
148
188
|
expect(radios[0].tabIndex).toBe(0);
|
|
149
189
|
expect(radios[1].tabIndex).toBe(-1);
|
|
150
190
|
expect(radios[2].tabIndex).toBe(-1);
|
|
151
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
|
+
})));
|
|
152
223
|
test("Error state renders with correct aria attributes", function () {
|
|
153
|
-
var
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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;
|
|
161
231
|
var radioGroup = getByRole("radiogroup");
|
|
162
232
|
var errorMessage = getByText("Error message");
|
|
163
233
|
expect(radioGroup.getAttribute("aria-errormessage")).toBe(errorMessage.id);
|
|
164
234
|
expect(radioGroup.getAttribute("aria-invalid")).toBe("true");
|
|
165
235
|
expect(errorMessage.getAttribute("aria-live")).toBe("assertive");
|
|
166
236
|
});
|
|
167
|
-
test("Radio group with required constraint and 'undefined' as value, sends an error", function () {
|
|
168
|
-
var onChange
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
-
});
|
|
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
|
+
})));
|
|
234
304
|
test("The 'defaultValue' gives the radio group an initial value when it is uncontrolled", function () {
|
|
235
305
|
var onChange = jest.fn();
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
container = _render7.container;
|
|
247
|
-
|
|
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;
|
|
248
316
|
var radio = getAllByRole("radio")[1];
|
|
249
317
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
250
318
|
expect(radio.tabIndex).toBe(0);
|
|
251
319
|
expect(radio.getAttribute("aria-checked")).toBe("true");
|
|
252
320
|
expect(submitInput.value).toBe("2");
|
|
253
321
|
});
|
|
254
|
-
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 () {
|
|
255
|
-
var onChange
|
|
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
|
-
test("Controlled radio group", function () {
|
|
290
|
-
var onChange
|
|
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
|
-
test("Select an option by clicking on its label", function () {
|
|
326
|
-
var onChange
|
|
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
|
-
var radioGroup = getByRole("radiogroup");
|
|
416
|
-
var checkedRadio = getAllByRole("radio")[0];
|
|
417
|
-
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
418
|
-
|
|
419
|
-
_react2.fireEvent.keyDown(radioGroup, {
|
|
420
|
-
key: "Enter",
|
|
421
|
-
code: "Enter",
|
|
422
|
-
keyCode: 13,
|
|
423
|
-
charCode: 13
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
expect(onChange).toHaveBeenCalled();
|
|
427
|
-
expect(onChange).toHaveBeenCalledWith("1");
|
|
428
|
-
expect(checkedRadio.getAttribute("aria-checked")).toBe("true");
|
|
429
|
-
expect(checkedRadio.tabIndex).toBe(0);
|
|
430
|
-
expect(submitInput.value).toBe("1");
|
|
431
|
-
});
|
|
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
|
+
})));
|
|
432
482
|
test("The 'space' key checks the current focused option if anyone is checked", function () {
|
|
433
483
|
var onChange = jest.fn();
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
container = _render14.container;
|
|
445
|
-
|
|
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;
|
|
446
494
|
var radioGroup = getByRole("radiogroup");
|
|
447
495
|
var checkedRadio = getAllByRole("radio")[0];
|
|
448
496
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
449
|
-
|
|
450
497
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
451
|
-
key: "
|
|
498
|
+
key: " ",
|
|
452
499
|
code: "Space",
|
|
453
500
|
keyCode: 32,
|
|
454
501
|
charCode: 32
|
|
455
502
|
});
|
|
456
|
-
|
|
457
|
-
expect(onChange).toHaveBeenCalled();
|
|
458
503
|
expect(onChange).toHaveBeenCalledWith("1");
|
|
459
504
|
expect(checkedRadio.getAttribute("aria-checked")).toBe("true");
|
|
460
505
|
expect(checkedRadio.tabIndex).toBe(0);
|
|
@@ -463,39 +508,33 @@ describe("Radio Group component tests", function () {
|
|
|
463
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 () {
|
|
464
509
|
var onChange = jest.fn();
|
|
465
510
|
var onBlur = jest.fn();
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
container = _render15.container;
|
|
478
|
-
|
|
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;
|
|
479
522
|
var radioGroup = getByRole("radiogroup");
|
|
480
523
|
var radios = getAllByRole("radio");
|
|
481
524
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
482
525
|
var checkedRadio = getAllByRole("radio")[0];
|
|
483
|
-
|
|
484
526
|
_userEvent["default"].tab();
|
|
485
|
-
|
|
486
527
|
expect(onChange).not.toHaveBeenCalled();
|
|
487
528
|
expect(submitInput.value).toBe("");
|
|
488
529
|
expect(checkedRadio.tabIndex).toBe(0);
|
|
489
530
|
expect(checkedRadio.getAttribute("aria-checked")).toBe("false");
|
|
490
531
|
expect(document.activeElement).toEqual(checkedRadio);
|
|
491
|
-
|
|
492
532
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
493
533
|
key: "ArrowRight",
|
|
494
534
|
code: "ArrowRight",
|
|
495
535
|
keyCode: 39,
|
|
496
536
|
charCode: 39
|
|
497
537
|
});
|
|
498
|
-
|
|
499
538
|
expect(onBlur).not.toHaveBeenCalled();
|
|
500
539
|
expect(onChange).toHaveBeenCalledTimes(1);
|
|
501
540
|
expect(radios[1].getAttribute("aria-checked")).toBe("true");
|
|
@@ -503,48 +542,42 @@ describe("Radio Group component tests", function () {
|
|
|
503
542
|
expect(radios[1].tabIndex).toBe(0);
|
|
504
543
|
expect(submitInput.value).toBe("2");
|
|
505
544
|
});
|
|
506
|
-
test("The 'arrowDown' and 'arrowRight' keys move the selection to the next radio", function () {
|
|
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 () {
|
|
507
546
|
var onChange = jest.fn();
|
|
508
547
|
var onBlur = jest.fn();
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
container = _render16.container;
|
|
522
|
-
|
|
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;
|
|
523
560
|
var radioGroup = getByRole("radiogroup");
|
|
524
561
|
var radios = getAllByRole("radio");
|
|
525
562
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
526
|
-
|
|
527
563
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
528
564
|
key: "ArrowDown",
|
|
529
565
|
code: "ArrowDown",
|
|
530
566
|
keyCode: 40,
|
|
531
567
|
charCode: 40
|
|
532
568
|
});
|
|
533
|
-
|
|
534
569
|
expect(onBlur).not.toHaveBeenCalled();
|
|
535
570
|
expect(onChange).toHaveBeenCalledTimes(1);
|
|
536
571
|
expect(radios[8].getAttribute("aria-checked")).toBe("true");
|
|
537
572
|
expect(document.activeElement).toEqual(radios[8]);
|
|
538
573
|
expect(radios[8].tabIndex).toBe(0);
|
|
539
574
|
expect(submitInput.value).toBe("9");
|
|
540
|
-
|
|
541
575
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
542
576
|
key: "ArrowRight",
|
|
543
577
|
code: "ArrowRight",
|
|
544
578
|
keyCode: 39,
|
|
545
579
|
charCode: 39
|
|
546
580
|
});
|
|
547
|
-
|
|
548
581
|
expect(onBlur).not.toHaveBeenCalled();
|
|
549
582
|
expect(onChange).toHaveBeenCalledTimes(2);
|
|
550
583
|
expect(radios[0].getAttribute("aria-checked")).toBe("true");
|
|
@@ -552,48 +585,42 @@ describe("Radio Group component tests", function () {
|
|
|
552
585
|
expect(radios[0].tabIndex).toBe(0);
|
|
553
586
|
expect(submitInput.value).toBe("1");
|
|
554
587
|
});
|
|
555
|
-
test("The 'arrowUp' and 'arrowLeft' keys move the selection to the previous radio", function () {
|
|
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 () {
|
|
556
589
|
var onChange = jest.fn();
|
|
557
590
|
var onBlur = jest.fn();
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
container = _render17.container;
|
|
571
|
-
|
|
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;
|
|
572
603
|
var radioGroup = getByRole("radiogroup");
|
|
573
604
|
var radios = getAllByRole("radio");
|
|
574
605
|
var submitInput = container.querySelector("input[name=\"test\"]");
|
|
575
|
-
|
|
576
606
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
577
607
|
key: "ArrowUp",
|
|
578
608
|
code: "ArrowUp",
|
|
579
609
|
keyCode: 38,
|
|
580
610
|
charCode: 38
|
|
581
611
|
});
|
|
582
|
-
|
|
583
612
|
expect(onBlur).not.toHaveBeenCalled();
|
|
584
613
|
expect(onChange).toHaveBeenCalledTimes(1);
|
|
585
614
|
expect(radios[0].getAttribute("aria-checked")).toBe("true");
|
|
586
615
|
expect(document.activeElement).toEqual(radios[0]);
|
|
587
616
|
expect(radios[0].tabIndex).toBe(0);
|
|
588
617
|
expect(submitInput.value).toBe("1");
|
|
589
|
-
|
|
590
618
|
_react2.fireEvent.keyDown(radioGroup, {
|
|
591
619
|
key: "ArrowLeft",
|
|
592
620
|
code: "ArrowLeft",
|
|
593
621
|
keyCode: 37,
|
|
594
622
|
charCode: 37
|
|
595
623
|
});
|
|
596
|
-
|
|
597
624
|
expect(onBlur).not.toHaveBeenCalled();
|
|
598
625
|
expect(onChange).toHaveBeenCalledTimes(2);
|
|
599
626
|
expect(radios[8].getAttribute("aria-checked")).toBe("true");
|
|
@@ -601,94 +628,129 @@ describe("Radio Group component tests", function () {
|
|
|
601
628
|
expect(radios[8].tabIndex).toBe(0);
|
|
602
629
|
expect(submitInput.value).toBe("9");
|
|
603
630
|
});
|
|
604
|
-
test("Keyboard focus movement continues from the last radio input clicked", function () {
|
|
605
|
-
var onChange
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
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
|
-
test("
|
|
655
|
-
var onChange
|
|
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
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
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
|
+
})));
|
|
694
756
|
});
|