@dxc-technology/halstack-react 0.0.0-2b773b3 → 0.0.0-2bca710
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 +2 -2
- package/BackgroundColorContext.js +1 -1
- package/HalstackContext.d.ts +1348 -0
- package/HalstackContext.js +335 -0
- package/README.md +47 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +108 -134
- package/accordion/Accordion.stories.tsx +108 -118
- package/accordion/Accordion.test.js +10 -11
- package/accordion/types.d.ts +1 -12
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +25 -65
- package/accordion-group/AccordionGroup.stories.tsx +93 -66
- package/accordion-group/AccordionGroup.test.js +27 -62
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +43 -0
- package/accordion-group/types.d.ts +7 -12
- package/alert/Alert.js +9 -10
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +1 -1
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +5 -3
- package/badge/types.d.ts +1 -0
- package/bleed/Bleed.js +1 -34
- package/bleed/Bleed.stories.tsx +95 -95
- package/bleed/types.d.ts +1 -1
- package/box/Box.d.ts +1 -1
- package/box/Box.js +19 -48
- package/box/Box.stories.tsx +38 -51
- package/box/Box.test.js +1 -1
- package/box/types.d.ts +0 -11
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +125 -0
- package/bulleted-list/BulletedList.stories.tsx +206 -0
- package/bulleted-list/types.d.ts +38 -0
- package/button/Button.d.ts +1 -1
- package/button/Button.js +44 -71
- package/button/Button.stories.tsx +159 -8
- package/button/Button.test.js +12 -1
- package/button/types.d.ts +9 -5
- package/card/Card.d.ts +1 -1
- package/card/Card.js +37 -58
- package/card/Card.stories.tsx +12 -42
- package/card/Card.test.js +1 -1
- package/card/types.d.ts +1 -6
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +104 -101
- package/checkbox/Checkbox.stories.tsx +198 -130
- package/checkbox/Checkbox.test.js +94 -17
- package/checkbox/types.d.ts +7 -3
- package/chip/Chip.js +28 -49
- package/chip/Chip.stories.tsx +121 -26
- package/chip/Chip.test.js +3 -5
- package/chip/types.d.ts +1 -1
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +146 -0
- package/common/coreTokens.js +167 -0
- package/common/utils.d.ts +1 -0
- package/common/utils.js +4 -4
- package/common/variables.d.ts +1494 -0
- package/common/variables.js +1111 -1111
- package/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +258 -0
- package/date-input/DateInput.js +140 -238
- package/date-input/DateInput.stories.tsx +209 -33
- package/date-input/DateInput.test.js +519 -149
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +146 -0
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +75 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +126 -0
- package/date-input/types.d.ts +55 -0
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +68 -103
- package/dialog/Dialog.stories.tsx +154 -171
- package/dialog/Dialog.test.js +334 -5
- package/dialog/types.d.ts +0 -12
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +246 -253
- package/dropdown/Dropdown.stories.tsx +245 -56
- package/dropdown/Dropdown.test.js +507 -110
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +74 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +79 -0
- package/dropdown/types.d.ts +23 -3
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +180 -223
- package/file-input/FileInput.stories.tsx +122 -11
- package/file-input/FileInput.test.js +14 -14
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +44 -66
- package/file-input/types.d.ts +18 -1
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +71 -0
- package/flex/Flex.stories.tsx +112 -0
- package/flex/types.d.ts +97 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +49 -142
- package/footer/Footer.stories.tsx +41 -19
- package/footer/Footer.test.js +16 -26
- package/footer/Icons.js +1 -1
- package/footer/types.d.ts +11 -12
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +91 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/header/Header.d.ts +4 -3
- package/header/Header.js +102 -150
- package/header/Header.stories.tsx +152 -63
- package/header/Header.test.js +20 -4
- package/header/Icons.js +2 -2
- package/header/types.d.ts +0 -13
- package/heading/Heading.js +1 -1
- package/heading/Heading.test.js +1 -1
- package/image/Image.d.ts +4 -0
- package/image/Image.js +85 -0
- package/image/Image.stories.tsx +127 -0
- package/image/types.d.ts +72 -0
- package/inset/Inset.js +1 -34
- package/inset/Inset.stories.tsx +37 -36
- package/inset/types.d.ts +1 -1
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +81 -138
- package/layout/ApplicationLayout.stories.tsx +85 -94
- package/layout/Icons.d.ts +8 -0
- package/layout/Icons.js +52 -45
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +19 -0
- package/layout/types.d.ts +19 -35
- package/link/Link.d.ts +3 -2
- package/link/Link.js +60 -77
- package/link/Link.stories.tsx +155 -53
- package/link/Link.test.js +9 -19
- package/link/types.d.ts +5 -21
- package/main.d.ts +9 -10
- package/main.js +55 -57
- package/nav-tabs/NavTabs.d.ts +8 -0
- package/nav-tabs/NavTabs.js +122 -0
- package/nav-tabs/NavTabs.stories.tsx +274 -0
- package/nav-tabs/NavTabs.test.js +82 -0
- package/nav-tabs/Tab.d.ts +4 -0
- package/nav-tabs/Tab.js +146 -0
- package/nav-tabs/types.d.ts +52 -0
- package/number-input/NumberInput.d.ts +7 -0
- package/number-input/NumberInput.js +6 -4
- package/number-input/NumberInput.test.js +319 -102
- package/number-input/types.d.ts +13 -10
- package/package.json +19 -23
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +16 -28
- package/paginator/Paginator.js +20 -49
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +91 -39
- package/paragraph/Paragraph.d.ts +5 -0
- package/paragraph/Paragraph.js +38 -0
- package/paragraph/Paragraph.stories.tsx +44 -0
- package/password-input/Icons.d.ts +6 -0
- package/password-input/Icons.js +39 -0
- package/password-input/PasswordInput.js +36 -80
- package/password-input/PasswordInput.stories.tsx +1 -0
- package/password-input/PasswordInput.test.js +36 -45
- package/password-input/types.d.ts +14 -11
- package/progress-bar/ProgressBar.js +61 -55
- package/progress-bar/ProgressBar.stories.jsx +47 -12
- package/progress-bar/ProgressBar.test.js +68 -23
- package/quick-nav/QuickNav.js +77 -26
- package/quick-nav/QuickNav.stories.tsx +145 -26
- package/quick-nav/types.d.ts +4 -4
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +46 -31
- package/radio-group/RadioGroup.js +37 -36
- package/radio-group/RadioGroup.stories.tsx +132 -18
- package/radio-group/RadioGroup.test.js +124 -97
- package/radio-group/types.d.ts +2 -2
- package/resultsetTable/Icons.d.ts +7 -0
- package/resultsetTable/Icons.js +51 -0
- package/resultsetTable/ResultsetTable.js +49 -108
- package/resultsetTable/ResultsetTable.stories.tsx +50 -25
- package/resultsetTable/ResultsetTable.test.js +61 -42
- package/resultsetTable/types.d.ts +1 -1
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +169 -0
- package/select/Option.js +11 -24
- package/select/Select.js +148 -214
- package/select/Select.stories.tsx +525 -136
- package/select/Select.test.js +478 -307
- package/select/types.d.ts +20 -4
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +51 -0
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +146 -44
- package/sidenav/Sidenav.stories.tsx +251 -151
- package/sidenav/Sidenav.test.js +25 -37
- package/sidenav/types.d.ts +52 -26
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +121 -97
- package/slider/Slider.stories.tsx +64 -1
- package/slider/Slider.test.js +122 -22
- package/slider/types.d.ts +4 -0
- package/spinner/Spinner.js +18 -24
- package/spinner/Spinner.stories.jsx +53 -27
- package/spinner/Spinner.test.js +1 -1
- package/switch/Switch.d.ts +2 -2
- package/switch/Switch.js +138 -68
- package/switch/Switch.stories.tsx +49 -38
- package/switch/Switch.test.js +145 -18
- package/switch/types.d.ts +6 -2
- package/table/Table.js +3 -3
- package/table/Table.stories.jsx +80 -1
- package/table/Table.test.js +2 -2
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +132 -0
- package/tabs/Tabs.js +358 -108
- package/tabs/Tabs.stories.tsx +119 -11
- package/tabs/Tabs.test.js +220 -10
- package/tabs/types.d.ts +13 -3
- package/tag/Tag.js +12 -17
- package/tag/Tag.stories.tsx +14 -1
- package/tag/Tag.test.js +1 -1
- package/tag/types.d.ts +1 -1
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +60 -0
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +84 -0
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +134 -0
- package/text-input/TextInput.js +260 -399
- package/text-input/TextInput.stories.tsx +319 -185
- package/text-input/TextInput.test.js +846 -759
- package/text-input/types.d.ts +50 -12
- package/textarea/Textarea.js +37 -45
- package/textarea/Textarea.stories.jsx +68 -1
- package/textarea/Textarea.test.js +61 -19
- package/textarea/types.d.ts +14 -7
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +85 -59
- package/toggle-group/ToggleGroup.stories.tsx +48 -3
- package/toggle-group/ToggleGroup.test.js +38 -24
- package/toggle-group/types.d.ts +23 -14
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +32 -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 +1246 -1
- package/useTheme.js +3 -3
- package/useTranslatedLabels.d.ts +85 -0
- package/useTranslatedLabels.js +20 -0
- package/utils/BaseTypography.d.ts +21 -0
- package/utils/BaseTypography.js +108 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +138 -0
- package/wizard/Wizard.js +44 -45
- package/wizard/Wizard.stories.tsx +40 -1
- package/wizard/Wizard.test.js +1 -1
- package/wizard/types.d.ts +3 -3
- package/ThemeContext.d.ts +0 -10
- package/ThemeContext.js +0 -243
- package/card/ice-cream.jpg +0 -0
- package/common/RequiredComponent.js +0 -32
- 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/NumberInputContext.d.ts +0 -4
- package/number-input/NumberInputContext.js +0 -19
- package/number-input/numberInputContextTypes.d.ts +0 -19
- 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/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/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/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
- /package/{list → bulleted-list}/types.js +0 -0
- /package/{radio → flex}/types.js +0 -0
- /package/{row → grid}/types.js +0 -0
- /package/{stack → image}/types.js +0 -0
- /package/{number-input/numberInputContextTypes.js → nav-tabs/types.js} +0 -0
|
@@ -6,64 +6,67 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
6
6
|
|
|
7
7
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
8
|
|
|
9
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
+
|
|
11
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
+
|
|
9
13
|
var _react = _interopRequireDefault(require("react"));
|
|
10
14
|
|
|
11
15
|
var _react2 = require("@testing-library/react");
|
|
12
16
|
|
|
13
17
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
14
18
|
|
|
15
|
-
var _TextInput = _interopRequireDefault(require("./TextInput"));
|
|
19
|
+
var _TextInput = _interopRequireDefault(require("./TextInput.tsx"));
|
|
20
|
+
|
|
21
|
+
// Mocking DOMRect for Radix Primitive Popover
|
|
22
|
+
global.globalThis = global;
|
|
23
|
+
|
|
24
|
+
global.ResizeObserver = /*#__PURE__*/function () {
|
|
25
|
+
function ResizeObserver(cb) {
|
|
26
|
+
(0, _classCallCheck2["default"])(this, ResizeObserver);
|
|
27
|
+
this.cb = cb;
|
|
28
|
+
}
|
|
16
29
|
|
|
30
|
+
(0, _createClass2["default"])(ResizeObserver, [{
|
|
31
|
+
key: "observe",
|
|
32
|
+
value: function observe() {
|
|
33
|
+
this.cb([{
|
|
34
|
+
borderBoxSize: {
|
|
35
|
+
inlineSize: 0,
|
|
36
|
+
blockSize: 0
|
|
37
|
+
}
|
|
38
|
+
}]);
|
|
39
|
+
}
|
|
40
|
+
}, {
|
|
41
|
+
key: "unobserve",
|
|
42
|
+
value: function unobserve() {}
|
|
43
|
+
}]);
|
|
44
|
+
return ResizeObserver;
|
|
45
|
+
}();
|
|
46
|
+
|
|
47
|
+
global.DOMRect = {
|
|
48
|
+
fromRect: function fromRect() {
|
|
49
|
+
return {
|
|
50
|
+
top: 0,
|
|
51
|
+
left: 0,
|
|
52
|
+
bottom: 0,
|
|
53
|
+
right: 0,
|
|
54
|
+
width: 0,
|
|
55
|
+
height: 0
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
};
|
|
17
59
|
var countries = ["Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Cabo Verde", "Cambodia", "Cameroon", "Canada", "Cayman Islands, The", "Central African Republic", "Chad", "Democratic Republic of the Congo", "Dominican Republic", "Dominica", "Denmark", "Djibouti"];
|
|
60
|
+
var specialCharacters = ["/", "\\", "*", "(", ")", "[", "]", "+", "?", "*{[]}|"];
|
|
18
61
|
describe("TextInput component tests", function () {
|
|
19
|
-
test("Renders with correct
|
|
62
|
+
test("Renders with correct error aria attributes", function () {
|
|
20
63
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
21
|
-
label: "Example label"
|
|
22
|
-
})),
|
|
23
|
-
getByText = _render.getByText;
|
|
24
|
-
|
|
25
|
-
expect(getByText("Example label")).toBeTruthy();
|
|
26
|
-
});
|
|
27
|
-
test("Renders with correct label and helper text", function () {
|
|
28
|
-
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
29
|
-
label: "Example label",
|
|
30
|
-
helperText: "Example helper text"
|
|
31
|
-
})),
|
|
32
|
-
getByText = _render2.getByText;
|
|
33
|
-
|
|
34
|
-
expect(getByText("Example label")).toBeTruthy();
|
|
35
|
-
expect(getByText("Example helper text")).toBeTruthy();
|
|
36
|
-
});
|
|
37
|
-
test("Renders with correct label and optional", function () {
|
|
38
|
-
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
39
|
-
label: "Example label",
|
|
40
|
-
helperText: "Example helper text",
|
|
41
|
-
optional: true
|
|
42
|
-
})),
|
|
43
|
-
getByText = _render3.getByText;
|
|
44
|
-
|
|
45
|
-
expect(getByText("Example label")).toBeTruthy();
|
|
46
|
-
expect(getByText("(Optional)")).toBeTruthy();
|
|
47
|
-
expect(getByText("Example helper text")).toBeTruthy();
|
|
48
|
-
});
|
|
49
|
-
test("Renders with correct placeholder", function () {
|
|
50
|
-
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
51
|
-
label: "Example label",
|
|
52
|
-
placeholder: "Placeholder"
|
|
53
|
-
})),
|
|
54
|
-
getByRole = _render4.getByRole;
|
|
55
|
-
|
|
56
|
-
var input = getByRole("textbox");
|
|
57
|
-
expect(input.getAttribute("placeholder")).toBe("Placeholder");
|
|
58
|
-
});
|
|
59
|
-
test("Renders with error message and correct aria attributes", function () {
|
|
60
|
-
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
61
64
|
label: "Error label",
|
|
62
65
|
placeholder: "Placeholder",
|
|
63
66
|
error: "Error message."
|
|
64
67
|
})),
|
|
65
|
-
getByText =
|
|
66
|
-
getByRole =
|
|
68
|
+
getByText = _render.getByText,
|
|
69
|
+
getByRole = _render.getByRole;
|
|
67
70
|
|
|
68
71
|
var input = getByRole("textbox");
|
|
69
72
|
var errorMessage = getByText("Error message.");
|
|
@@ -73,12 +76,12 @@ describe("TextInput component tests", function () {
|
|
|
73
76
|
expect(errorMessage.getAttribute("aria-live")).toBe("assertive");
|
|
74
77
|
});
|
|
75
78
|
test("Renders with correct initial value", function () {
|
|
76
|
-
var
|
|
79
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
77
80
|
label: "Default label",
|
|
78
81
|
placeholder: "Placeholder",
|
|
79
82
|
defaultValue: "Example text"
|
|
80
83
|
})),
|
|
81
|
-
getByRole =
|
|
84
|
+
getByRole = _render2.getByRole;
|
|
82
85
|
|
|
83
86
|
var input = getByRole("textbox");
|
|
84
87
|
expect(input.value).toBe("Example text");
|
|
@@ -87,14 +90,14 @@ describe("TextInput component tests", function () {
|
|
|
87
90
|
var onChange = jest.fn();
|
|
88
91
|
var onBlur = jest.fn();
|
|
89
92
|
|
|
90
|
-
var
|
|
93
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
91
94
|
label: "Input label",
|
|
92
95
|
placeholder: "Placeholder",
|
|
93
96
|
onChange: onChange,
|
|
94
97
|
onBlur: onBlur,
|
|
95
98
|
clearable: true
|
|
96
99
|
})),
|
|
97
|
-
getByRole =
|
|
100
|
+
getByRole = _render3.getByRole;
|
|
98
101
|
|
|
99
102
|
var input = getByRole("textbox");
|
|
100
103
|
|
|
@@ -118,20 +121,19 @@ describe("TextInput component tests", function () {
|
|
|
118
121
|
|
|
119
122
|
expect(onBlur).toHaveBeenCalled();
|
|
120
123
|
expect(onBlur).toHaveBeenCalledWith({
|
|
121
|
-
value: "Test"
|
|
122
|
-
error: null
|
|
124
|
+
value: "Test"
|
|
123
125
|
});
|
|
124
126
|
});
|
|
125
127
|
test("Not optional constraint (onChange)", function () {
|
|
126
128
|
var onChange = jest.fn();
|
|
127
129
|
|
|
128
|
-
var
|
|
130
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
129
131
|
label: "Input label",
|
|
130
132
|
placeholder: "Placeholder",
|
|
131
133
|
onChange: onChange,
|
|
132
134
|
clearable: true
|
|
133
135
|
})),
|
|
134
|
-
getByRole =
|
|
136
|
+
getByRole = _render4.getByRole;
|
|
135
137
|
|
|
136
138
|
var input = getByRole("textbox");
|
|
137
139
|
|
|
@@ -143,8 +145,7 @@ describe("TextInput component tests", function () {
|
|
|
143
145
|
|
|
144
146
|
expect(onChange).toHaveBeenCalled();
|
|
145
147
|
expect(onChange).toHaveBeenCalledWith({
|
|
146
|
-
value: "Test"
|
|
147
|
-
error: null
|
|
148
|
+
value: "Test"
|
|
148
149
|
});
|
|
149
150
|
|
|
150
151
|
_userEvent["default"].clear(input);
|
|
@@ -159,7 +160,7 @@ describe("TextInput component tests", function () {
|
|
|
159
160
|
var onChange = jest.fn();
|
|
160
161
|
var onBlur = jest.fn();
|
|
161
162
|
|
|
162
|
-
var
|
|
163
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
163
164
|
label: "Input label",
|
|
164
165
|
placeholder: "Placeholder",
|
|
165
166
|
onChange: onChange,
|
|
@@ -171,7 +172,7 @@ describe("TextInput component tests", function () {
|
|
|
171
172
|
clearable: true,
|
|
172
173
|
pattern: "^.*(?=.*[a-zA-Z])(?=.*\\d)(?=.*[!&$%&? \"]).*$"
|
|
173
174
|
})),
|
|
174
|
-
getByRole =
|
|
175
|
+
getByRole = _render5.getByRole;
|
|
175
176
|
|
|
176
177
|
var input = getByRole("textbox");
|
|
177
178
|
|
|
@@ -205,23 +206,21 @@ describe("TextInput component tests", function () {
|
|
|
205
206
|
|
|
206
207
|
expect(onChange).toHaveBeenCalled();
|
|
207
208
|
expect(onChange).toHaveBeenCalledWith({
|
|
208
|
-
value: "pattern4&"
|
|
209
|
-
error: null
|
|
209
|
+
value: "pattern4&"
|
|
210
210
|
});
|
|
211
211
|
|
|
212
212
|
_react2.fireEvent.blur(input);
|
|
213
213
|
|
|
214
214
|
expect(onBlur).toHaveBeenCalled();
|
|
215
215
|
expect(onBlur).toHaveBeenCalledWith({
|
|
216
|
-
value: "pattern4&"
|
|
217
|
-
error: null
|
|
216
|
+
value: "pattern4&"
|
|
218
217
|
});
|
|
219
218
|
});
|
|
220
219
|
test("Length constraint", function () {
|
|
221
220
|
var onChange = jest.fn();
|
|
222
221
|
var onBlur = jest.fn();
|
|
223
222
|
|
|
224
|
-
var
|
|
223
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
225
224
|
label: "Input label",
|
|
226
225
|
placeholder: "Placeholder",
|
|
227
226
|
onChange: onChange,
|
|
@@ -234,7 +233,7 @@ describe("TextInput component tests", function () {
|
|
|
234
233
|
minLength: 5,
|
|
235
234
|
maxLength: 10
|
|
236
235
|
})),
|
|
237
|
-
getByRole =
|
|
236
|
+
getByRole = _render6.getByRole;
|
|
238
237
|
|
|
239
238
|
var input = getByRole("textbox");
|
|
240
239
|
|
|
@@ -268,23 +267,21 @@ describe("TextInput component tests", function () {
|
|
|
268
267
|
|
|
269
268
|
expect(onChange).toHaveBeenCalled();
|
|
270
269
|
expect(onChange).toHaveBeenCalledWith({
|
|
271
|
-
value: "length"
|
|
272
|
-
error: null
|
|
270
|
+
value: "length"
|
|
273
271
|
});
|
|
274
272
|
|
|
275
273
|
_react2.fireEvent.blur(input);
|
|
276
274
|
|
|
277
275
|
expect(onBlur).toHaveBeenCalled();
|
|
278
276
|
expect(onBlur).toHaveBeenCalledWith({
|
|
279
|
-
value: "length"
|
|
280
|
-
error: null
|
|
277
|
+
value: "length"
|
|
281
278
|
});
|
|
282
279
|
});
|
|
283
280
|
test("Pattern and length constraints", function () {
|
|
284
281
|
var onChange = jest.fn();
|
|
285
282
|
var onBlur = jest.fn();
|
|
286
283
|
|
|
287
|
-
var
|
|
284
|
+
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
288
285
|
label: "Input label",
|
|
289
286
|
placeholder: "Placeholder",
|
|
290
287
|
onChange: onChange,
|
|
@@ -298,7 +295,7 @@ describe("TextInput component tests", function () {
|
|
|
298
295
|
minLength: 5,
|
|
299
296
|
maxLength: 10
|
|
300
297
|
})),
|
|
301
|
-
getByRole =
|
|
298
|
+
getByRole = _render7.getByRole;
|
|
302
299
|
|
|
303
300
|
var input = getByRole("textbox");
|
|
304
301
|
|
|
@@ -350,26 +347,24 @@ describe("TextInput component tests", function () {
|
|
|
350
347
|
|
|
351
348
|
expect(onChange).toHaveBeenCalled();
|
|
352
349
|
expect(onChange).toHaveBeenCalledWith({
|
|
353
|
-
value: "tests4&"
|
|
354
|
-
error: null
|
|
350
|
+
value: "tests4&"
|
|
355
351
|
});
|
|
356
352
|
|
|
357
353
|
_react2.fireEvent.blur(input);
|
|
358
354
|
|
|
359
355
|
expect(onBlur).toHaveBeenCalled();
|
|
360
356
|
expect(onBlur).toHaveBeenCalledWith({
|
|
361
|
-
value: "tests4&"
|
|
362
|
-
error: null
|
|
357
|
+
value: "tests4&"
|
|
363
358
|
});
|
|
364
359
|
});
|
|
365
360
|
test("onChange function is called correctly", function () {
|
|
366
361
|
var onChange = jest.fn();
|
|
367
362
|
|
|
368
|
-
var
|
|
363
|
+
var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
369
364
|
label: "Input label",
|
|
370
365
|
onChange: onChange
|
|
371
366
|
})),
|
|
372
|
-
getByRole =
|
|
367
|
+
getByRole = _render8.getByRole;
|
|
373
368
|
|
|
374
369
|
var input = getByRole("textbox");
|
|
375
370
|
|
|
@@ -378,20 +373,19 @@ describe("TextInput component tests", function () {
|
|
|
378
373
|
expect(input.value).toBe("onchange event test");
|
|
379
374
|
expect(onChange).toHaveBeenCalled();
|
|
380
375
|
expect(onChange).toHaveBeenCalledWith({
|
|
381
|
-
value: "onchange event test"
|
|
382
|
-
error: null
|
|
376
|
+
value: "onchange event test"
|
|
383
377
|
});
|
|
384
378
|
});
|
|
385
379
|
test("onBlur function is called correctly", function () {
|
|
386
380
|
var onBlur = jest.fn();
|
|
387
381
|
var onChange = jest.fn();
|
|
388
382
|
|
|
389
|
-
var
|
|
383
|
+
var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
390
384
|
label: "Input label",
|
|
391
385
|
onChange: onChange,
|
|
392
386
|
onBlur: onBlur
|
|
393
387
|
})),
|
|
394
|
-
getByRole =
|
|
388
|
+
getByRole = _render9.getByRole;
|
|
395
389
|
|
|
396
390
|
var input = getByRole("textbox");
|
|
397
391
|
|
|
@@ -405,37 +399,25 @@ describe("TextInput component tests", function () {
|
|
|
405
399
|
|
|
406
400
|
expect(onBlur).toHaveBeenCalled();
|
|
407
401
|
expect(onBlur).toHaveBeenCalledWith({
|
|
408
|
-
value: "Blur test"
|
|
409
|
-
error: null
|
|
402
|
+
value: "Blur test"
|
|
410
403
|
});
|
|
411
404
|
});
|
|
412
|
-
test("Clear action
|
|
413
|
-
var
|
|
405
|
+
test("Clear action tooltip is correct", function () {
|
|
406
|
+
var _render10 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
407
|
+
label: "Input label",
|
|
408
|
+
value: "Text",
|
|
409
|
+
clearable: true
|
|
410
|
+
})),
|
|
411
|
+
getByTitle = _render10.getByTitle;
|
|
414
412
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
switch (_context.prev = _context.next) {
|
|
418
|
-
case 0:
|
|
419
|
-
_render14 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
420
|
-
label: "Input label",
|
|
421
|
-
value: "Text",
|
|
422
|
-
clearable: true
|
|
423
|
-
})), getByTitle = _render14.getByTitle;
|
|
424
|
-
expect(getByTitle("Clear field")).toBeTruthy();
|
|
425
|
-
|
|
426
|
-
case 2:
|
|
427
|
-
case "end":
|
|
428
|
-
return _context.stop();
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}, _callee);
|
|
432
|
-
})));
|
|
413
|
+
expect(getByTitle("Clear field")).toBeTruthy();
|
|
414
|
+
});
|
|
433
415
|
test("Clear action onClick cleans the input", function () {
|
|
434
|
-
var
|
|
416
|
+
var _render11 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
435
417
|
label: "Input label",
|
|
436
418
|
clearable: true
|
|
437
419
|
})),
|
|
438
|
-
getByRole =
|
|
420
|
+
getByRole = _render11.getByRole;
|
|
439
421
|
|
|
440
422
|
var input = getByRole("textbox");
|
|
441
423
|
|
|
@@ -447,24 +429,23 @@ describe("TextInput component tests", function () {
|
|
|
447
429
|
|
|
448
430
|
expect(input.value).toBe("");
|
|
449
431
|
});
|
|
450
|
-
test("Disabled input renders with correct aria and can not be modified", function () {
|
|
432
|
+
test("Disabled text input renders with correct aria and can not be modified", function () {
|
|
451
433
|
var onChange = jest.fn();
|
|
452
434
|
|
|
453
|
-
var
|
|
435
|
+
var _render12 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
454
436
|
label: "Input label",
|
|
455
437
|
onChange: onChange,
|
|
456
438
|
disabled: true
|
|
457
439
|
})),
|
|
458
|
-
getByRole =
|
|
440
|
+
getByRole = _render12.getByRole;
|
|
459
441
|
|
|
460
442
|
var input = getByRole("textbox");
|
|
461
|
-
expect(input.getAttribute("aria-disabled")).toBe("true");
|
|
462
443
|
|
|
463
444
|
_userEvent["default"].type(input, "Test");
|
|
464
445
|
|
|
465
446
|
expect(onChange).not.toHaveBeenCalled();
|
|
466
447
|
});
|
|
467
|
-
test("Disabled input (action must be shown but not clickable)", function () {
|
|
448
|
+
test("Disabled text input (action must be shown but not clickable)", function () {
|
|
468
449
|
var onClick = jest.fn();
|
|
469
450
|
var action = {
|
|
470
451
|
onClick: onClick,
|
|
@@ -483,12 +464,12 @@ describe("TextInput component tests", function () {
|
|
|
483
464
|
}))
|
|
484
465
|
};
|
|
485
466
|
|
|
486
|
-
var
|
|
467
|
+
var _render13 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
487
468
|
label: "Disabled input label",
|
|
488
469
|
action: action,
|
|
489
470
|
disabled: true
|
|
490
471
|
})),
|
|
491
|
-
getByRole =
|
|
472
|
+
getByRole = _render13.getByRole;
|
|
492
473
|
|
|
493
474
|
var input = getByRole("textbox");
|
|
494
475
|
expect(input.disabled).toBeTruthy();
|
|
@@ -497,36 +478,125 @@ describe("TextInput component tests", function () {
|
|
|
497
478
|
|
|
498
479
|
expect(onClick).not.toHaveBeenCalled();
|
|
499
480
|
});
|
|
500
|
-
test("Disabled input (clear default action should not be displayed, even with text written on the input)", function () {
|
|
501
|
-
var
|
|
481
|
+
test("Disabled text input (clear default action should not be displayed, even with text written on the input)", function () {
|
|
482
|
+
var _render14 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
502
483
|
label: "Disabled input label",
|
|
503
484
|
value: "Sample text",
|
|
504
485
|
disabled: true,
|
|
505
486
|
clearable: true
|
|
506
487
|
})),
|
|
507
|
-
getByRole =
|
|
508
|
-
queryByRole =
|
|
488
|
+
getByRole = _render14.getByRole,
|
|
489
|
+
queryByRole = _render14.queryByRole;
|
|
509
490
|
|
|
510
491
|
var input = getByRole("textbox");
|
|
511
492
|
expect(input.disabled).toBeTruthy();
|
|
512
493
|
expect(queryByRole("button")).toBeFalsy();
|
|
513
494
|
});
|
|
514
|
-
test("Disabled input (suffix and
|
|
515
|
-
var
|
|
495
|
+
test("Disabled text input (suffix and prefix must be displayed)", function () {
|
|
496
|
+
var _render15 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
516
497
|
label: "Disabled input label",
|
|
517
498
|
value: "Sample text",
|
|
518
499
|
prefix: "+34",
|
|
519
500
|
suffix: "USD",
|
|
520
501
|
disabled: true
|
|
521
502
|
})),
|
|
522
|
-
getByRole =
|
|
523
|
-
getByText =
|
|
503
|
+
getByRole = _render15.getByRole,
|
|
504
|
+
getByText = _render15.getByText;
|
|
524
505
|
|
|
525
506
|
var input = getByRole("textbox");
|
|
526
507
|
expect(input.disabled).toBeTruthy();
|
|
527
508
|
expect(getByText("+34")).toBeTruthy();
|
|
528
509
|
expect(getByText("USD")).toBeTruthy();
|
|
529
510
|
});
|
|
511
|
+
test("Read-only text input doesn't render the clear action", function () {
|
|
512
|
+
var _render16 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
513
|
+
label: "Disabled input label",
|
|
514
|
+
defaultValue: "Sample text",
|
|
515
|
+
readOnly: true,
|
|
516
|
+
clearable: true
|
|
517
|
+
})),
|
|
518
|
+
getByRole = _render16.getByRole,
|
|
519
|
+
queryByRole = _render16.queryByRole;
|
|
520
|
+
|
|
521
|
+
var input = getByRole("textbox");
|
|
522
|
+
expect(input.readOnly).toBeTruthy();
|
|
523
|
+
expect(queryByRole("button")).toBeFalsy();
|
|
524
|
+
});
|
|
525
|
+
test("Read-only text input does not trigger onChange function", function () {
|
|
526
|
+
var onChange = jest.fn();
|
|
527
|
+
|
|
528
|
+
var _render17 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
529
|
+
label: "Example label",
|
|
530
|
+
onChange: onChange,
|
|
531
|
+
readOnly: true
|
|
532
|
+
})),
|
|
533
|
+
getByLabelText = _render17.getByLabelText;
|
|
534
|
+
|
|
535
|
+
var textInput = getByLabelText("Example label");
|
|
536
|
+
|
|
537
|
+
_userEvent["default"].type(textInput, "Test");
|
|
538
|
+
|
|
539
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
540
|
+
});
|
|
541
|
+
test("Read-only text input sends its value on submit", function () {
|
|
542
|
+
var handlerOnSubmit = jest.fn(function (e) {
|
|
543
|
+
e.preventDefault();
|
|
544
|
+
var formData = new FormData(e.target);
|
|
545
|
+
var formProps = Object.fromEntries(formData);
|
|
546
|
+
expect(formProps).toStrictEqual({
|
|
547
|
+
data: "Text"
|
|
548
|
+
});
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
var _render18 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement("form", {
|
|
552
|
+
onSubmit: handlerOnSubmit
|
|
553
|
+
}, /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
554
|
+
label: "Example label",
|
|
555
|
+
name: "data",
|
|
556
|
+
defaultValue: "Text",
|
|
557
|
+
readOnly: true
|
|
558
|
+
}), /*#__PURE__*/_react["default"].createElement("button", {
|
|
559
|
+
type: "submit"
|
|
560
|
+
}, "Submit"))),
|
|
561
|
+
getByText = _render18.getByText;
|
|
562
|
+
|
|
563
|
+
var submit = getByText("Submit");
|
|
564
|
+
|
|
565
|
+
_userEvent["default"].click(submit);
|
|
566
|
+
|
|
567
|
+
expect(handlerOnSubmit).toHaveBeenCalled();
|
|
568
|
+
});
|
|
569
|
+
test("Read-only text input doesn't trigger custom action's onClick event", function () {
|
|
570
|
+
var onClick = jest.fn();
|
|
571
|
+
var action = {
|
|
572
|
+
onClick: onClick,
|
|
573
|
+
icon: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
574
|
+
"data-testid": "image",
|
|
575
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
576
|
+
height: "24px",
|
|
577
|
+
viewBox: "0 0 24 24",
|
|
578
|
+
width: "24px",
|
|
579
|
+
fill: "currentColor"
|
|
580
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
581
|
+
d: "M0 0h24v24H0V0z",
|
|
582
|
+
fill: "none"
|
|
583
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
584
|
+
d: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"
|
|
585
|
+
})),
|
|
586
|
+
title: "Search"
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
var _render19 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
590
|
+
label: "Input label",
|
|
591
|
+
action: action,
|
|
592
|
+
readOnly: true
|
|
593
|
+
})),
|
|
594
|
+
getByRole = _render19.getByRole;
|
|
595
|
+
|
|
596
|
+
_userEvent["default"].click(getByRole("button"));
|
|
597
|
+
|
|
598
|
+
expect(onClick).not.toHaveBeenCalled();
|
|
599
|
+
});
|
|
530
600
|
test("Action prop: image displayed with title and onClick event", function () {
|
|
531
601
|
var onClick = jest.fn();
|
|
532
602
|
var action = {
|
|
@@ -562,18 +632,75 @@ describe("TextInput component tests", function () {
|
|
|
562
632
|
|
|
563
633
|
expect(onClick).toHaveBeenCalled();
|
|
564
634
|
});
|
|
635
|
+
test("Text input submit correctly value in form", function () {
|
|
636
|
+
var onClick = jest.fn();
|
|
637
|
+
var action = {
|
|
638
|
+
onClick: onClick,
|
|
639
|
+
icon: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
640
|
+
"data-testid": "image",
|
|
641
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
642
|
+
height: "24px",
|
|
643
|
+
viewBox: "0 0 24 24",
|
|
644
|
+
width: "24px",
|
|
645
|
+
fill: "currentColor"
|
|
646
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
647
|
+
d: "M0 0h24v24H0V0z",
|
|
648
|
+
fill: "none"
|
|
649
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
650
|
+
d: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"
|
|
651
|
+
})),
|
|
652
|
+
title: "Search"
|
|
653
|
+
};
|
|
654
|
+
var handlerOnSubmit = jest.fn(function (e) {
|
|
655
|
+
e.preventDefault();
|
|
656
|
+
var formData = new FormData(e.target);
|
|
657
|
+
var formProps = Object.fromEntries(formData);
|
|
658
|
+
expect(formProps).toStrictEqual({
|
|
659
|
+
data: "test"
|
|
660
|
+
});
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
var _render21 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement("form", {
|
|
664
|
+
onSubmit: handlerOnSubmit
|
|
665
|
+
}, /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
666
|
+
label: "Input label",
|
|
667
|
+
name: "data",
|
|
668
|
+
action: action
|
|
669
|
+
}), /*#__PURE__*/_react["default"].createElement("button", {
|
|
670
|
+
type: "submit"
|
|
671
|
+
}, "Submit"))),
|
|
672
|
+
getByText = _render21.getByText,
|
|
673
|
+
getAllByRole = _render21.getAllByRole,
|
|
674
|
+
getByRole = _render21.getByRole;
|
|
675
|
+
|
|
676
|
+
var search = getAllByRole("button")[0];
|
|
677
|
+
var submit = getByText("Submit");
|
|
678
|
+
var input = getByRole("textbox");
|
|
679
|
+
|
|
680
|
+
_userEvent["default"].type(input, "test");
|
|
681
|
+
|
|
682
|
+
expect(input.value).toBe("test");
|
|
683
|
+
|
|
684
|
+
_userEvent["default"].click(search);
|
|
685
|
+
|
|
686
|
+
expect(handlerOnSubmit).not.toHaveBeenCalled();
|
|
687
|
+
|
|
688
|
+
_userEvent["default"].click(submit);
|
|
689
|
+
|
|
690
|
+
expect(handlerOnSubmit).toHaveBeenCalled();
|
|
691
|
+
});
|
|
565
692
|
test("Renders with correct prefix and suffix", function () {
|
|
566
|
-
var
|
|
693
|
+
var _render22 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
567
694
|
label: "Input label",
|
|
568
695
|
prefix: "+34",
|
|
569
696
|
suffix: "USD"
|
|
570
697
|
})),
|
|
571
|
-
getByText =
|
|
698
|
+
getByText = _render22.getByText;
|
|
572
699
|
|
|
573
700
|
expect(getByText("+34")).toBeTruthy();
|
|
574
701
|
expect(getByText("USD")).toBeTruthy();
|
|
575
702
|
});
|
|
576
|
-
test("Input has correct
|
|
703
|
+
test("Text Input has correct aria accessibility attributes", function () {
|
|
577
704
|
var onClick = jest.fn();
|
|
578
705
|
var action = {
|
|
579
706
|
onClick: onClick,
|
|
@@ -593,18 +720,19 @@ describe("TextInput component tests", function () {
|
|
|
593
720
|
title: "Search"
|
|
594
721
|
};
|
|
595
722
|
|
|
596
|
-
var
|
|
723
|
+
var _render23 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
597
724
|
label: "Example label",
|
|
598
725
|
clearable: true,
|
|
599
726
|
action: action
|
|
600
727
|
})),
|
|
601
|
-
getByRole =
|
|
602
|
-
getAllByRole =
|
|
728
|
+
getByRole = _render23.getByRole,
|
|
729
|
+
getAllByRole = _render23.getAllByRole;
|
|
603
730
|
|
|
604
731
|
var input = getByRole("textbox");
|
|
605
732
|
expect(input.getAttribute("aria-autocomplete")).toBeNull();
|
|
606
733
|
expect(input.getAttribute("aria-controls")).toBeNull();
|
|
607
734
|
expect(input.getAttribute("aria-expanded")).toBeNull();
|
|
735
|
+
expect(input.getAttribute("aria-haspopup")).toBeNull();
|
|
608
736
|
expect(input.getAttribute("aria-activedescendant")).toBeNull();
|
|
609
737
|
expect(input.getAttribute("aria-invalid")).toBe("false");
|
|
610
738
|
expect(input.getAttribute("aria-errormessage")).toBeNull();
|
|
@@ -617,18 +745,19 @@ describe("TextInput component tests", function () {
|
|
|
617
745
|
var search = getAllByRole("button")[1];
|
|
618
746
|
expect(search.getAttribute("aria-label")).toBe("Search");
|
|
619
747
|
});
|
|
620
|
-
test("Autosuggest has correct
|
|
621
|
-
var
|
|
748
|
+
test("Autosuggest has correct accessibility attributes", function () {
|
|
749
|
+
var _render24 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
622
750
|
label: "Autocomplete Countries",
|
|
623
751
|
optional: true,
|
|
624
752
|
suggestions: countries
|
|
625
753
|
})),
|
|
626
|
-
getByRole =
|
|
627
|
-
getAllByRole =
|
|
754
|
+
getByRole = _render24.getByRole,
|
|
755
|
+
getAllByRole = _render24.getAllByRole;
|
|
628
756
|
|
|
629
757
|
var input = getByRole("combobox");
|
|
630
758
|
expect(input.getAttribute("aria-autocomplete")).toBe("list");
|
|
631
759
|
expect(input.getAttribute("aria-expanded")).toBe("false");
|
|
760
|
+
expect(input.getAttribute("aria-haspopup")).toBe("listbox");
|
|
632
761
|
expect(input.getAttribute("aria-required")).toBe("false");
|
|
633
762
|
|
|
634
763
|
_react2.fireEvent.focus(input);
|
|
@@ -636,121 +765,95 @@ describe("TextInput component tests", function () {
|
|
|
636
765
|
var list = getByRole("listbox");
|
|
637
766
|
expect(input.getAttribute("aria-controls")).toBe(list.id);
|
|
638
767
|
expect(input.getAttribute("aria-expanded")).toBe("true");
|
|
639
|
-
expect(list.getAttribute("aria-label")).toBe("Autocomplete Countries");
|
|
640
768
|
var options = getAllByRole("option");
|
|
641
|
-
expect(options[0].getAttribute("aria-selected")).
|
|
769
|
+
expect(options[0].getAttribute("aria-selected")).toBeNull();
|
|
642
770
|
});
|
|
643
771
|
});
|
|
644
772
|
describe("TextInput component synchronous autosuggest tests", function () {
|
|
645
|
-
test("Autosuggest is displayed when the input gains focus",
|
|
646
|
-
var onChange
|
|
773
|
+
test("Autosuggest is displayed when the input gains focus", function () {
|
|
774
|
+
var onChange = jest.fn();
|
|
647
775
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
suggestions: countries,
|
|
656
|
-
onChange: onChange
|
|
657
|
-
})), getByRole = _render24.getByRole, getByText = _render24.getByText;
|
|
658
|
-
input = getByRole("combobox");
|
|
776
|
+
var _render25 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
777
|
+
label: "Autocomplete Countries",
|
|
778
|
+
suggestions: countries,
|
|
779
|
+
onChange: onChange
|
|
780
|
+
})),
|
|
781
|
+
getByRole = _render25.getByRole,
|
|
782
|
+
getByText = _render25.getByText;
|
|
659
783
|
|
|
660
|
-
|
|
784
|
+
var input = getByRole("combobox");
|
|
661
785
|
|
|
662
|
-
|
|
663
|
-
expect(list).toBeTruthy();
|
|
664
|
-
expect(getByText("Afghanistan")).toBeTruthy();
|
|
665
|
-
expect(getByText("Albania")).toBeTruthy();
|
|
666
|
-
expect(getByText("Algeria")).toBeTruthy();
|
|
667
|
-
expect(getByText("Andorra")).toBeTruthy();
|
|
786
|
+
_react2.fireEvent.focus(input);
|
|
668
787
|
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
})
|
|
676
|
-
test("Autosuggest is displayed when the user clicks the input",
|
|
677
|
-
var onChange
|
|
788
|
+
var list = getByRole("listbox");
|
|
789
|
+
expect(list).toBeTruthy();
|
|
790
|
+
expect(getByText("Afghanistan")).toBeTruthy();
|
|
791
|
+
expect(getByText("Albania")).toBeTruthy();
|
|
792
|
+
expect(getByText("Algeria")).toBeTruthy();
|
|
793
|
+
expect(getByText("Andorra")).toBeTruthy();
|
|
794
|
+
});
|
|
795
|
+
test("Autosuggest is displayed when the user clicks the input", function () {
|
|
796
|
+
var onChange = jest.fn();
|
|
678
797
|
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
suggestions: countries,
|
|
687
|
-
onChange: onChange
|
|
688
|
-
})), getByRole = _render25.getByRole, getByText = _render25.getByText;
|
|
689
|
-
input = getByRole("combobox");
|
|
798
|
+
var _render26 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
799
|
+
label: "Autocomplete Countries",
|
|
800
|
+
suggestions: countries,
|
|
801
|
+
onChange: onChange
|
|
802
|
+
})),
|
|
803
|
+
getByRole = _render26.getByRole,
|
|
804
|
+
getByText = _render26.getByText;
|
|
690
805
|
|
|
691
|
-
|
|
806
|
+
var input = getByRole("combobox");
|
|
692
807
|
|
|
693
|
-
|
|
694
|
-
expect(list).toBeTruthy();
|
|
695
|
-
expect(getByText("Afghanistan")).toBeTruthy();
|
|
696
|
-
expect(getByText("Albania")).toBeTruthy();
|
|
697
|
-
expect(getByText("Algeria")).toBeTruthy();
|
|
698
|
-
expect(getByText("Andorra")).toBeTruthy();
|
|
808
|
+
_react2.fireEvent.focus(input);
|
|
699
809
|
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
})
|
|
707
|
-
test("Autosuggest is displayed while the user is writing (if closed previously, if it is open stays open)",
|
|
708
|
-
var onChange
|
|
810
|
+
var list = getByRole("listbox");
|
|
811
|
+
expect(list).toBeTruthy();
|
|
812
|
+
expect(getByText("Afghanistan")).toBeTruthy();
|
|
813
|
+
expect(getByText("Albania")).toBeTruthy();
|
|
814
|
+
expect(getByText("Algeria")).toBeTruthy();
|
|
815
|
+
expect(getByText("Andorra")).toBeTruthy();
|
|
816
|
+
});
|
|
817
|
+
test("Autosuggest is displayed while the user is writing (if closed previously, if it is open stays open)", function () {
|
|
818
|
+
var onChange = jest.fn();
|
|
709
819
|
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
})), getByRole = _render26.getByRole, queryByRole = _render26.queryByRole, getByText = _render26.getByText, getAllByText = _render26.getAllByText;
|
|
720
|
-
input = getByRole("combobox");
|
|
820
|
+
var _render27 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
821
|
+
label: "Autocomplete Countries",
|
|
822
|
+
suggestions: countries,
|
|
823
|
+
onChange: onChange
|
|
824
|
+
})),
|
|
825
|
+
getByRole = _render27.getByRole,
|
|
826
|
+
queryByRole = _render27.queryByRole,
|
|
827
|
+
getByText = _render27.getByText,
|
|
828
|
+
getAllByText = _render27.getAllByText;
|
|
721
829
|
|
|
722
|
-
|
|
830
|
+
var input = getByRole("combobox");
|
|
723
831
|
|
|
724
|
-
|
|
725
|
-
expect(list).toBeTruthy();
|
|
832
|
+
_react2.fireEvent.focus(input);
|
|
726
833
|
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
code: "Esc",
|
|
730
|
-
keyCode: 27,
|
|
731
|
-
charCode: 27
|
|
732
|
-
});
|
|
834
|
+
var list = getByRole("listbox");
|
|
835
|
+
expect(list).toBeTruthy();
|
|
733
836
|
|
|
734
|
-
|
|
837
|
+
_react2.fireEvent.keyDown(input, {
|
|
838
|
+
key: "Esc",
|
|
839
|
+
code: "Esc",
|
|
840
|
+
keyCode: 27,
|
|
841
|
+
charCode: 27
|
|
842
|
+
});
|
|
735
843
|
|
|
736
|
-
|
|
844
|
+
expect(queryByRole("listbox")).toBeFalsy();
|
|
737
845
|
|
|
738
|
-
|
|
739
|
-
expect(getAllByText("B").length).toBe(4);
|
|
740
|
-
expect(getByText("ahamas")).toBeTruthy();
|
|
741
|
-
expect(getByText("ahrain")).toBeTruthy();
|
|
742
|
-
expect(getByText("angladesh")).toBeTruthy();
|
|
743
|
-
expect(getByText("arbados")).toBeTruthy();
|
|
846
|
+
_userEvent["default"].type(input, "B");
|
|
744
847
|
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
})
|
|
848
|
+
expect(list).toBeTruthy();
|
|
849
|
+
expect(getAllByText("B").length).toBe(4);
|
|
850
|
+
expect(getByText("ahamas")).toBeTruthy();
|
|
851
|
+
expect(getByText("ahrain")).toBeTruthy();
|
|
852
|
+
expect(getByText("angladesh")).toBeTruthy();
|
|
853
|
+
expect(getByText("arbados")).toBeTruthy();
|
|
854
|
+
});
|
|
752
855
|
test("Autosuggest displays filtered when the input has a default value", function () {
|
|
753
|
-
var
|
|
856
|
+
var _render28 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
754
857
|
label: "Uncontrolled suggestions filtered by default",
|
|
755
858
|
helperText: "Example of helper text",
|
|
756
859
|
placeholder: "Placeholder",
|
|
@@ -759,9 +862,9 @@ describe("TextInput component synchronous autosuggest tests", function () {
|
|
|
759
862
|
suggestions: ["Suggestion 11", "Suggestion 12", "Suggestion 23", "Suggestion 24"],
|
|
760
863
|
clearable: true
|
|
761
864
|
})),
|
|
762
|
-
getByRole =
|
|
763
|
-
getByText =
|
|
764
|
-
getAllByText =
|
|
865
|
+
getByRole = _render28.getByRole,
|
|
866
|
+
getByText = _render28.getByText,
|
|
867
|
+
getAllByText = _render28.getAllByText;
|
|
765
868
|
|
|
766
869
|
var input = getByRole("combobox");
|
|
767
870
|
expect(input.value).toBe("Suggestion 2");
|
|
@@ -772,518 +875,510 @@ describe("TextInput component synchronous autosuggest tests", function () {
|
|
|
772
875
|
expect(getByText("3")).toBeTruthy();
|
|
773
876
|
expect(getByText("4")).toBeTruthy();
|
|
774
877
|
});
|
|
775
|
-
test("Autosuggest is not displayed when prop suggestions is an empty array",
|
|
776
|
-
var onChange
|
|
878
|
+
test("Autosuggest is not displayed when prop suggestions is an empty array", function () {
|
|
879
|
+
var onChange = jest.fn();
|
|
777
880
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
label: "Autocomplete Countries",
|
|
785
|
-
suggestions: [],
|
|
786
|
-
onChange: onChange
|
|
787
|
-
})), queryByRole = _render28.queryByRole;
|
|
788
|
-
input = queryByRole("textbox");
|
|
881
|
+
var _render29 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
882
|
+
label: "Autocomplete Countries",
|
|
883
|
+
suggestions: [],
|
|
884
|
+
onChange: onChange
|
|
885
|
+
})),
|
|
886
|
+
queryByRole = _render29.queryByRole;
|
|
789
887
|
|
|
790
|
-
|
|
888
|
+
var input = queryByRole("textbox");
|
|
791
889
|
|
|
792
|
-
|
|
890
|
+
_react2.fireEvent.focus(input);
|
|
793
891
|
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
}
|
|
799
|
-
}, _callee5);
|
|
800
|
-
})));
|
|
801
|
-
test("Autosuggest closes the listbox when there are no matches for the user's input", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
|
|
802
|
-
var onChange, _render29, getByRole, queryByRole, getByText, input, list;
|
|
892
|
+
expect(queryByRole("listbox")).toBeFalsy();
|
|
893
|
+
});
|
|
894
|
+
test("Autosuggest closes the listbox when there are no matches for the user's input", function () {
|
|
895
|
+
var onChange = jest.fn();
|
|
803
896
|
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
onChange: onChange
|
|
813
|
-
})), getByRole = _render29.getByRole, queryByRole = _render29.queryByRole, getByText = _render29.getByText;
|
|
814
|
-
input = getByRole("combobox");
|
|
897
|
+
var _render30 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
898
|
+
label: "Autocomplete Countries",
|
|
899
|
+
suggestions: countries,
|
|
900
|
+
onChange: onChange
|
|
901
|
+
})),
|
|
902
|
+
getByRole = _render30.getByRole,
|
|
903
|
+
queryByRole = _render30.queryByRole,
|
|
904
|
+
getByText = _render30.getByText;
|
|
815
905
|
|
|
816
|
-
|
|
906
|
+
var input = getByRole("combobox");
|
|
817
907
|
|
|
818
|
-
|
|
819
|
-
expect(list).toBeTruthy();
|
|
820
|
-
expect(getByText("Afghanistan")).toBeTruthy();
|
|
908
|
+
_react2.fireEvent.focus(input);
|
|
821
909
|
|
|
822
|
-
|
|
910
|
+
var list = getByRole("listbox");
|
|
911
|
+
expect(list).toBeTruthy();
|
|
912
|
+
expect(getByText("Afghanistan")).toBeTruthy();
|
|
823
913
|
|
|
824
|
-
|
|
914
|
+
_userEvent["default"].type(input, "x");
|
|
825
915
|
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
}
|
|
831
|
-
}, _callee6);
|
|
832
|
-
})));
|
|
833
|
-
test("Autosuggest with no matches founded doesn't let the listbox to be opened", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
|
|
834
|
-
var onChange, _render30, getByRole, queryByRole, getByText, input, list;
|
|
916
|
+
expect(queryByRole("listbox")).toBeFalsy();
|
|
917
|
+
});
|
|
918
|
+
test("Autosuggest with no matches founded doesn't let the listbox to be opened", function () {
|
|
919
|
+
var onChange = jest.fn();
|
|
835
920
|
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
onChange: onChange
|
|
845
|
-
})), getByRole = _render30.getByRole, queryByRole = _render30.queryByRole, getByText = _render30.getByText;
|
|
846
|
-
input = getByRole("combobox");
|
|
921
|
+
var _render31 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
922
|
+
label: "Autocomplete Countries",
|
|
923
|
+
suggestions: countries,
|
|
924
|
+
onChange: onChange
|
|
925
|
+
})),
|
|
926
|
+
getByRole = _render31.getByRole,
|
|
927
|
+
queryByRole = _render31.queryByRole,
|
|
928
|
+
getByText = _render31.getByText;
|
|
847
929
|
|
|
848
|
-
|
|
930
|
+
var input = getByRole("combobox");
|
|
849
931
|
|
|
850
|
-
|
|
851
|
-
expect(list).toBeTruthy();
|
|
852
|
-
expect(getByText("Afghanistan")).toBeTruthy();
|
|
932
|
+
_react2.fireEvent.focus(input);
|
|
853
933
|
|
|
854
|
-
|
|
934
|
+
var list = getByRole("listbox");
|
|
935
|
+
expect(list).toBeTruthy();
|
|
936
|
+
expect(getByText("Afghanistan")).toBeTruthy();
|
|
855
937
|
|
|
856
|
-
|
|
938
|
+
_userEvent["default"].type(input, "x");
|
|
857
939
|
|
|
858
|
-
|
|
940
|
+
expect(queryByRole("listbox")).toBeFalsy();
|
|
859
941
|
|
|
860
|
-
|
|
942
|
+
_react2.fireEvent.focus(input);
|
|
861
943
|
|
|
862
|
-
|
|
863
|
-
key: "ArrowUp",
|
|
864
|
-
code: "ArrowUp",
|
|
865
|
-
keyCode: 38,
|
|
866
|
-
charCode: 38
|
|
867
|
-
});
|
|
944
|
+
expect(queryByRole("listbox")).toBeFalsy();
|
|
868
945
|
|
|
869
|
-
|
|
946
|
+
_react2.fireEvent.keyDown(input, {
|
|
947
|
+
key: "ArrowUp",
|
|
948
|
+
code: "ArrowUp",
|
|
949
|
+
keyCode: 38,
|
|
950
|
+
charCode: 38
|
|
951
|
+
});
|
|
870
952
|
|
|
871
|
-
|
|
872
|
-
key: "ArrowDown",
|
|
873
|
-
code: "ArrowDown",
|
|
874
|
-
keyCode: 40,
|
|
875
|
-
charCode: 40
|
|
876
|
-
});
|
|
953
|
+
expect(queryByRole("listbox")).toBeFalsy();
|
|
877
954
|
|
|
878
|
-
|
|
955
|
+
_react2.fireEvent.keyDown(input, {
|
|
956
|
+
key: "ArrowDown",
|
|
957
|
+
code: "ArrowDown",
|
|
958
|
+
keyCode: 40,
|
|
959
|
+
charCode: 40
|
|
960
|
+
});
|
|
879
961
|
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
}
|
|
885
|
-
}, _callee7);
|
|
886
|
-
})));
|
|
887
|
-
test("Autosuggest uncontrolled - Suggestion selected by click", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
|
|
888
|
-
var onChange, _render31, getByRole, getByText, queryByRole, input;
|
|
962
|
+
expect(queryByRole("listbox")).toBeFalsy();
|
|
963
|
+
});
|
|
964
|
+
test("Autosuggest uncontrolled - Suggestion selected by click", function () {
|
|
965
|
+
var onChange = jest.fn();
|
|
889
966
|
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
onChange: onChange
|
|
899
|
-
})), getByRole = _render31.getByRole, getByText = _render31.getByText, queryByRole = _render31.queryByRole;
|
|
900
|
-
input = getByRole("combobox");
|
|
967
|
+
var _render32 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
968
|
+
label: "Autocomplete Countries",
|
|
969
|
+
suggestions: countries,
|
|
970
|
+
onChange: onChange
|
|
971
|
+
})),
|
|
972
|
+
getByRole = _render32.getByRole,
|
|
973
|
+
getByText = _render32.getByText,
|
|
974
|
+
queryByRole = _render32.queryByRole;
|
|
901
975
|
|
|
902
|
-
|
|
976
|
+
var input = getByRole("combobox");
|
|
903
977
|
|
|
904
|
-
|
|
978
|
+
_react2.fireEvent.focus(input);
|
|
905
979
|
|
|
906
|
-
|
|
907
|
-
expect(getByText("Alba")).toBeTruthy();
|
|
908
|
-
expect(getByText("nia")).toBeTruthy();
|
|
980
|
+
_userEvent["default"].type(input, "Alba");
|
|
909
981
|
|
|
910
|
-
|
|
982
|
+
expect(onChange).toHaveBeenCalled();
|
|
983
|
+
expect(getByText("Alba")).toBeTruthy();
|
|
984
|
+
expect(getByText("nia")).toBeTruthy();
|
|
911
985
|
|
|
912
|
-
|
|
913
|
-
expect(queryByRole("listbox")).toBeFalsy();
|
|
986
|
+
_userEvent["default"].click(getByRole("option"));
|
|
914
987
|
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
}, _callee8);
|
|
921
|
-
})));
|
|
922
|
-
test("Autosuggest controlled - Suggestion selected by click", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
|
|
923
|
-
var onChange, _render32, getByRole, getByText, queryByRole, input;
|
|
988
|
+
expect(input.value).toBe("Albania");
|
|
989
|
+
expect(queryByRole("listbox")).toBeFalsy();
|
|
990
|
+
});
|
|
991
|
+
test("Autosuggest controlled - Suggestion selected by click", function () {
|
|
992
|
+
var onChange = jest.fn();
|
|
924
993
|
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
onChange: onChange
|
|
935
|
-
})), getByRole = _render32.getByRole, getByText = _render32.getByText, queryByRole = _render32.queryByRole;
|
|
936
|
-
input = getByRole("combobox");
|
|
994
|
+
var _render33 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
995
|
+
label: "Autocomplete Countries",
|
|
996
|
+
value: "Andor",
|
|
997
|
+
suggestions: countries,
|
|
998
|
+
onChange: onChange
|
|
999
|
+
})),
|
|
1000
|
+
getByRole = _render33.getByRole,
|
|
1001
|
+
getByText = _render33.getByText,
|
|
1002
|
+
queryByRole = _render33.queryByRole;
|
|
937
1003
|
|
|
938
|
-
|
|
1004
|
+
var input = getByRole("combobox");
|
|
939
1005
|
|
|
940
|
-
|
|
941
|
-
expect(getByText("Andor")).toBeTruthy();
|
|
942
|
-
expect(getByText("ra")).toBeTruthy();
|
|
1006
|
+
_userEvent["default"].click(getByText("Autocomplete Countries"));
|
|
943
1007
|
|
|
944
|
-
|
|
1008
|
+
expect(input.value).toBe("Andor");
|
|
1009
|
+
expect(getByText("Andor")).toBeTruthy();
|
|
1010
|
+
expect(getByText("ra")).toBeTruthy();
|
|
945
1011
|
|
|
946
|
-
|
|
947
|
-
value: "Andorra",
|
|
948
|
-
error: null
|
|
949
|
-
});
|
|
950
|
-
expect(queryByRole("listbox")).toBeFalsy();
|
|
1012
|
+
_userEvent["default"].click(getByRole("option"));
|
|
951
1013
|
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
var onChange, onBlur, _render33, getByRole, getByText, input;
|
|
1014
|
+
expect(onChange).toHaveBeenCalledWith({
|
|
1015
|
+
value: "Andorra"
|
|
1016
|
+
});
|
|
1017
|
+
expect(queryByRole("listbox")).toBeFalsy();
|
|
1018
|
+
});
|
|
1019
|
+
test("Autosuggest - Pattern constraint", function () {
|
|
1020
|
+
var onChange = jest.fn();
|
|
1021
|
+
var onBlur = jest.fn();
|
|
961
1022
|
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
onChange: onChange,
|
|
972
|
-
onBlur: onBlur,
|
|
973
|
-
pattern: "^.*(?=.*[a-zA-Z])(?=.*\\d)(?=.*[!&$%&? \"]).*$"
|
|
974
|
-
})), getByRole = _render33.getByRole, getByText = _render33.getByText;
|
|
975
|
-
input = getByRole("combobox");
|
|
1023
|
+
var _render34 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1024
|
+
label: "Autocomplete Countries",
|
|
1025
|
+
suggestions: countries,
|
|
1026
|
+
onChange: onChange,
|
|
1027
|
+
onBlur: onBlur,
|
|
1028
|
+
pattern: "^.*(?=.*[a-zA-Z])(?=.*\\d)(?=.*[!&$%&? \"]).*$"
|
|
1029
|
+
})),
|
|
1030
|
+
getByRole = _render34.getByRole,
|
|
1031
|
+
getByText = _render34.getByText;
|
|
976
1032
|
|
|
977
|
-
|
|
1033
|
+
var input = getByRole("combobox");
|
|
978
1034
|
|
|
979
|
-
|
|
1035
|
+
_react2.fireEvent.focus(input);
|
|
980
1036
|
|
|
981
|
-
|
|
982
|
-
expect(getByText("ra")).toBeTruthy();
|
|
1037
|
+
_userEvent["default"].type(input, "Andor");
|
|
983
1038
|
|
|
984
|
-
|
|
1039
|
+
expect(getByText("Andor")).toBeTruthy();
|
|
1040
|
+
expect(getByText("ra")).toBeTruthy();
|
|
985
1041
|
|
|
986
|
-
|
|
987
|
-
value: "Andorra",
|
|
988
|
-
error: "Please match the format requested."
|
|
989
|
-
});
|
|
1042
|
+
_userEvent["default"].click(getByRole("option"));
|
|
990
1043
|
|
|
991
|
-
|
|
1044
|
+
expect(onChange).toHaveBeenCalledWith({
|
|
1045
|
+
value: "Andorra",
|
|
1046
|
+
error: "Please match the format requested."
|
|
1047
|
+
});
|
|
992
1048
|
|
|
993
|
-
|
|
994
|
-
value: "Andorra",
|
|
995
|
-
error: "Please match the format requested."
|
|
996
|
-
});
|
|
1049
|
+
_react2.fireEvent.blur(input);
|
|
997
1050
|
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
var onChange, onBlur, _render34, getByText, getByRole, input;
|
|
1051
|
+
expect(onBlur).toHaveBeenCalledWith({
|
|
1052
|
+
value: "Andorra",
|
|
1053
|
+
error: "Please match the format requested."
|
|
1054
|
+
});
|
|
1055
|
+
});
|
|
1056
|
+
test("Autosuggest - Length constraint", function () {
|
|
1057
|
+
var onChange = jest.fn();
|
|
1058
|
+
var onBlur = jest.fn();
|
|
1007
1059
|
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
onBlur: onBlur,
|
|
1019
|
-
minLength: 5,
|
|
1020
|
-
maxLength: 10
|
|
1021
|
-
})), getByText = _render34.getByText, getByRole = _render34.getByRole;
|
|
1022
|
-
input = getByRole("combobox");
|
|
1060
|
+
var _render35 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1061
|
+
label: "Autocomplete Countries",
|
|
1062
|
+
suggestions: countries,
|
|
1063
|
+
onChange: onChange,
|
|
1064
|
+
onBlur: onBlur,
|
|
1065
|
+
minLength: 5,
|
|
1066
|
+
maxLength: 10
|
|
1067
|
+
})),
|
|
1068
|
+
getByText = _render35.getByText,
|
|
1069
|
+
getByRole = _render35.getByRole;
|
|
1023
1070
|
|
|
1024
|
-
|
|
1071
|
+
var input = getByRole("combobox");
|
|
1025
1072
|
|
|
1026
|
-
|
|
1073
|
+
_react2.fireEvent.focus(input);
|
|
1027
1074
|
|
|
1028
|
-
|
|
1029
|
-
expect(getByText("d")).toBeTruthy();
|
|
1075
|
+
_userEvent["default"].type(input, "Cha");
|
|
1030
1076
|
|
|
1031
|
-
|
|
1077
|
+
expect(getByText("Cha")).toBeTruthy();
|
|
1078
|
+
expect(getByText("d")).toBeTruthy();
|
|
1032
1079
|
|
|
1033
|
-
|
|
1034
|
-
value: "Cha",
|
|
1035
|
-
error: "Min length 5, max length 10."
|
|
1036
|
-
});
|
|
1080
|
+
_userEvent["default"].click(getByRole("option"));
|
|
1037
1081
|
|
|
1038
|
-
|
|
1082
|
+
expect(onChange).toHaveBeenCalledWith({
|
|
1083
|
+
value: "Cha",
|
|
1084
|
+
error: "Min length 5, max length 10."
|
|
1085
|
+
});
|
|
1039
1086
|
|
|
1040
|
-
|
|
1041
|
-
value: "Chad",
|
|
1042
|
-
error: "Min length 5, max length 10."
|
|
1043
|
-
});
|
|
1087
|
+
_react2.fireEvent.blur(input);
|
|
1044
1088
|
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
test("Autosuggest keys: arrow down key opens autosuggest, active first option is selected with Enter and closes the autosuggest", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
|
|
1053
|
-
var onChange, _render35, getByRole, queryByRole, input, list;
|
|
1089
|
+
expect(onBlur).toHaveBeenCalledWith({
|
|
1090
|
+
value: "Chad",
|
|
1091
|
+
error: "Min length 5, max length 10."
|
|
1092
|
+
});
|
|
1093
|
+
});
|
|
1094
|
+
test("Autosuggest keys: arrow down key opens autosuggest, active first option is selected with Enter and closes the autosuggest", function () {
|
|
1095
|
+
var onChange = jest.fn();
|
|
1054
1096
|
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
suggestions: countries,
|
|
1063
|
-
onChange: onChange
|
|
1064
|
-
})), getByRole = _render35.getByRole, queryByRole = _render35.queryByRole;
|
|
1065
|
-
input = getByRole("combobox");
|
|
1097
|
+
var _render36 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1098
|
+
label: "Autocomplete Countries",
|
|
1099
|
+
suggestions: countries,
|
|
1100
|
+
onChange: onChange
|
|
1101
|
+
})),
|
|
1102
|
+
getByRole = _render36.getByRole,
|
|
1103
|
+
queryByRole = _render36.queryByRole;
|
|
1066
1104
|
|
|
1067
|
-
|
|
1068
|
-
key: "ArrowDown",
|
|
1069
|
-
code: "ArrowDown",
|
|
1070
|
-
keyCode: 40,
|
|
1071
|
-
charCode: 40
|
|
1072
|
-
});
|
|
1105
|
+
var input = getByRole("combobox");
|
|
1073
1106
|
|
|
1074
|
-
|
|
1075
|
-
|
|
1107
|
+
_react2.fireEvent.keyDown(input, {
|
|
1108
|
+
key: "ArrowDown",
|
|
1109
|
+
code: "ArrowDown",
|
|
1110
|
+
keyCode: 40,
|
|
1111
|
+
charCode: 40
|
|
1112
|
+
});
|
|
1113
|
+
|
|
1114
|
+
var list = getByRole("listbox");
|
|
1115
|
+
expect(list).toBeTruthy();
|
|
1116
|
+
|
|
1117
|
+
_react2.fireEvent.keyDown(input, {
|
|
1118
|
+
key: "Enter",
|
|
1119
|
+
code: "Enter",
|
|
1120
|
+
keyCode: 13,
|
|
1121
|
+
charCode: 13
|
|
1122
|
+
});
|
|
1123
|
+
|
|
1124
|
+
expect(input.value).toBe("Afghanistan");
|
|
1125
|
+
expect(queryByRole("list")).toBeFalsy();
|
|
1126
|
+
});
|
|
1127
|
+
test("Autosuggest keys: arrow up key opens autosuggest, active last option is selected with Enter and closes the autosuggest", function () {
|
|
1128
|
+
var onChange = jest.fn();
|
|
1129
|
+
|
|
1130
|
+
var _render37 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1131
|
+
label: "Autocomplete Countries",
|
|
1132
|
+
suggestions: countries,
|
|
1133
|
+
onChange: onChange
|
|
1134
|
+
})),
|
|
1135
|
+
getByRole = _render37.getByRole,
|
|
1136
|
+
queryByRole = _render37.queryByRole;
|
|
1137
|
+
|
|
1138
|
+
var input = getByRole("combobox");
|
|
1139
|
+
|
|
1140
|
+
_react2.fireEvent.keyDown(input, {
|
|
1141
|
+
key: "ArrowUp",
|
|
1142
|
+
code: "ArrowUp",
|
|
1143
|
+
keyCode: 38,
|
|
1144
|
+
charCode: 38
|
|
1145
|
+
});
|
|
1146
|
+
|
|
1147
|
+
var list = getByRole("listbox");
|
|
1148
|
+
expect(list).toBeTruthy();
|
|
1149
|
+
|
|
1150
|
+
_react2.fireEvent.keyDown(input, {
|
|
1151
|
+
key: "Enter",
|
|
1152
|
+
code: "Enter",
|
|
1153
|
+
keyCode: 13,
|
|
1154
|
+
charCode: 13
|
|
1155
|
+
});
|
|
1156
|
+
|
|
1157
|
+
expect(input.value).toBe("Djibouti");
|
|
1158
|
+
expect(queryByRole("list")).toBeFalsy();
|
|
1159
|
+
});
|
|
1160
|
+
test("Autosuggest keys: Esc key closes the autosuggest and cleans the input", function () {
|
|
1161
|
+
var onChange = jest.fn();
|
|
1162
|
+
|
|
1163
|
+
var _render38 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1164
|
+
label: "Autocomplete Countries",
|
|
1165
|
+
suggestions: countries,
|
|
1166
|
+
onChange: onChange
|
|
1167
|
+
})),
|
|
1168
|
+
getByRole = _render38.getByRole,
|
|
1169
|
+
queryByRole = _render38.queryByRole;
|
|
1170
|
+
|
|
1171
|
+
var input = getByRole("combobox");
|
|
1172
|
+
|
|
1173
|
+
_react2.fireEvent.focus(input);
|
|
1174
|
+
|
|
1175
|
+
_userEvent["default"].type(input, "Bangla");
|
|
1176
|
+
|
|
1177
|
+
var list = getByRole("listbox");
|
|
1178
|
+
expect(list).toBeTruthy();
|
|
1179
|
+
|
|
1180
|
+
_react2.fireEvent.keyDown(input, {
|
|
1181
|
+
key: "Esc",
|
|
1182
|
+
code: "Esc",
|
|
1183
|
+
keyCode: 27,
|
|
1184
|
+
charCode: 27
|
|
1185
|
+
});
|
|
1186
|
+
|
|
1187
|
+
expect(input.value).toBe("");
|
|
1188
|
+
expect(queryByRole("listbox")).toBeFalsy();
|
|
1189
|
+
});
|
|
1190
|
+
test("Autosuggest keys: Enter, if no active suggestion closes the autosuggest", function () {
|
|
1191
|
+
var onChange = jest.fn();
|
|
1192
|
+
|
|
1193
|
+
var _render39 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1194
|
+
label: "Autocomplete Countries",
|
|
1195
|
+
suggestions: countries,
|
|
1196
|
+
onChange: onChange
|
|
1197
|
+
})),
|
|
1198
|
+
getByRole = _render39.getByRole,
|
|
1199
|
+
queryByRole = _render39.queryByRole;
|
|
1200
|
+
|
|
1201
|
+
var input = getByRole("combobox");
|
|
1202
|
+
|
|
1203
|
+
_react2.fireEvent.focus(input);
|
|
1204
|
+
|
|
1205
|
+
var list = getByRole("listbox");
|
|
1206
|
+
expect(list).toBeTruthy();
|
|
1207
|
+
|
|
1208
|
+
_react2.fireEvent.keyDown(input, {
|
|
1209
|
+
key: "Enter",
|
|
1210
|
+
code: "Enter",
|
|
1211
|
+
keyCode: 27,
|
|
1212
|
+
charCode: 27
|
|
1213
|
+
});
|
|
1214
|
+
|
|
1215
|
+
expect(input.value).toBe("");
|
|
1216
|
+
expect(queryByRole("list")).toBeFalsy();
|
|
1217
|
+
});
|
|
1218
|
+
test("Autosuggest complex key secuence: write, arrow up two times, arrow down and select with Enter. Then, clean with Esc.", function () {
|
|
1219
|
+
var onChange = jest.fn();
|
|
1076
1220
|
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1221
|
+
var _render40 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1222
|
+
label: "Autocomplete Countries",
|
|
1223
|
+
suggestions: countries,
|
|
1224
|
+
onChange: onChange
|
|
1225
|
+
})),
|
|
1226
|
+
getByRole = _render40.getByRole,
|
|
1227
|
+
queryByRole = _render40.queryByRole;
|
|
1083
1228
|
|
|
1084
|
-
|
|
1085
|
-
expect(queryByRole("list")).toBeFalsy();
|
|
1229
|
+
var input = getByRole("combobox");
|
|
1086
1230
|
|
|
1087
|
-
|
|
1088
|
-
case "end":
|
|
1089
|
-
return _context12.stop();
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
}, _callee12);
|
|
1093
|
-
})));
|
|
1094
|
-
test("Autosuggest keys: arrow up key opens autosuggest, active last option is selected with Enter and closes the autosuggest", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
|
|
1095
|
-
var onChange, _render36, getByRole, queryByRole, input, list;
|
|
1231
|
+
_react2.fireEvent.focus(input);
|
|
1096
1232
|
|
|
1097
|
-
|
|
1098
|
-
while (1) {
|
|
1099
|
-
switch (_context13.prev = _context13.next) {
|
|
1100
|
-
case 0:
|
|
1101
|
-
onChange = jest.fn();
|
|
1102
|
-
_render36 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1103
|
-
label: "Autocomplete Countries",
|
|
1104
|
-
suggestions: countries,
|
|
1105
|
-
onChange: onChange
|
|
1106
|
-
})), getByRole = _render36.getByRole, queryByRole = _render36.queryByRole;
|
|
1107
|
-
input = getByRole("combobox");
|
|
1233
|
+
_userEvent["default"].type(input, "Ba");
|
|
1108
1234
|
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1235
|
+
_react2.fireEvent.keyDown(input, {
|
|
1236
|
+
key: "ArrowUp",
|
|
1237
|
+
code: "ArrowUp",
|
|
1238
|
+
keyCode: 38,
|
|
1239
|
+
charCode: 38
|
|
1240
|
+
});
|
|
1115
1241
|
|
|
1116
|
-
|
|
1117
|
-
|
|
1242
|
+
_react2.fireEvent.keyDown(input, {
|
|
1243
|
+
key: "ArrowUp",
|
|
1244
|
+
code: "ArrowUpp",
|
|
1245
|
+
keyCode: 38,
|
|
1246
|
+
charCode: 38
|
|
1247
|
+
});
|
|
1118
1248
|
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1249
|
+
_react2.fireEvent.keyDown(input, {
|
|
1250
|
+
key: "ArrowDown",
|
|
1251
|
+
code: "ArrowDown",
|
|
1252
|
+
keyCode: 40,
|
|
1253
|
+
charCode: 40
|
|
1254
|
+
});
|
|
1125
1255
|
|
|
1126
|
-
|
|
1127
|
-
|
|
1256
|
+
_react2.fireEvent.keyDown(input, {
|
|
1257
|
+
key: "Enter",
|
|
1258
|
+
code: "Enter",
|
|
1259
|
+
keyCode: 13,
|
|
1260
|
+
charCode: 13
|
|
1261
|
+
});
|
|
1128
1262
|
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
return _context13.stop();
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
}, _callee13);
|
|
1135
|
-
})));
|
|
1136
|
-
test("Autosuggest keys: Esc key closes the autosuggest and cleans the input", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee14() {
|
|
1137
|
-
var onChange, _render37, getByRole, queryByRole, input, list;
|
|
1263
|
+
expect(input.value).toBe("Barbados");
|
|
1264
|
+
expect(queryByRole("listbox")).toBeFalsy();
|
|
1138
1265
|
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
label: "Autocomplete Countries",
|
|
1146
|
-
suggestions: countries,
|
|
1147
|
-
onChange: onChange
|
|
1148
|
-
})), getByRole = _render37.getByRole, queryByRole = _render37.queryByRole;
|
|
1149
|
-
input = getByRole("combobox");
|
|
1266
|
+
_react2.fireEvent.keyDown(input, {
|
|
1267
|
+
key: "Esc",
|
|
1268
|
+
code: "Esp",
|
|
1269
|
+
keyCode: 27,
|
|
1270
|
+
charCode: 27
|
|
1271
|
+
});
|
|
1150
1272
|
|
|
1151
|
-
|
|
1273
|
+
expect(input.value).toBe("");
|
|
1274
|
+
expect(queryByRole("listbox")).toBeFalsy();
|
|
1275
|
+
});
|
|
1276
|
+
test("Autosuggest escapes special characters", function () {
|
|
1277
|
+
var onChange = jest.fn();
|
|
1152
1278
|
|
|
1153
|
-
|
|
1279
|
+
var _render41 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1280
|
+
label: "Autocomplete Countries",
|
|
1281
|
+
suggestions: specialCharacters,
|
|
1282
|
+
onChange: onChange
|
|
1283
|
+
})),
|
|
1284
|
+
getAllByText = _render41.getAllByText,
|
|
1285
|
+
getByRole = _render41.getByRole;
|
|
1154
1286
|
|
|
1155
|
-
|
|
1156
|
-
expect(list).toBeTruthy();
|
|
1287
|
+
var input = getByRole("combobox");
|
|
1157
1288
|
|
|
1158
|
-
|
|
1159
|
-
key: "Esc",
|
|
1160
|
-
code: "Esc",
|
|
1161
|
-
keyCode: 27,
|
|
1162
|
-
charCode: 27
|
|
1163
|
-
});
|
|
1289
|
+
_react2.fireEvent.focus(input);
|
|
1164
1290
|
|
|
1165
|
-
|
|
1166
|
-
expect(queryByRole("listbox")).toBeFalsy();
|
|
1291
|
+
var list = getByRole("listbox");
|
|
1167
1292
|
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
}
|
|
1293
|
+
_react2.fireEvent.change(input, {
|
|
1294
|
+
target: {
|
|
1295
|
+
value: "/"
|
|
1172
1296
|
}
|
|
1173
|
-
}
|
|
1174
|
-
})));
|
|
1175
|
-
test("Autosuggest keys: Enter, if no active suggestion closes the autosuggest", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee15() {
|
|
1176
|
-
var onChange, _render38, getByRole, queryByRole, input, list;
|
|
1297
|
+
});
|
|
1177
1298
|
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
switch (_context15.prev = _context15.next) {
|
|
1181
|
-
case 0:
|
|
1182
|
-
onChange = jest.fn();
|
|
1183
|
-
_render38 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1184
|
-
label: "Autocomplete Countries",
|
|
1185
|
-
suggestions: countries,
|
|
1186
|
-
onChange: onChange
|
|
1187
|
-
})), getByRole = _render38.getByRole, queryByRole = _render38.queryByRole;
|
|
1188
|
-
input = getByRole("combobox");
|
|
1299
|
+
expect(list).toBeTruthy();
|
|
1300
|
+
expect(getAllByText("/").length).toBe(1);
|
|
1189
1301
|
|
|
1190
|
-
|
|
1302
|
+
_react2.fireEvent.change(input, {
|
|
1303
|
+
target: {
|
|
1304
|
+
value: "\\"
|
|
1305
|
+
}
|
|
1306
|
+
});
|
|
1191
1307
|
|
|
1192
|
-
|
|
1193
|
-
|
|
1308
|
+
expect(list).toBeTruthy();
|
|
1309
|
+
expect(getAllByText("\\").length).toBe(1);
|
|
1194
1310
|
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
});
|
|
1311
|
+
_react2.fireEvent.change(input, {
|
|
1312
|
+
target: {
|
|
1313
|
+
value: "*"
|
|
1314
|
+
}
|
|
1315
|
+
});
|
|
1201
1316
|
|
|
1202
|
-
|
|
1203
|
-
|
|
1317
|
+
expect(list).toBeTruthy();
|
|
1318
|
+
expect(getAllByText("*").length).toBe(2);
|
|
1204
1319
|
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
}
|
|
1320
|
+
_react2.fireEvent.change(input, {
|
|
1321
|
+
target: {
|
|
1322
|
+
value: "("
|
|
1209
1323
|
}
|
|
1210
|
-
}
|
|
1211
|
-
})));
|
|
1212
|
-
test("Autosuggest complex key secuence: write, arrow up two times, arrow down and select with Enter. Then, clean with Esc.", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee16() {
|
|
1213
|
-
var onChange, _render39, getByRole, queryByRole, input;
|
|
1214
|
-
|
|
1215
|
-
return _regenerator["default"].wrap(function _callee16$(_context16) {
|
|
1216
|
-
while (1) {
|
|
1217
|
-
switch (_context16.prev = _context16.next) {
|
|
1218
|
-
case 0:
|
|
1219
|
-
onChange = jest.fn();
|
|
1220
|
-
_render39 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1221
|
-
label: "Autocomplete Countries",
|
|
1222
|
-
suggestions: countries,
|
|
1223
|
-
onChange: onChange
|
|
1224
|
-
})), getByRole = _render39.getByRole, queryByRole = _render39.queryByRole;
|
|
1225
|
-
input = getByRole("combobox");
|
|
1324
|
+
});
|
|
1226
1325
|
|
|
1227
|
-
|
|
1326
|
+
expect(list).toBeTruthy();
|
|
1327
|
+
expect(getAllByText("(").length).toBe(1);
|
|
1228
1328
|
|
|
1229
|
-
|
|
1329
|
+
_react2.fireEvent.change(input, {
|
|
1330
|
+
target: {
|
|
1331
|
+
value: ")"
|
|
1332
|
+
}
|
|
1333
|
+
});
|
|
1230
1334
|
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
code: "ArrowUp",
|
|
1234
|
-
keyCode: 38,
|
|
1235
|
-
charCode: 38
|
|
1236
|
-
});
|
|
1335
|
+
expect(list).toBeTruthy();
|
|
1336
|
+
expect(getAllByText(")").length).toBe(1);
|
|
1237
1337
|
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
});
|
|
1338
|
+
_react2.fireEvent.change(input, {
|
|
1339
|
+
target: {
|
|
1340
|
+
value: "["
|
|
1341
|
+
}
|
|
1342
|
+
});
|
|
1244
1343
|
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
code: "ArrowDown",
|
|
1248
|
-
keyCode: 40,
|
|
1249
|
-
charCode: 40
|
|
1250
|
-
});
|
|
1344
|
+
expect(list).toBeTruthy();
|
|
1345
|
+
expect(getAllByText("[").length).toBe(1);
|
|
1251
1346
|
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
});
|
|
1347
|
+
_react2.fireEvent.change(input, {
|
|
1348
|
+
target: {
|
|
1349
|
+
value: "]"
|
|
1350
|
+
}
|
|
1351
|
+
});
|
|
1258
1352
|
|
|
1259
|
-
|
|
1260
|
-
|
|
1353
|
+
expect(list).toBeTruthy();
|
|
1354
|
+
expect(getAllByText("]").length).toBe(1);
|
|
1261
1355
|
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
});
|
|
1356
|
+
_react2.fireEvent.change(input, {
|
|
1357
|
+
target: {
|
|
1358
|
+
value: "+"
|
|
1359
|
+
}
|
|
1360
|
+
});
|
|
1268
1361
|
|
|
1269
|
-
|
|
1270
|
-
|
|
1362
|
+
expect(list).toBeTruthy();
|
|
1363
|
+
expect(getAllByText("+").length).toBe(1);
|
|
1271
1364
|
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
}
|
|
1365
|
+
_react2.fireEvent.change(input, {
|
|
1366
|
+
target: {
|
|
1367
|
+
value: "?"
|
|
1276
1368
|
}
|
|
1277
|
-
}
|
|
1278
|
-
|
|
1369
|
+
});
|
|
1370
|
+
|
|
1371
|
+
expect(list).toBeTruthy();
|
|
1372
|
+
expect(getAllByText("?").length).toBe(1);
|
|
1373
|
+
});
|
|
1279
1374
|
});
|
|
1280
1375
|
describe("TextInput component asynchronous autosuggest tests", function () {
|
|
1281
|
-
test("Autosuggest 'Searching...' message is shown", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
1282
|
-
var callbackFunc, onChange,
|
|
1376
|
+
test("Autosuggest 'Searching...' message is shown", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
1377
|
+
var callbackFunc, onChange, _render42, getByRole, getByText, input;
|
|
1283
1378
|
|
|
1284
|
-
return _regenerator["default"].wrap(function
|
|
1379
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
1285
1380
|
while (1) {
|
|
1286
|
-
switch (
|
|
1381
|
+
switch (_context.prev = _context.next) {
|
|
1287
1382
|
case 0:
|
|
1288
1383
|
callbackFunc = jest.fn(function (newValue) {
|
|
1289
1384
|
var result = new Promise(function (resolve) {
|
|
@@ -1291,22 +1386,22 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1291
1386
|
resolve(newValue ? countries.filter(function (option) {
|
|
1292
1387
|
return option.toUpperCase().includes(newValue.toUpperCase());
|
|
1293
1388
|
}) : countries);
|
|
1294
|
-
},
|
|
1389
|
+
}, 100);
|
|
1295
1390
|
});
|
|
1296
1391
|
return result;
|
|
1297
1392
|
});
|
|
1298
1393
|
onChange = jest.fn();
|
|
1299
|
-
|
|
1394
|
+
_render42 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1300
1395
|
label: "Autosuggest Countries",
|
|
1301
1396
|
suggestions: callbackFunc,
|
|
1302
1397
|
onChange: onChange
|
|
1303
|
-
})), getByRole =
|
|
1398
|
+
})), getByRole = _render42.getByRole, getByText = _render42.getByText;
|
|
1304
1399
|
input = getByRole("combobox");
|
|
1305
1400
|
|
|
1306
1401
|
_react2.fireEvent.focus(input);
|
|
1307
1402
|
|
|
1308
1403
|
expect(getByRole("listbox")).toBeTruthy();
|
|
1309
|
-
|
|
1404
|
+
_context.next = 8;
|
|
1310
1405
|
return (0, _react2.waitForElementToBeRemoved)(function () {
|
|
1311
1406
|
return getByText("Searching...");
|
|
1312
1407
|
});
|
|
@@ -1319,7 +1414,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1319
1414
|
|
|
1320
1415
|
_userEvent["default"].type(input, "Ab");
|
|
1321
1416
|
|
|
1322
|
-
|
|
1417
|
+
_context.next = 15;
|
|
1323
1418
|
return (0, _react2.waitForElementToBeRemoved)(function () {
|
|
1324
1419
|
return getByText("Searching...");
|
|
1325
1420
|
});
|
|
@@ -1345,66 +1440,58 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1345
1440
|
|
|
1346
1441
|
case 19:
|
|
1347
1442
|
case "end":
|
|
1348
|
-
return
|
|
1443
|
+
return _context.stop();
|
|
1349
1444
|
}
|
|
1350
1445
|
}
|
|
1351
|
-
},
|
|
1446
|
+
}, _callee);
|
|
1352
1447
|
})));
|
|
1353
|
-
test("Autosuggest Esc key works while 'Searching...' message is shown",
|
|
1354
|
-
var callbackFunc
|
|
1448
|
+
test("Autosuggest Esc key works while 'Searching...' message is shown", function () {
|
|
1449
|
+
var callbackFunc = jest.fn(function (newValue) {
|
|
1450
|
+
var result = new Promise(function (resolve) {
|
|
1451
|
+
return setTimeout(function () {
|
|
1452
|
+
resolve(newValue ? countries.filter(function (option) {
|
|
1453
|
+
return option.toUpperCase().includes(newValue.toUpperCase());
|
|
1454
|
+
}) : countries);
|
|
1455
|
+
}, 100);
|
|
1456
|
+
});
|
|
1457
|
+
return result;
|
|
1458
|
+
});
|
|
1459
|
+
var onChange = jest.fn();
|
|
1355
1460
|
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
return option.toUpperCase().includes(newValue.toUpperCase());
|
|
1365
|
-
}) : countries);
|
|
1366
|
-
}, 1000);
|
|
1367
|
-
});
|
|
1368
|
-
return result;
|
|
1369
|
-
});
|
|
1370
|
-
onChange = jest.fn();
|
|
1371
|
-
_render41 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1372
|
-
label: "Autosuggest Countries",
|
|
1373
|
-
suggestions: callbackFunc,
|
|
1374
|
-
onChange: onChange
|
|
1375
|
-
})), getByRole = _render41.getByRole, queryByText = _render41.queryByText, queryByRole = _render41.queryByRole;
|
|
1376
|
-
input = getByRole("combobox");
|
|
1461
|
+
var _render43 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1462
|
+
label: "Autosuggest Countries",
|
|
1463
|
+
suggestions: callbackFunc,
|
|
1464
|
+
onChange: onChange
|
|
1465
|
+
})),
|
|
1466
|
+
getByRole = _render43.getByRole,
|
|
1467
|
+
queryByText = _render43.queryByText,
|
|
1468
|
+
queryByRole = _render43.queryByRole;
|
|
1377
1469
|
|
|
1378
|
-
|
|
1470
|
+
var input = getByRole("combobox");
|
|
1379
1471
|
|
|
1380
|
-
|
|
1472
|
+
_react2.fireEvent.focus(input);
|
|
1381
1473
|
|
|
1382
|
-
|
|
1474
|
+
expect(getByRole("listbox")).toBeTruthy();
|
|
1383
1475
|
|
|
1384
|
-
|
|
1385
|
-
key: "Esc",
|
|
1386
|
-
code: "Esc",
|
|
1387
|
-
keyCode: 27,
|
|
1388
|
-
charCode: 27
|
|
1389
|
-
});
|
|
1476
|
+
_userEvent["default"].type(input, "Ab");
|
|
1390
1477
|
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1478
|
+
_react2.fireEvent.keyDown(input, {
|
|
1479
|
+
key: "Esc",
|
|
1480
|
+
code: "Esc",
|
|
1481
|
+
keyCode: 27,
|
|
1482
|
+
charCode: 27
|
|
1483
|
+
});
|
|
1394
1484
|
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
})));
|
|
1402
|
-
test("Autosuggest Esc + arrow down working while 'Searching...' message is shown", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee19() {
|
|
1403
|
-
var callbackFunc, onChange, _render42, getByRole, getByText, queryByText, queryByRole, input, list;
|
|
1485
|
+
expect(queryByRole("listbox")).toBeFalsy();
|
|
1486
|
+
expect(queryByText("Searching...")).toBeFalsy();
|
|
1487
|
+
expect(input.value).toBe("");
|
|
1488
|
+
});
|
|
1489
|
+
test("Autosuggest Esc + arrow down working while 'Searching...' message is shown", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
1490
|
+
var callbackFunc, onChange, _render44, getByRole, getByText, queryByText, queryByRole, input, list;
|
|
1404
1491
|
|
|
1405
|
-
return _regenerator["default"].wrap(function
|
|
1492
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
1406
1493
|
while (1) {
|
|
1407
|
-
switch (
|
|
1494
|
+
switch (_context2.prev = _context2.next) {
|
|
1408
1495
|
case 0:
|
|
1409
1496
|
callbackFunc = jest.fn(function (newValue) {
|
|
1410
1497
|
var result = new Promise(function (resolve) {
|
|
@@ -1412,16 +1499,16 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1412
1499
|
resolve(newValue ? countries.filter(function (option) {
|
|
1413
1500
|
return option.toUpperCase().includes(newValue.toUpperCase());
|
|
1414
1501
|
}) : countries);
|
|
1415
|
-
},
|
|
1502
|
+
}, 100);
|
|
1416
1503
|
});
|
|
1417
1504
|
return result;
|
|
1418
1505
|
});
|
|
1419
1506
|
onChange = jest.fn();
|
|
1420
|
-
|
|
1507
|
+
_render44 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1421
1508
|
label: "Autosuggest Countries",
|
|
1422
1509
|
suggestions: callbackFunc,
|
|
1423
1510
|
onChange: onChange
|
|
1424
|
-
})), getByRole =
|
|
1511
|
+
})), getByRole = _render44.getByRole, getByText = _render44.getByText, queryByText = _render44.queryByText, queryByRole = _render44.queryByRole;
|
|
1425
1512
|
input = getByRole("combobox");
|
|
1426
1513
|
|
|
1427
1514
|
_react2.fireEvent.focus(input);
|
|
@@ -1450,7 +1537,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1450
1537
|
});
|
|
1451
1538
|
|
|
1452
1539
|
expect(list).toBeTruthy();
|
|
1453
|
-
|
|
1540
|
+
_context2.next = 16;
|
|
1454
1541
|
return (0, _react2.waitForElementToBeRemoved)(function () {
|
|
1455
1542
|
return getByText("Searching...");
|
|
1456
1543
|
});
|
|
@@ -1463,17 +1550,17 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1463
1550
|
|
|
1464
1551
|
case 20:
|
|
1465
1552
|
case "end":
|
|
1466
|
-
return
|
|
1553
|
+
return _context2.stop();
|
|
1467
1554
|
}
|
|
1468
1555
|
}
|
|
1469
|
-
},
|
|
1556
|
+
}, _callee2);
|
|
1470
1557
|
})));
|
|
1471
|
-
test("Asynchronous uncontrolled autosuggest test", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
1472
|
-
var callbackFunc, onChange,
|
|
1558
|
+
test("Asynchronous uncontrolled autosuggest test", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
1559
|
+
var callbackFunc, onChange, _render45, getByRole, getByText, input;
|
|
1473
1560
|
|
|
1474
|
-
return _regenerator["default"].wrap(function
|
|
1561
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
1475
1562
|
while (1) {
|
|
1476
|
-
switch (
|
|
1563
|
+
switch (_context3.prev = _context3.next) {
|
|
1477
1564
|
case 0:
|
|
1478
1565
|
callbackFunc = jest.fn(function (newValue) {
|
|
1479
1566
|
var result = new Promise(function (resolve) {
|
|
@@ -1481,23 +1568,23 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1481
1568
|
resolve(newValue ? countries.filter(function (option) {
|
|
1482
1569
|
return option.toUpperCase().includes(newValue.toUpperCase());
|
|
1483
1570
|
}) : countries);
|
|
1484
|
-
},
|
|
1571
|
+
}, 100);
|
|
1485
1572
|
});
|
|
1486
1573
|
return result;
|
|
1487
1574
|
});
|
|
1488
1575
|
onChange = jest.fn();
|
|
1489
|
-
|
|
1576
|
+
_render45 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1490
1577
|
label: "Autosuggest Countries",
|
|
1491
1578
|
onChange: onChange,
|
|
1492
1579
|
suggestions: callbackFunc
|
|
1493
|
-
})), getByRole =
|
|
1580
|
+
})), getByRole = _render45.getByRole, getByText = _render45.getByText;
|
|
1494
1581
|
input = getByRole("combobox");
|
|
1495
1582
|
|
|
1496
1583
|
_react2.fireEvent.focus(input);
|
|
1497
1584
|
|
|
1498
1585
|
_userEvent["default"].type(input, "Den");
|
|
1499
1586
|
|
|
1500
|
-
|
|
1587
|
+
_context3.next = 8;
|
|
1501
1588
|
return (0, _react2.waitForElementToBeRemoved)(function () {
|
|
1502
1589
|
return getByText("Searching...");
|
|
1503
1590
|
});
|
|
@@ -1508,24 +1595,23 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1508
1595
|
_userEvent["default"].click(getByRole("option"));
|
|
1509
1596
|
|
|
1510
1597
|
expect(onChange).toHaveBeenCalledWith({
|
|
1511
|
-
value: "Denmark"
|
|
1512
|
-
error: null
|
|
1598
|
+
value: "Denmark"
|
|
1513
1599
|
});
|
|
1514
1600
|
expect(input.value).toBe("Denmark");
|
|
1515
1601
|
|
|
1516
1602
|
case 12:
|
|
1517
1603
|
case "end":
|
|
1518
|
-
return
|
|
1604
|
+
return _context3.stop();
|
|
1519
1605
|
}
|
|
1520
1606
|
}
|
|
1521
|
-
},
|
|
1607
|
+
}, _callee3);
|
|
1522
1608
|
})));
|
|
1523
|
-
test("Asynchronous controlled autosuggest test", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
1524
|
-
var callbackFunc, onChange,
|
|
1609
|
+
test("Asynchronous controlled autosuggest test", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
|
1610
|
+
var callbackFunc, onChange, _render46, getByRole, getByText, queryByRole, input;
|
|
1525
1611
|
|
|
1526
|
-
return _regenerator["default"].wrap(function
|
|
1612
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
1527
1613
|
while (1) {
|
|
1528
|
-
switch (
|
|
1614
|
+
switch (_context4.prev = _context4.next) {
|
|
1529
1615
|
case 0:
|
|
1530
1616
|
callbackFunc = jest.fn(function (newValue) {
|
|
1531
1617
|
var result = new Promise(function (resolve) {
|
|
@@ -1533,51 +1619,52 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1533
1619
|
resolve(newValue ? countries.filter(function (option) {
|
|
1534
1620
|
return option.toUpperCase().includes(newValue.toUpperCase());
|
|
1535
1621
|
}) : countries);
|
|
1536
|
-
},
|
|
1622
|
+
}, 100);
|
|
1537
1623
|
});
|
|
1538
1624
|
return result;
|
|
1539
1625
|
});
|
|
1540
1626
|
onChange = jest.fn();
|
|
1541
|
-
|
|
1627
|
+
_render46 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1542
1628
|
label: "Autosuggest Countries",
|
|
1543
1629
|
value: "Denm",
|
|
1544
1630
|
onChange: onChange,
|
|
1545
1631
|
suggestions: callbackFunc
|
|
1546
|
-
})), getByRole =
|
|
1632
|
+
})), getByRole = _render46.getByRole, getByText = _render46.getByText, queryByRole = _render46.queryByRole;
|
|
1547
1633
|
input = getByRole("combobox");
|
|
1634
|
+
expect(input.value).toBe("Denm");
|
|
1548
1635
|
|
|
1549
|
-
|
|
1636
|
+
_userEvent["default"].click(getByText("Autosuggest Countries"));
|
|
1550
1637
|
|
|
1551
|
-
|
|
1638
|
+
_context4.next = 8;
|
|
1552
1639
|
return (0, _react2.waitForElementToBeRemoved)(function () {
|
|
1553
1640
|
return getByText("Searching...");
|
|
1554
1641
|
});
|
|
1555
1642
|
|
|
1556
|
-
case
|
|
1557
|
-
expect(input.value).toBe("Denm");
|
|
1643
|
+
case 8:
|
|
1558
1644
|
expect(getByText("Denmark")).toBeTruthy();
|
|
1559
1645
|
|
|
1560
|
-
|
|
1646
|
+
_react2.fireEvent.focus(getByRole("option"));
|
|
1647
|
+
|
|
1648
|
+
_userEvent["default"].click(getByText("Denmark"));
|
|
1561
1649
|
|
|
1562
1650
|
expect(onChange).toHaveBeenCalledWith({
|
|
1563
|
-
value: "Denmark"
|
|
1564
|
-
error: null
|
|
1651
|
+
value: "Denmark"
|
|
1565
1652
|
});
|
|
1566
1653
|
expect(queryByRole("listbox")).toBeFalsy();
|
|
1567
1654
|
|
|
1568
|
-
case
|
|
1655
|
+
case 13:
|
|
1569
1656
|
case "end":
|
|
1570
|
-
return
|
|
1657
|
+
return _context4.stop();
|
|
1571
1658
|
}
|
|
1572
1659
|
}
|
|
1573
|
-
},
|
|
1660
|
+
}, _callee4);
|
|
1574
1661
|
})));
|
|
1575
|
-
test("Asynchronous autosuggest closes the listbox after finishing no matches search", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
1576
|
-
var callbackFunc, onChange,
|
|
1662
|
+
test("Asynchronous autosuggest closes the listbox after finishing no matches search", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
|
|
1663
|
+
var callbackFunc, onChange, _render47, getByText, getByRole, queryByRole, input;
|
|
1577
1664
|
|
|
1578
|
-
return _regenerator["default"].wrap(function
|
|
1665
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
1579
1666
|
while (1) {
|
|
1580
|
-
switch (
|
|
1667
|
+
switch (_context5.prev = _context5.next) {
|
|
1581
1668
|
case 0:
|
|
1582
1669
|
callbackFunc = jest.fn(function (newValue) {
|
|
1583
1670
|
var result = new Promise(function (resolve) {
|
|
@@ -1585,23 +1672,23 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1585
1672
|
resolve(newValue ? countries.filter(function (option) {
|
|
1586
1673
|
return option.toUpperCase().includes(newValue.toUpperCase());
|
|
1587
1674
|
}) : countries);
|
|
1588
|
-
},
|
|
1675
|
+
}, 100);
|
|
1589
1676
|
});
|
|
1590
1677
|
return result;
|
|
1591
1678
|
});
|
|
1592
1679
|
onChange = jest.fn();
|
|
1593
|
-
|
|
1680
|
+
_render47 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1594
1681
|
label: "Autosuggest Countries",
|
|
1595
1682
|
onChange: onChange,
|
|
1596
1683
|
suggestions: callbackFunc
|
|
1597
|
-
})), getByText =
|
|
1684
|
+
})), getByText = _render47.getByText, getByRole = _render47.getByRole, queryByRole = _render47.queryByRole;
|
|
1598
1685
|
input = getByRole("combobox");
|
|
1599
1686
|
|
|
1600
1687
|
_react2.fireEvent.focus(input);
|
|
1601
1688
|
|
|
1602
1689
|
_userEvent["default"].type(input, "Example text");
|
|
1603
1690
|
|
|
1604
|
-
|
|
1691
|
+
_context5.next = 8;
|
|
1605
1692
|
return (0, _react2.waitForElementToBeRemoved)(function () {
|
|
1606
1693
|
return getByText("Searching...");
|
|
1607
1694
|
});
|
|
@@ -1611,17 +1698,17 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1611
1698
|
|
|
1612
1699
|
case 9:
|
|
1613
1700
|
case "end":
|
|
1614
|
-
return
|
|
1701
|
+
return _context5.stop();
|
|
1615
1702
|
}
|
|
1616
1703
|
}
|
|
1617
|
-
},
|
|
1704
|
+
}, _callee5);
|
|
1618
1705
|
})));
|
|
1619
|
-
test("Asynchronous autosuggest with no matches founded doesn't let the listbox to be opened", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
1620
|
-
var callbackFunc, onChange,
|
|
1706
|
+
test("Asynchronous autosuggest with no matches founded doesn't let the listbox to be opened", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
|
|
1707
|
+
var callbackFunc, onChange, _render48, getByText, getByRole, queryByRole, input;
|
|
1621
1708
|
|
|
1622
|
-
return _regenerator["default"].wrap(function
|
|
1709
|
+
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
1623
1710
|
while (1) {
|
|
1624
|
-
switch (
|
|
1711
|
+
switch (_context6.prev = _context6.next) {
|
|
1625
1712
|
case 0:
|
|
1626
1713
|
callbackFunc = jest.fn(function (newValue) {
|
|
1627
1714
|
var result = new Promise(function (resolve) {
|
|
@@ -1629,23 +1716,23 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1629
1716
|
resolve(newValue ? countries.filter(function (option) {
|
|
1630
1717
|
return option.toUpperCase().includes(newValue.toUpperCase());
|
|
1631
1718
|
}) : countries);
|
|
1632
|
-
},
|
|
1719
|
+
}, 100);
|
|
1633
1720
|
});
|
|
1634
1721
|
return result;
|
|
1635
1722
|
});
|
|
1636
1723
|
onChange = jest.fn();
|
|
1637
|
-
|
|
1724
|
+
_render48 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1638
1725
|
label: "Autosuggest Countries",
|
|
1639
1726
|
onChange: onChange,
|
|
1640
1727
|
suggestions: callbackFunc
|
|
1641
|
-
})), getByText =
|
|
1728
|
+
})), getByText = _render48.getByText, getByRole = _render48.getByRole, queryByRole = _render48.queryByRole;
|
|
1642
1729
|
input = getByRole("combobox");
|
|
1643
1730
|
|
|
1644
1731
|
_react2.fireEvent.focus(input);
|
|
1645
1732
|
|
|
1646
1733
|
_userEvent["default"].type(input, "wrong");
|
|
1647
1734
|
|
|
1648
|
-
|
|
1735
|
+
_context6.next = 8;
|
|
1649
1736
|
return (0, _react2.waitForElementToBeRemoved)(function () {
|
|
1650
1737
|
return getByText("Searching...");
|
|
1651
1738
|
});
|
|
@@ -1677,37 +1764,37 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1677
1764
|
|
|
1678
1765
|
case 15:
|
|
1679
1766
|
case "end":
|
|
1680
|
-
return
|
|
1767
|
+
return _context6.stop();
|
|
1681
1768
|
}
|
|
1682
1769
|
}
|
|
1683
|
-
},
|
|
1770
|
+
}, _callee6);
|
|
1684
1771
|
})));
|
|
1685
|
-
test("Asynchronous autosuggest request failed, shows 'Error fetching data' message", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
1686
|
-
var errorCallbackFunc, onChange,
|
|
1772
|
+
test("Asynchronous autosuggest request failed, shows 'Error fetching data' message", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
|
|
1773
|
+
var errorCallbackFunc, onChange, _render49, getByRole, getByText, input;
|
|
1687
1774
|
|
|
1688
|
-
return _regenerator["default"].wrap(function
|
|
1775
|
+
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
1689
1776
|
while (1) {
|
|
1690
|
-
switch (
|
|
1777
|
+
switch (_context7.prev = _context7.next) {
|
|
1691
1778
|
case 0:
|
|
1692
1779
|
errorCallbackFunc = jest.fn(function () {
|
|
1693
1780
|
var result = new Promise(function (resolve, reject) {
|
|
1694
1781
|
return setTimeout(function () {
|
|
1695
1782
|
reject("err");
|
|
1696
|
-
},
|
|
1783
|
+
}, 100);
|
|
1697
1784
|
});
|
|
1698
1785
|
return result;
|
|
1699
1786
|
});
|
|
1700
1787
|
onChange = jest.fn();
|
|
1701
|
-
|
|
1788
|
+
_render49 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
1702
1789
|
label: "Autosuggest Countries",
|
|
1703
1790
|
onChange: onChange,
|
|
1704
1791
|
suggestions: errorCallbackFunc
|
|
1705
|
-
})), getByRole =
|
|
1792
|
+
})), getByRole = _render49.getByRole, getByText = _render49.getByText;
|
|
1706
1793
|
input = getByRole("combobox");
|
|
1707
1794
|
|
|
1708
1795
|
_react2.fireEvent.focus(input);
|
|
1709
1796
|
|
|
1710
|
-
|
|
1797
|
+
_context7.next = 7;
|
|
1711
1798
|
return (0, _react2.waitForElementToBeRemoved)(function () {
|
|
1712
1799
|
return getByText("Searching...");
|
|
1713
1800
|
});
|
|
@@ -1717,9 +1804,9 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1717
1804
|
|
|
1718
1805
|
case 8:
|
|
1719
1806
|
case "end":
|
|
1720
|
-
return
|
|
1807
|
+
return _context7.stop();
|
|
1721
1808
|
}
|
|
1722
1809
|
}
|
|
1723
|
-
},
|
|
1810
|
+
}, _callee7);
|
|
1724
1811
|
})));
|
|
1725
1812
|
});
|