@dxc-technology/halstack-react 0.0.0-e30cba6 → 0.0.0-e832ef8
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/dist/ThemeContext.js +69 -61
- package/dist/V3Textarea/V3Textarea.js +264 -0
- package/dist/alert/Alert.js +5 -5
- package/dist/alert/index.d.ts +51 -0
- package/dist/button/Button.js +1 -1
- package/dist/common/variables.js +341 -139
- package/dist/date/Date.js +10 -12
- package/dist/{new-date/NewDate.js → date-input/DateInput.js} +69 -72
- package/dist/date-input/index.d.ts +95 -0
- package/dist/file-input/FileInput.js +644 -0
- package/dist/file-input/FileItem.js +280 -0
- package/dist/file-input/index.d.ts +81 -0
- package/dist/footer/Footer.js +44 -18
- package/dist/footer/Icons.js +77 -0
- package/dist/header/Header.js +80 -49
- package/dist/header/Icons.js +59 -0
- package/dist/input-text/Icons.js +22 -0
- package/dist/input-text/InputText.js +7 -9
- package/dist/layout/ApplicationLayout.js +5 -9
- package/dist/layout/Icons.js +55 -0
- package/dist/link/Link.js +4 -8
- package/dist/main.d.ts +8 -0
- package/dist/main.js +37 -21
- package/dist/new-select/NewSelect.js +836 -0
- package/dist/new-select/index.d.ts +53 -0
- package/dist/{number/Number.js → number-input/NumberInput.js} +9 -11
- package/dist/{number/NumberContext.js → number-input/NumberInputContext.js} +2 -2
- package/dist/number-input/index.d.ts +113 -0
- package/dist/paginator/Icons.js +66 -0
- package/dist/paginator/Paginator.js +5 -11
- package/dist/{password/Password.js → password-input/PasswordInput.js} +11 -13
- package/dist/password-input/index.d.ts +94 -0
- package/dist/progress-bar/ProgressBar.js +1 -1
- package/dist/select/Select.js +122 -158
- package/dist/sidenav/Sidenav.js +6 -4
- package/dist/slider/Slider.js +104 -19
- package/dist/spinner/Spinner.js +217 -54
- package/dist/tag/Tag.js +26 -32
- package/dist/{new-input-text/NewInputText.js → text-input/TextInput.js} +180 -170
- package/dist/text-input/index.d.ts +135 -0
- package/dist/textarea/Textarea.js +227 -122
- package/dist/textarea/index.d.ts +117 -0
- package/dist/toggle-group/ToggleGroup.js +132 -28
- package/dist/upload/Upload.js +3 -3
- package/dist/upload/buttons-upload/ButtonsUpload.js +7 -11
- package/dist/upload/buttons-upload/Icons.js +40 -0
- package/dist/upload/file-upload/FileToUpload.js +26 -21
- package/dist/upload/file-upload/Icons.js +66 -0
- package/dist/upload/readme.md +2 -2
- package/dist/upload/transaction/Icons.js +160 -0
- package/dist/upload/transaction/Transaction.js +11 -38
- package/dist/wizard/Icons.js +65 -0
- package/dist/wizard/Wizard.js +3 -9
- package/package.json +2 -1
- package/test/Date.test.js +48 -44
- package/test/{NewDate.test.js → DateInput.test.js} +66 -27
- package/test/FileInput.test.js +201 -0
- package/test/Footer.test.js +2 -7
- package/test/Header.test.js +5 -10
- package/test/InputText.test.js +24 -16
- package/test/{Number.test.js → NumberInput.test.js} +84 -66
- package/test/Paginator.test.js +1 -1
- package/test/PasswordInput.test.js +83 -0
- package/test/ResultsetTable.test.js +1 -2
- package/test/Select.test.js +40 -17
- package/test/Slider.test.js +9 -17
- package/test/Spinner.test.js +5 -0
- package/test/{NewInputText.test.js → TextInput.test.js} +146 -231
- package/test/Textarea.test.js +193 -0
- package/test/ToggleGroup.test.js +5 -1
- package/test/Upload.test.js +5 -5
- package/test/{TextArea.test.js → V3TextArea.test.js} +6 -7
- package/dist/footer/Footer.stories.js +0 -94
- package/dist/footer/dxc_logo.svg +0 -15
- package/dist/footer/readme.md +0 -41
- package/dist/header/Header.stories.js +0 -176
- package/dist/header/close_icon.svg +0 -1
- package/dist/header/dxc_logo_black.svg +0 -8
- package/dist/header/hamb_menu_black.svg +0 -1
- package/dist/header/hamb_menu_white.svg +0 -1
- package/dist/header/readme.md +0 -33
- package/dist/input-text/InputText.stories.js +0 -209
- package/dist/input-text/error.svg +0 -1
- package/dist/input-text/readme.md +0 -91
- package/dist/layout/facebook.svg +0 -45
- package/dist/layout/linkedin.svg +0 -50
- package/dist/layout/twitter.svg +0 -53
- package/dist/new-textarea/NewTextarea.js +0 -346
- package/dist/paginator/images/next.svg +0 -3
- package/dist/paginator/images/nextPage.svg +0 -3
- package/dist/paginator/images/previous.svg +0 -3
- package/dist/paginator/images/previousPage.svg +0 -3
- package/dist/paginator/readme.md +0 -50
- package/dist/password/styles.css +0 -3
- package/dist/resultsetTable/arrow_downward-24px_wht.svg +0 -1
- package/dist/resultsetTable/arrow_upward-24px_wht.svg +0 -1
- package/dist/resultsetTable/unfold_more-24px_wht.svg +0 -1
- package/dist/select/Select.stories.js +0 -235
- package/dist/select/readme.md +0 -72
- package/dist/slider/Slider.stories.js +0 -241
- package/dist/upload/buttons-upload/drag-drop-icon.svg +0 -4
- package/dist/upload/buttons-upload/upload-button.svg +0 -1
- package/dist/upload/file-upload/audio-icon.svg +0 -4
- package/dist/upload/file-upload/close.svg +0 -4
- package/dist/upload/file-upload/file-icon.svg +0 -4
- package/dist/upload/file-upload/video-icon.svg +0 -4
- package/dist/upload/transaction/audio-icon-err.svg +0 -4
- package/dist/upload/transaction/audio-icon.svg +0 -4
- package/dist/upload/transaction/error-icon.svg +0 -4
- package/dist/upload/transaction/file-icon-err.svg +0 -4
- package/dist/upload/transaction/file-icon.svg +0 -4
- package/dist/upload/transaction/image-icon-err.svg +0 -4
- package/dist/upload/transaction/image-icon.svg +0 -4
- package/dist/upload/transaction/success-icon.svg +0 -4
- package/dist/upload/transaction/video-icon-err.svg +0 -4
- package/dist/upload/transaction/video-icon.svg +0 -4
- package/dist/wizard/invalid_icon.svg +0 -5
- package/dist/wizard/valid_icon.svg +0 -5
- package/dist/wizard/validation-wrong.svg +0 -6
- package/test/NewTextarea.test.js +0 -201
- package/test/Password.test.js +0 -76
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { render, fireEvent, waitForElementToBeRemoved } from "@testing-library/react";
|
|
3
3
|
import userEvent from "@testing-library/user-event";
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import DxcTextInput from "../src/text-input/TextInput";
|
|
6
6
|
|
|
7
7
|
const countries = [
|
|
8
8
|
"Afghanistan",
|
|
@@ -29,113 +29,127 @@ const countries = [
|
|
|
29
29
|
"Djibouti",
|
|
30
30
|
];
|
|
31
31
|
|
|
32
|
-
describe("
|
|
32
|
+
describe("TextInput component tests", () => {
|
|
33
33
|
test("Renders with correct label", () => {
|
|
34
|
-
const { getByText } = render(<
|
|
34
|
+
const { getByText } = render(<DxcTextInput label="Example label" />);
|
|
35
35
|
expect(getByText("Example label")).toBeTruthy();
|
|
36
36
|
});
|
|
37
37
|
test("Renders with correct label and helper text", () => {
|
|
38
|
-
const { getByText } = render(<
|
|
38
|
+
const { getByText } = render(<DxcTextInput label="Example label" helperText="Example helper text" />);
|
|
39
39
|
expect(getByText("Example label")).toBeTruthy();
|
|
40
40
|
expect(getByText("Example helper text")).toBeTruthy();
|
|
41
41
|
});
|
|
42
42
|
test("Renders with correct label and optional", () => {
|
|
43
|
-
const { getByText } = render(<
|
|
43
|
+
const { getByText } = render(<DxcTextInput label="Example label" helperText="Example helper text" optional />);
|
|
44
44
|
expect(getByText("Example label")).toBeTruthy();
|
|
45
45
|
expect(getByText("(Optional)")).toBeTruthy();
|
|
46
46
|
expect(getByText("Example helper text")).toBeTruthy();
|
|
47
47
|
});
|
|
48
48
|
test("Renders with correct placeholder", () => {
|
|
49
|
-
const { getByRole } = render(<
|
|
49
|
+
const { getByRole } = render(<DxcTextInput label="Example label" placeholder="Placeholder" />);
|
|
50
50
|
const input = getByRole("textbox");
|
|
51
51
|
expect(input.getAttribute("placeholder")).toBe("Placeholder");
|
|
52
52
|
});
|
|
53
53
|
test("Renders with error message", () => {
|
|
54
|
-
const { getByText } = render(
|
|
55
|
-
<DxcNewInputText label="Error label" placeholder="Placeholder" error="Error message." />
|
|
56
|
-
);
|
|
54
|
+
const { getByText } = render(<DxcTextInput label="Error label" placeholder="Placeholder" error="Error message." />);
|
|
57
55
|
expect(getByText("Error message.")).toBeTruthy();
|
|
58
56
|
});
|
|
59
|
-
test("
|
|
57
|
+
test("Not optional constraint (onBlur)", () => {
|
|
60
58
|
const onChange = jest.fn();
|
|
61
59
|
const onBlur = jest.fn();
|
|
62
|
-
const { getByRole
|
|
63
|
-
<
|
|
64
|
-
label="Input label"
|
|
65
|
-
placeholder="Placeholder"
|
|
66
|
-
onChange={onChange}
|
|
67
|
-
onBlur={onBlur}
|
|
68
|
-
margin={{ left: "medium", right: "medium" }}
|
|
69
|
-
clearable
|
|
70
|
-
pattern='^.*(?=.*[a-zA-Z])(?=.*\d)(?=.*[!&$%&? "]).*$'
|
|
71
|
-
/>
|
|
60
|
+
const { getByRole } = render(
|
|
61
|
+
<DxcTextInput label="Input label" placeholder="Placeholder" onChange={onChange} onBlur={onBlur} clearable />
|
|
72
62
|
);
|
|
73
63
|
const input = getByRole("textbox");
|
|
74
|
-
|
|
64
|
+
|
|
65
|
+
fireEvent.focus(input);
|
|
75
66
|
fireEvent.blur(input);
|
|
76
|
-
expect(
|
|
77
|
-
|
|
67
|
+
expect(onBlur).toHaveBeenCalled();
|
|
68
|
+
expect(onBlur).toHaveBeenCalledWith({ value: "", error: "This field is required. Please, enter a value." });
|
|
69
|
+
fireEvent.change(input, { target: { value: "Test" } });
|
|
78
70
|
fireEvent.blur(input);
|
|
79
|
-
expect(
|
|
71
|
+
expect(onBlur).toHaveBeenCalled();
|
|
72
|
+
expect(onBlur).toHaveBeenCalledWith({ value: "Test", error: null });
|
|
80
73
|
});
|
|
81
|
-
test("
|
|
74
|
+
test("Not optional constraint (onChange)", () => {
|
|
75
|
+
const onChange = jest.fn();
|
|
76
|
+
const { getByRole } = render(
|
|
77
|
+
<DxcTextInput label="Input label" placeholder="Placeholder" onChange={onChange} clearable />
|
|
78
|
+
);
|
|
79
|
+
const input = getByRole("textbox");
|
|
80
|
+
|
|
81
|
+
fireEvent.change(input, { target: { value: "Test" } });
|
|
82
|
+
expect(onChange).toHaveBeenCalled();
|
|
83
|
+
expect(onChange).toHaveBeenCalledWith({ value: "Test", error: null });
|
|
84
|
+
userEvent.clear(input);
|
|
85
|
+
expect(onChange).toHaveBeenCalled();
|
|
86
|
+
expect(onChange).toHaveBeenCalledWith({ value: "", error: "This field is required. Please, enter a value." });
|
|
87
|
+
});
|
|
88
|
+
test("Pattern constraint", () => {
|
|
82
89
|
const onChange = jest.fn();
|
|
83
90
|
const onBlur = jest.fn();
|
|
84
91
|
const { getByRole, getByText, queryByText } = render(
|
|
85
|
-
<
|
|
92
|
+
<DxcTextInput
|
|
86
93
|
label="Input label"
|
|
87
94
|
placeholder="Placeholder"
|
|
88
95
|
onChange={onChange}
|
|
89
96
|
onBlur={onBlur}
|
|
90
97
|
margin={{ left: "medium", right: "medium" }}
|
|
91
98
|
clearable
|
|
92
|
-
|
|
99
|
+
pattern='^.*(?=.*[a-zA-Z])(?=.*\d)(?=.*[!&$%&? "]).*$'
|
|
93
100
|
/>
|
|
94
101
|
);
|
|
95
102
|
const input = getByRole("textbox");
|
|
96
|
-
|
|
103
|
+
|
|
104
|
+
fireEvent.change(input, { target: { value: "pattern test" } });
|
|
105
|
+
expect(onChange).toHaveBeenCalled();
|
|
106
|
+
expect(onChange).toHaveBeenCalledWith({ value: "pattern test", error: "Please match the format requested." });
|
|
97
107
|
fireEvent.blur(input);
|
|
98
|
-
expect(
|
|
99
|
-
|
|
108
|
+
expect(onBlur).toHaveBeenCalled();
|
|
109
|
+
expect(onBlur).toHaveBeenCalledWith({ value: "pattern test", error: "Please match the format requested." });
|
|
110
|
+
userEvent.clear(input);
|
|
111
|
+
fireEvent.change(input, { target: { value: "pattern4&" } });
|
|
112
|
+
expect(onChange).toHaveBeenCalled();
|
|
113
|
+
expect(onChange).toHaveBeenCalledWith({ value: "pattern4&", error: null });
|
|
100
114
|
fireEvent.blur(input);
|
|
101
|
-
expect(
|
|
115
|
+
expect(onBlur).toHaveBeenCalled();
|
|
116
|
+
expect(onBlur).toHaveBeenCalledWith({ value: "pattern4&", error: null });
|
|
102
117
|
});
|
|
103
|
-
test("
|
|
118
|
+
test("Length constraint", () => {
|
|
104
119
|
const onChange = jest.fn();
|
|
105
120
|
const onBlur = jest.fn();
|
|
106
121
|
const { getByRole, getByText, queryByText } = render(
|
|
107
|
-
<
|
|
122
|
+
<DxcTextInput
|
|
108
123
|
label="Input label"
|
|
109
124
|
placeholder="Placeholder"
|
|
110
125
|
onChange={onChange}
|
|
111
126
|
onBlur={onBlur}
|
|
112
127
|
margin={{ left: "medium", right: "medium" }}
|
|
113
128
|
clearable
|
|
114
|
-
pattern='^.*(?=.*[a-zA-Z])(?=.*\d)(?=.*[!&$%&? "]).*$'
|
|
115
129
|
length={{ min: 5, max: 10 }}
|
|
116
130
|
/>
|
|
117
131
|
);
|
|
118
132
|
const input = getByRole("textbox");
|
|
119
|
-
|
|
120
|
-
fireEvent.
|
|
121
|
-
expect(
|
|
122
|
-
|
|
133
|
+
|
|
134
|
+
fireEvent.change(input, { target: { value: "test" } });
|
|
135
|
+
expect(onChange).toHaveBeenCalled();
|
|
136
|
+
expect(onChange).toHaveBeenCalledWith({ value: "test", error: "Min length 5, max length 10." });
|
|
123
137
|
fireEvent.blur(input);
|
|
124
|
-
expect(
|
|
125
|
-
|
|
138
|
+
expect(onBlur).toHaveBeenCalled();
|
|
139
|
+
expect(onBlur).toHaveBeenCalledWith({ value: "test", error: "Min length 5, max length 10." });
|
|
140
|
+
userEvent.clear(input);
|
|
141
|
+
fireEvent.change(input, { target: { value: "length" } });
|
|
142
|
+
expect(onChange).toHaveBeenCalled();
|
|
143
|
+
expect(onChange).toHaveBeenCalledWith({ value: "length", error: null });
|
|
126
144
|
fireEvent.blur(input);
|
|
127
|
-
expect(
|
|
145
|
+
expect(onBlur).toHaveBeenCalled();
|
|
146
|
+
expect(onBlur).toHaveBeenCalledWith({ value: "length", error: null });
|
|
128
147
|
});
|
|
129
|
-
test("
|
|
130
|
-
const onChange = jest.fn(
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
expect(value).toBe("t");
|
|
135
|
-
expect(error).toBe("Please match the format requested.");
|
|
136
|
-
});
|
|
137
|
-
const { getByRole } = render(
|
|
138
|
-
<DxcNewInputText
|
|
148
|
+
test("Pattern and length constraints", () => {
|
|
149
|
+
const onChange = jest.fn();
|
|
150
|
+
const onBlur = jest.fn();
|
|
151
|
+
const { getByRole, getByText, queryByText } = render(
|
|
152
|
+
<DxcTextInput
|
|
139
153
|
label="Input label"
|
|
140
154
|
placeholder="Placeholder"
|
|
141
155
|
onChange={onChange}
|
|
@@ -143,102 +157,51 @@ describe("NewInputText component tests", () => {
|
|
|
143
157
|
margin={{ left: "medium", right: "medium" }}
|
|
144
158
|
clearable
|
|
145
159
|
pattern='^.*(?=.*[a-zA-Z])(?=.*\d)(?=.*[!&$%&? "]).*$'
|
|
146
|
-
/>
|
|
147
|
-
);
|
|
148
|
-
const input = getByRole("textbox");
|
|
149
|
-
userEvent.type(input, "t");
|
|
150
|
-
fireEvent.blur(input);
|
|
151
|
-
});
|
|
152
|
-
test("Input Non Strict - Length constraint", () => {
|
|
153
|
-
const onChange = jest.fn((value) => {
|
|
154
|
-
expect(value).toBe("t");
|
|
155
|
-
});
|
|
156
|
-
const onBlur = jest.fn(({ value, error }) => {
|
|
157
|
-
expect(value).toBe("t");
|
|
158
|
-
expect(error).toBe("Min length 5, max length 10.");
|
|
159
|
-
});
|
|
160
|
-
const { getByRole } = render(
|
|
161
|
-
<DxcNewInputText
|
|
162
|
-
label="Input label"
|
|
163
|
-
placeholder="Placeholder"
|
|
164
|
-
onChange={onChange}
|
|
165
|
-
onBlur={onBlur}
|
|
166
|
-
margin={{ left: "medium", right: "medium" }}
|
|
167
|
-
clearable
|
|
168
160
|
length={{ min: 5, max: 10 }}
|
|
169
161
|
/>
|
|
170
162
|
);
|
|
171
163
|
const input = getByRole("textbox");
|
|
172
|
-
|
|
164
|
+
|
|
165
|
+
fireEvent.change(input, { target: { value: "test" } });
|
|
166
|
+
expect(onChange).toHaveBeenCalled();
|
|
167
|
+
expect(onChange).toHaveBeenCalledWith({ value: "test", error: "Min length 5, max length 10." });
|
|
173
168
|
fireEvent.blur(input);
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
});
|
|
179
|
-
const onBlur = jest.fn(({ value, error }) => {
|
|
180
|
-
expect(value).toBe("t");
|
|
181
|
-
expect(error).toBe("Min length 5, max length 10.");
|
|
182
|
-
});
|
|
183
|
-
const { getByRole } = render(
|
|
184
|
-
<DxcNewInputText
|
|
185
|
-
label="Input label"
|
|
186
|
-
placeholder="Placeholder"
|
|
187
|
-
onChange={onChange}
|
|
188
|
-
onBlur={onBlur}
|
|
189
|
-
margin={{ left: "medium", right: "medium" }}
|
|
190
|
-
clearable
|
|
191
|
-
length={{ min: 5, max: 10 }}
|
|
192
|
-
/>
|
|
193
|
-
);
|
|
194
|
-
const input = getByRole("textbox");
|
|
195
|
-
userEvent.type(input, "t");
|
|
169
|
+
expect(onBlur).toHaveBeenCalled();
|
|
170
|
+
expect(onBlur).toHaveBeenCalledWith({ value: "test", error: "Min length 5, max length 10." });
|
|
171
|
+
fireEvent.change(input, { target: { value: "tests" } });
|
|
172
|
+
expect(onChange).toHaveBeenCalled();
|
|
173
|
+
expect(onChange).toHaveBeenCalledWith({ value: "tests", error: "Please match the format requested." });
|
|
196
174
|
fireEvent.blur(input);
|
|
175
|
+
expect(onBlur).toHaveBeenCalled();
|
|
176
|
+
expect(onBlur).toHaveBeenCalledWith({ value: "tests", error: "Please match the format requested." });
|
|
177
|
+
fireEvent.change(input, { target: { value: "tests4&" } });
|
|
178
|
+
expect(onChange).toHaveBeenCalled();
|
|
179
|
+
expect(onChange).toHaveBeenCalledWith({ value: "tests4&", error: null });
|
|
180
|
+
fireEvent.blur(input);
|
|
181
|
+
expect(onBlur).toHaveBeenCalled();
|
|
182
|
+
expect(onBlur).toHaveBeenCalledWith({ value: "tests4&", error: null });
|
|
197
183
|
});
|
|
198
184
|
test("onChange function is called correctly", () => {
|
|
199
185
|
const onChange = jest.fn();
|
|
200
|
-
const { getByRole } = render(<
|
|
186
|
+
const { getByRole } = render(<DxcTextInput label="Input label" onChange={onChange} />);
|
|
201
187
|
const input = getByRole("textbox");
|
|
202
188
|
userEvent.type(input, "onchange event test");
|
|
203
189
|
expect(input.value).toBe("onchange event test");
|
|
204
190
|
expect(onChange).toHaveBeenCalled();
|
|
205
|
-
expect(onChange).toHaveBeenCalledWith("onchange event test");
|
|
191
|
+
expect(onChange).toHaveBeenCalledWith({ value: "onchange event test", error: null });
|
|
206
192
|
});
|
|
207
193
|
test("onBlur function is called correctly", () => {
|
|
208
194
|
const onBlur = jest.fn();
|
|
209
195
|
const onChange = jest.fn();
|
|
210
|
-
const { getByRole } = render(<
|
|
196
|
+
const { getByRole } = render(<DxcTextInput label="Input label" onChange={onChange} onBlur={onBlur} />);
|
|
211
197
|
const input = getByRole("textbox");
|
|
212
|
-
|
|
198
|
+
fireEvent.change(input, { target: { value: "Blur test" } });
|
|
213
199
|
fireEvent.blur(input);
|
|
214
200
|
expect(onBlur).toHaveBeenCalled();
|
|
215
|
-
expect(onBlur).toHaveBeenCalledWith({ value: "
|
|
216
|
-
});
|
|
217
|
-
test("Uncontrolled input", () => {
|
|
218
|
-
const onChange = jest.fn();
|
|
219
|
-
const { getByRole } = render(<DxcNewInputText label="Input label" onChange={onChange} />);
|
|
220
|
-
const input = getByRole("textbox");
|
|
221
|
-
userEvent.type(input, "Uncontrolled test");
|
|
222
|
-
expect(onChange).toHaveBeenCalled();
|
|
223
|
-
expect(onChange).toHaveBeenCalledWith("Uncontrolled test");
|
|
224
|
-
expect(input.value).toBe("Uncontrolled test");
|
|
225
|
-
});
|
|
226
|
-
test("Controlled input", () => {
|
|
227
|
-
const onChange = jest.fn();
|
|
228
|
-
const onBlur = jest.fn();
|
|
229
|
-
const { getByRole } = render(
|
|
230
|
-
<DxcNewInputText label="Input label" value="Test value" onChange={onChange} onBlur={onBlur} />
|
|
231
|
-
);
|
|
232
|
-
const input = getByRole("textbox");
|
|
233
|
-
userEvent.type(input, "Example text");
|
|
234
|
-
expect(onChange).toHaveBeenCalled();
|
|
235
|
-
expect(input.value).toBe("Test value");
|
|
236
|
-
fireEvent.blur(input);
|
|
237
|
-
expect(onBlur).toHaveBeenCalled();
|
|
238
|
-
expect(onBlur).toHaveBeenCalledWith({ value: "Test value", error: null });
|
|
201
|
+
expect(onBlur).toHaveBeenCalledWith({ value: "Blur test", error: null });
|
|
239
202
|
});
|
|
240
203
|
test("Clear action onClick cleans the input", () => {
|
|
241
|
-
const { getByRole } = render(<
|
|
204
|
+
const { getByRole } = render(<DxcTextInput label="Input label" clearable />);
|
|
242
205
|
const input = getByRole("textbox");
|
|
243
206
|
userEvent.type(input, "Test");
|
|
244
207
|
const closeAction = getByRole("button");
|
|
@@ -263,7 +226,7 @@ describe("NewInputText component tests", () => {
|
|
|
263
226
|
</svg>
|
|
264
227
|
),
|
|
265
228
|
};
|
|
266
|
-
const { getByRole } = render(<
|
|
229
|
+
const { getByRole } = render(<DxcTextInput label="Disabled input label" action={action} disabled />);
|
|
267
230
|
const input = getByRole("textbox");
|
|
268
231
|
expect(input.disabled).toBeTruthy();
|
|
269
232
|
userEvent.click(getByRole("button"));
|
|
@@ -271,7 +234,7 @@ describe("NewInputText component tests", () => {
|
|
|
271
234
|
});
|
|
272
235
|
test("Disabled input (clear default action should not be displayed, even with text written on the input)", () => {
|
|
273
236
|
const { getByRole, queryByRole } = render(
|
|
274
|
-
<
|
|
237
|
+
<DxcTextInput label="Disabled input label" value="Sample text" disabled clearable />
|
|
275
238
|
);
|
|
276
239
|
const input = getByRole("textbox");
|
|
277
240
|
expect(input.disabled).toBeTruthy();
|
|
@@ -279,7 +242,7 @@ describe("NewInputText component tests", () => {
|
|
|
279
242
|
});
|
|
280
243
|
test("Disabled input (suffix and preffix must be displayed)", () => {
|
|
281
244
|
const { getByRole, getByText } = render(
|
|
282
|
-
<
|
|
245
|
+
<DxcTextInput label="Disabled input label" value="Sample text" prefix="+34" suffix="USD" disabled />
|
|
283
246
|
);
|
|
284
247
|
const input = getByRole("textbox");
|
|
285
248
|
expect(input.disabled).toBeTruthy();
|
|
@@ -304,70 +267,16 @@ describe("NewInputText component tests", () => {
|
|
|
304
267
|
</svg>
|
|
305
268
|
),
|
|
306
269
|
};
|
|
307
|
-
const { getByRole, getByTestId } = render(<
|
|
270
|
+
const { getByRole, getByTestId } = render(<DxcTextInput label="Input label" action={action} />);
|
|
308
271
|
expect(getByTestId("image")).toBeTruthy();
|
|
309
272
|
userEvent.click(getByRole("button"));
|
|
310
273
|
expect(onClick).toHaveBeenCalled();
|
|
311
274
|
});
|
|
312
|
-
test("Renders with correct prefix and suffix
|
|
313
|
-
const { getByText } = render(<
|
|
275
|
+
test("Renders with correct prefix and suffix", () => {
|
|
276
|
+
const { getByText } = render(<DxcTextInput label="Input label" prefix="+34" suffix="USD" />);
|
|
314
277
|
expect(getByText("+34")).toBeTruthy();
|
|
315
278
|
expect(getByText("USD")).toBeTruthy();
|
|
316
279
|
});
|
|
317
|
-
test("Renders with correct prefix (icon)", () => {
|
|
318
|
-
const { getByTestId } = render(
|
|
319
|
-
<DxcNewInputText
|
|
320
|
-
label="Input label"
|
|
321
|
-
prefix={
|
|
322
|
-
<svg
|
|
323
|
-
data-testid="image"
|
|
324
|
-
version="1.1"
|
|
325
|
-
x="0px"
|
|
326
|
-
y="0px"
|
|
327
|
-
width="24px"
|
|
328
|
-
height="24px"
|
|
329
|
-
viewBox="0 0 24 24"
|
|
330
|
-
enable-background="new 0 0 24 24"
|
|
331
|
-
>
|
|
332
|
-
<g id="Bounding_Box">
|
|
333
|
-
<rect fill="none" width="24" height="24" />
|
|
334
|
-
</g>
|
|
335
|
-
<g id="Master">
|
|
336
|
-
<path d="M19,9.3V4h-3v2.6L12,3L2,12h3v8h5v-6h4v6h5v-8h3L19,9.3z M10,10c0-1.1,0.9-2,2-2s2,0.9,2,2H10z" />
|
|
337
|
-
</g>
|
|
338
|
-
</svg>
|
|
339
|
-
}
|
|
340
|
-
/>
|
|
341
|
-
);
|
|
342
|
-
expect(getByTestId("image")).toBeTruthy();
|
|
343
|
-
});
|
|
344
|
-
test("Renders with correct suffix (icon)", () => {
|
|
345
|
-
const { getByTestId } = render(
|
|
346
|
-
<DxcNewInputText
|
|
347
|
-
label="Input label"
|
|
348
|
-
suffix={
|
|
349
|
-
<svg
|
|
350
|
-
data-testid="image"
|
|
351
|
-
version="1.1"
|
|
352
|
-
x="0px"
|
|
353
|
-
y="0px"
|
|
354
|
-
width="24px"
|
|
355
|
-
height="24px"
|
|
356
|
-
viewBox="0 0 24 24"
|
|
357
|
-
enable-background="new 0 0 24 24"
|
|
358
|
-
>
|
|
359
|
-
<g id="Bounding_Box">
|
|
360
|
-
<rect fill="none" width="24" height="24" />
|
|
361
|
-
</g>
|
|
362
|
-
<g id="Master">
|
|
363
|
-
<path d="M19,9.3V4h-3v2.6L12,3L2,12h3v8h5v-6h4v6h5v-8h3L19,9.3z M10,10c0-1.1,0.9-2,2-2s2,0.9,2,2H10z" />
|
|
364
|
-
</g>
|
|
365
|
-
</svg>
|
|
366
|
-
}
|
|
367
|
-
/>
|
|
368
|
-
);
|
|
369
|
-
expect(getByTestId("image")).toBeTruthy();
|
|
370
|
-
});
|
|
371
280
|
test("Input has correct accesibility attributes", () => {
|
|
372
281
|
const onClick = jest.fn();
|
|
373
282
|
const action = {
|
|
@@ -386,40 +295,43 @@ describe("NewInputText component tests", () => {
|
|
|
386
295
|
</svg>
|
|
387
296
|
),
|
|
388
297
|
};
|
|
389
|
-
const { getByRole, getAllByRole } = render(
|
|
390
|
-
<DxcNewInputText label="Example label" clearable action={action} error="Error message." />
|
|
391
|
-
);
|
|
298
|
+
const { getByRole, getAllByRole } = render(<DxcTextInput label="Example label" clearable action={action} />);
|
|
392
299
|
const input = getByRole("textbox");
|
|
393
300
|
expect(input.getAttribute("aria-autocomplete")).toBeNull();
|
|
394
301
|
expect(input.getAttribute("aria-controls")).toBeNull();
|
|
395
302
|
expect(input.getAttribute("aria-expanded")).toBeNull();
|
|
396
|
-
expect(input.getAttribute("aria-
|
|
303
|
+
expect(input.getAttribute("aria-activedescendant")).toBeNull();
|
|
304
|
+
expect(input.getAttribute("aria-invalid")).toBe("false");
|
|
305
|
+
expect(input.getAttribute("aria-describedBy")).toBeNull();
|
|
306
|
+
expect(input.getAttribute("aria-required")).toBe("true");
|
|
397
307
|
userEvent.type(input, "Text");
|
|
398
308
|
const clear = getAllByRole("button")[0];
|
|
399
309
|
expect(clear.getAttribute("aria-label")).toBe("Clear");
|
|
400
310
|
});
|
|
401
311
|
test("Autosuggest has correct accesibility attributes", () => {
|
|
402
312
|
const { getByRole, getAllByRole } = render(
|
|
403
|
-
<
|
|
313
|
+
<DxcTextInput label="Autocomplete Countries" optional suggestions={countries} />
|
|
404
314
|
);
|
|
405
315
|
const input = getByRole("combobox");
|
|
406
316
|
const inputId = input.id;
|
|
407
317
|
expect(input.getAttribute("aria-autocomplete")).toBe("list");
|
|
408
318
|
expect(input.getAttribute("aria-controls")).toBe(inputId);
|
|
409
319
|
expect(input.getAttribute("aria-expanded")).toBe("false");
|
|
320
|
+
expect(input.getAttribute("aria-required")).toBe("false");
|
|
410
321
|
fireEvent.focus(input);
|
|
411
322
|
const list = getByRole("listbox");
|
|
323
|
+
expect(input.getAttribute("aria-expanded")).toBe("true");
|
|
412
324
|
expect(list.getAttribute("aria-label")).toBe("Autocomplete Countries");
|
|
413
325
|
const options = getAllByRole("option");
|
|
414
326
|
expect(options[0].getAttribute("aria-selected")).toBe("false");
|
|
415
327
|
});
|
|
416
328
|
});
|
|
417
329
|
|
|
418
|
-
describe("
|
|
330
|
+
describe("TextInput component synchronous autosuggest tests", () => {
|
|
419
331
|
test("Autosuggest is displayed when the input gains focus", async () => {
|
|
420
332
|
const onChange = jest.fn();
|
|
421
333
|
const { getByRole, getByText } = render(
|
|
422
|
-
<
|
|
334
|
+
<DxcTextInput label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
|
|
423
335
|
);
|
|
424
336
|
const input = getByRole("combobox");
|
|
425
337
|
fireEvent.focus(input);
|
|
@@ -433,7 +345,7 @@ describe("NewInputText component synchronous autosuggest tests", () => {
|
|
|
433
345
|
test("Autosuggest is displayed when the user clicks the input", async () => {
|
|
434
346
|
const onChange = jest.fn();
|
|
435
347
|
const { getByRole, getByText } = render(
|
|
436
|
-
<
|
|
348
|
+
<DxcTextInput label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
|
|
437
349
|
);
|
|
438
350
|
const input = getByRole("combobox");
|
|
439
351
|
userEvent.click(input);
|
|
@@ -447,7 +359,7 @@ describe("NewInputText component synchronous autosuggest tests", () => {
|
|
|
447
359
|
test("Autosuggest is displayed while the user is writing (if closed previously, if open stays open)", async () => {
|
|
448
360
|
const onChange = jest.fn();
|
|
449
361
|
const { getByRole, queryByRole, getByText, getAllByText } = render(
|
|
450
|
-
<
|
|
362
|
+
<DxcTextInput label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
|
|
451
363
|
);
|
|
452
364
|
const input = getByRole("combobox");
|
|
453
365
|
fireEvent.focus(input);
|
|
@@ -466,7 +378,7 @@ describe("NewInputText component synchronous autosuggest tests", () => {
|
|
|
466
378
|
test("Autosuggest is not displayed when prop suggestions is an empty array", async () => {
|
|
467
379
|
const onChange = jest.fn();
|
|
468
380
|
const { queryByRole } = render(
|
|
469
|
-
<
|
|
381
|
+
<DxcTextInput label="Autocomplete Countries" suggestions={[]} onChange={onChange} />
|
|
470
382
|
);
|
|
471
383
|
const input = queryByRole("textbox");
|
|
472
384
|
fireEvent.focus(input);
|
|
@@ -475,7 +387,7 @@ describe("NewInputText component synchronous autosuggest tests", () => {
|
|
|
475
387
|
test("Autosuggest shows 'No results found' message when there are no matches with the user's input", async () => {
|
|
476
388
|
const onChange = jest.fn();
|
|
477
389
|
const { getByRole, getByText } = render(
|
|
478
|
-
<
|
|
390
|
+
<DxcTextInput label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
|
|
479
391
|
);
|
|
480
392
|
const input = getByRole("combobox");
|
|
481
393
|
fireEvent.focus(input);
|
|
@@ -489,7 +401,7 @@ describe("NewInputText component synchronous autosuggest tests", () => {
|
|
|
489
401
|
test("Autosuggest uncontrolled suggestion selected", async () => {
|
|
490
402
|
const onChange = jest.fn();
|
|
491
403
|
const { getByRole, getByText, queryByRole } = render(
|
|
492
|
-
<
|
|
404
|
+
<DxcTextInput label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
|
|
493
405
|
);
|
|
494
406
|
const input = getByRole("combobox");
|
|
495
407
|
fireEvent.focus(input);
|
|
@@ -505,7 +417,7 @@ describe("NewInputText component synchronous autosuggest tests", () => {
|
|
|
505
417
|
test("Autosuggest controlled suggestions selected", async () => {
|
|
506
418
|
const onChange = jest.fn();
|
|
507
419
|
const { getByRole, getByText, queryByRole } = render(
|
|
508
|
-
<
|
|
420
|
+
<DxcTextInput label="Autocomplete Countries" value="Andor" suggestions={countries} onChange={onChange} />
|
|
509
421
|
);
|
|
510
422
|
const input = getByRole("combobox");
|
|
511
423
|
fireEvent.focus(input);
|
|
@@ -514,17 +426,18 @@ describe("NewInputText component synchronous autosuggest tests", () => {
|
|
|
514
426
|
expect(getByText("ra")).toBeTruthy();
|
|
515
427
|
fireEvent.mouseDown(getByRole("option"));
|
|
516
428
|
fireEvent.mouseUp(getByRole("option"));
|
|
517
|
-
expect(onChange).toHaveBeenCalledWith("Andorra");
|
|
429
|
+
expect(onChange).toHaveBeenCalledWith({ value: "Andorra", error: null });
|
|
518
430
|
expect(queryByRole("listbox")).toBeFalsy();
|
|
519
431
|
});
|
|
520
|
-
test("Autosuggest
|
|
432
|
+
test("Autosuggest - Pattern constraint", async () => {
|
|
521
433
|
const onChange = jest.fn();
|
|
522
|
-
const
|
|
523
|
-
|
|
434
|
+
const onBlur = jest.fn();
|
|
435
|
+
const { getByRole, getByText } = render(
|
|
436
|
+
<DxcTextInput
|
|
524
437
|
label="Autocomplete Countries"
|
|
525
|
-
value="Andor"
|
|
526
438
|
suggestions={countries}
|
|
527
439
|
onChange={onChange}
|
|
440
|
+
onBlur={onBlur}
|
|
528
441
|
pattern='^.*(?=.*[a-zA-Z])(?=.*\d)(?=.*[!&$%&? "]).*$'
|
|
529
442
|
/>
|
|
530
443
|
);
|
|
@@ -535,36 +448,38 @@ describe("NewInputText component synchronous autosuggest tests", () => {
|
|
|
535
448
|
expect(getByText("ra")).toBeTruthy();
|
|
536
449
|
fireEvent.mouseDown(getByRole("option"));
|
|
537
450
|
fireEvent.mouseUp(getByRole("option"));
|
|
538
|
-
expect(onChange).toHaveBeenCalledWith("Andorra");
|
|
451
|
+
expect(onChange).toHaveBeenCalledWith({ value: "Andorra", error: "Please match the format requested." });
|
|
539
452
|
fireEvent.blur(input);
|
|
540
|
-
expect(
|
|
453
|
+
expect(onBlur).toHaveBeenCalledWith({ value: "Andorra", error: "Please match the format requested." });
|
|
541
454
|
});
|
|
542
|
-
test("Autosuggest
|
|
455
|
+
test("Autosuggest - Length constraint", async () => {
|
|
543
456
|
const onChange = jest.fn();
|
|
544
|
-
const
|
|
545
|
-
|
|
457
|
+
const onBlur = jest.fn();
|
|
458
|
+
const { getByText, getByRole } = render(
|
|
459
|
+
<DxcTextInput
|
|
546
460
|
label="Autocomplete Countries"
|
|
547
|
-
value="Cha"
|
|
548
461
|
suggestions={countries}
|
|
549
462
|
onChange={onChange}
|
|
463
|
+
onBlur={onBlur}
|
|
550
464
|
length={{ min: 5, max: 10 }}
|
|
551
465
|
/>
|
|
552
466
|
);
|
|
553
467
|
const input = getByRole("combobox");
|
|
554
468
|
fireEvent.focus(input);
|
|
555
|
-
userEvent.type(input, "
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
fireEvent.
|
|
559
|
-
|
|
469
|
+
userEvent.type(input, "Cha");
|
|
470
|
+
expect(getByText("Cha")).toBeTruthy();
|
|
471
|
+
expect(getByText("d")).toBeTruthy();
|
|
472
|
+
fireEvent.mouseDown(getByRole("option"));
|
|
473
|
+
fireEvent.mouseUp(getByRole("option"));
|
|
474
|
+
expect(onChange).toHaveBeenCalledWith({ value: "Cha", error: "Min length 5, max length 10." });
|
|
560
475
|
fireEvent.blur(input);
|
|
561
|
-
expect(
|
|
476
|
+
expect(onBlur).toHaveBeenCalledWith({ value: "Chad", error: "Min length 5, max length 10." });
|
|
562
477
|
});
|
|
563
478
|
test("Autosuggest keys: arrow down key opens autosuggest, active first option is selected with Enter and closes the autosuggest", async () => {
|
|
564
479
|
Element.prototype.scrollTo = () => {};
|
|
565
480
|
const onChange = jest.fn();
|
|
566
481
|
const { getByRole, queryByRole } = render(
|
|
567
|
-
<
|
|
482
|
+
<DxcTextInput label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
|
|
568
483
|
);
|
|
569
484
|
const input = getByRole("combobox");
|
|
570
485
|
fireEvent.keyDown(input, { key: "ArrowDown", code: "ArrowDown", keyCode: 40, charCode: 40 });
|
|
@@ -578,7 +493,7 @@ describe("NewInputText component synchronous autosuggest tests", () => {
|
|
|
578
493
|
Element.prototype.scrollTo = () => {};
|
|
579
494
|
const onChange = jest.fn();
|
|
580
495
|
const { getByRole, queryByRole } = render(
|
|
581
|
-
<
|
|
496
|
+
<DxcTextInput label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
|
|
582
497
|
);
|
|
583
498
|
const input = getByRole("combobox");
|
|
584
499
|
fireEvent.keyDown(input, { key: "ArrowUp", code: "ArrowUp", keyCode: 38, charCode: 38 });
|
|
@@ -592,7 +507,7 @@ describe("NewInputText component synchronous autosuggest tests", () => {
|
|
|
592
507
|
Element.prototype.scrollTo = () => {};
|
|
593
508
|
const onChange = jest.fn();
|
|
594
509
|
const { getByRole, queryByRole } = render(
|
|
595
|
-
<
|
|
510
|
+
<DxcTextInput label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
|
|
596
511
|
);
|
|
597
512
|
const input = getByRole("combobox");
|
|
598
513
|
fireEvent.focus(input);
|
|
@@ -607,7 +522,7 @@ describe("NewInputText component synchronous autosuggest tests", () => {
|
|
|
607
522
|
Element.prototype.scrollTo = () => {};
|
|
608
523
|
const onChange = jest.fn();
|
|
609
524
|
const { getByRole, queryByRole } = render(
|
|
610
|
-
<
|
|
525
|
+
<DxcTextInput label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
|
|
611
526
|
);
|
|
612
527
|
const input = getByRole("combobox");
|
|
613
528
|
fireEvent.focus(input);
|
|
@@ -621,13 +536,13 @@ describe("NewInputText component synchronous autosuggest tests", () => {
|
|
|
621
536
|
Element.prototype.scrollTo = () => {};
|
|
622
537
|
const onChange = jest.fn();
|
|
623
538
|
const { getByRole, queryByRole } = render(
|
|
624
|
-
<
|
|
539
|
+
<DxcTextInput label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
|
|
625
540
|
);
|
|
626
541
|
const input = getByRole("combobox");
|
|
627
542
|
fireEvent.focus(input);
|
|
628
543
|
userEvent.type(input, "Ba");
|
|
629
544
|
fireEvent.keyDown(input, { key: "ArrowUp", code: "ArrowUp", keyCode: 38, charCode: 38 });
|
|
630
|
-
fireEvent.keyDown(input, { key: "ArrowUp", code: "
|
|
545
|
+
fireEvent.keyDown(input, { key: "ArrowUp", code: "ArrowUpp", keyCode: 38, charCode: 38 });
|
|
631
546
|
fireEvent.keyDown(input, { key: "ArrowDown", code: "ArrowDown", keyCode: 40, charCode: 40 });
|
|
632
547
|
fireEvent.keyDown(input, { key: "Enter", code: "Enter", keyCode: 13, charCode: 13 });
|
|
633
548
|
expect(input.value).toBe("Barbados");
|
|
@@ -638,7 +553,7 @@ describe("NewInputText component synchronous autosuggest tests", () => {
|
|
|
638
553
|
});
|
|
639
554
|
});
|
|
640
555
|
|
|
641
|
-
describe("
|
|
556
|
+
describe("TextInput component asynchronous autosuggest tests", () => {
|
|
642
557
|
test("Autosuggest 'Searching...' message is shown", async () => {
|
|
643
558
|
const callbackFunc = jest.fn((newValue) => {
|
|
644
559
|
const result = new Promise((resolve) =>
|
|
@@ -652,7 +567,7 @@ describe("NewInputText component asynchronous autosuggest tests", () => {
|
|
|
652
567
|
});
|
|
653
568
|
const onChange = jest.fn();
|
|
654
569
|
const { getByRole, getByText } = render(
|
|
655
|
-
<
|
|
570
|
+
<DxcTextInput label="Autosuggest Countries" suggestions={callbackFunc} onChange={onChange} />
|
|
656
571
|
);
|
|
657
572
|
const input = getByRole("combobox");
|
|
658
573
|
fireEvent.focus(input);
|
|
@@ -682,7 +597,7 @@ describe("NewInputText component asynchronous autosuggest tests", () => {
|
|
|
682
597
|
});
|
|
683
598
|
const onChange = jest.fn();
|
|
684
599
|
const { getByRole, queryByText, queryByRole } = render(
|
|
685
|
-
<
|
|
600
|
+
<DxcTextInput label="Autosuggest Countries" suggestions={callbackFunc} onChange={onChange} />
|
|
686
601
|
);
|
|
687
602
|
const input = getByRole("combobox");
|
|
688
603
|
fireEvent.focus(input);
|
|
@@ -706,7 +621,7 @@ describe("NewInputText component asynchronous autosuggest tests", () => {
|
|
|
706
621
|
});
|
|
707
622
|
const onChange = jest.fn();
|
|
708
623
|
const { getByRole, getByText, queryByText, queryByRole } = render(
|
|
709
|
-
<
|
|
624
|
+
<DxcTextInput label="Autosuggest Countries" suggestions={callbackFunc} onChange={onChange} />
|
|
710
625
|
);
|
|
711
626
|
const input = getByRole("combobox");
|
|
712
627
|
fireEvent.focus(input);
|
|
@@ -738,7 +653,7 @@ describe("NewInputText component asynchronous autosuggest tests", () => {
|
|
|
738
653
|
});
|
|
739
654
|
const onChange = jest.fn();
|
|
740
655
|
const { getByRole, getByText } = render(
|
|
741
|
-
<
|
|
656
|
+
<DxcTextInput label="Autosuggest Countries" onChange={onChange} suggestions={callbackFunc} />
|
|
742
657
|
);
|
|
743
658
|
const input = getByRole("combobox");
|
|
744
659
|
fireEvent.focus(input);
|
|
@@ -747,7 +662,7 @@ describe("NewInputText component asynchronous autosuggest tests", () => {
|
|
|
747
662
|
expect(getByText("Denmark")).toBeTruthy();
|
|
748
663
|
fireEvent.mouseDown(getByRole("option"));
|
|
749
664
|
fireEvent.mouseUp(getByRole("option"));
|
|
750
|
-
expect(onChange).toHaveBeenCalledWith("Denmark");
|
|
665
|
+
expect(onChange).toHaveBeenCalledWith({ value: "Denmark", error: null });
|
|
751
666
|
expect(input.value).toBe("Denmark");
|
|
752
667
|
});
|
|
753
668
|
test("Asynchronous controlled autosuggest test", async () => {
|
|
@@ -763,7 +678,7 @@ describe("NewInputText component asynchronous autosuggest tests", () => {
|
|
|
763
678
|
});
|
|
764
679
|
const onChange = jest.fn();
|
|
765
680
|
const { getByRole, getByText, queryByRole } = render(
|
|
766
|
-
<
|
|
681
|
+
<DxcTextInput label="Autosuggest Countries" value="Denm" onChange={onChange} suggestions={callbackFunc} />
|
|
767
682
|
);
|
|
768
683
|
const input = getByRole("combobox");
|
|
769
684
|
fireEvent.focus(input);
|
|
@@ -772,7 +687,7 @@ describe("NewInputText component asynchronous autosuggest tests", () => {
|
|
|
772
687
|
expect(getByText("Denmark")).toBeTruthy();
|
|
773
688
|
fireEvent.mouseDown(getByRole("option"));
|
|
774
689
|
fireEvent.mouseUp(getByRole("option"));
|
|
775
|
-
expect(onChange).toHaveBeenCalledWith("Denmark");
|
|
690
|
+
expect(onChange).toHaveBeenCalledWith({ value: "Denmark", error: null });
|
|
776
691
|
expect(queryByRole("listbox")).toBeFalsy();
|
|
777
692
|
});
|
|
778
693
|
test("Asynchronous autosuggest shows 'No results found' after finishing no matches search", async () => {
|
|
@@ -788,7 +703,7 @@ describe("NewInputText component asynchronous autosuggest tests", () => {
|
|
|
788
703
|
});
|
|
789
704
|
const onChange = jest.fn();
|
|
790
705
|
const { getByRole, getByText } = render(
|
|
791
|
-
<
|
|
706
|
+
<DxcTextInput label="Autosuggest Countries" onChange={onChange} suggestions={callbackFunc} />
|
|
792
707
|
);
|
|
793
708
|
const input = getByRole("combobox");
|
|
794
709
|
fireEvent.focus(input);
|
|
@@ -807,7 +722,7 @@ describe("NewInputText component asynchronous autosuggest tests", () => {
|
|
|
807
722
|
});
|
|
808
723
|
const onChange = jest.fn();
|
|
809
724
|
const { getByRole, getByText } = render(
|
|
810
|
-
<
|
|
725
|
+
<DxcTextInput label="Autosuggest Countries" onChange={onChange} suggestions={errorCallbackFunc} />
|
|
811
726
|
);
|
|
812
727
|
const input = getByRole("combobox");
|
|
813
728
|
fireEvent.focus(input);
|