@dxc-technology/halstack-react 0.0.0-2aeb707 → 0.0.0-2c8be25
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/README.md +2 -2
- package/babel.config.js +5 -2
- package/dist/BackgroundColorContext.js +46 -0
- package/dist/ThemeContext.js +237 -2
- package/dist/V3Select/V3Select.js +549 -0
- package/dist/V3Select/index.d.ts +27 -0
- package/dist/V3Textarea/V3Textarea.js +264 -0
- package/dist/V3Textarea/index.d.ts +27 -0
- package/dist/accordion/Accordion.js +152 -67
- package/dist/accordion/index.d.ts +28 -0
- package/dist/accordion-group/AccordionGroup.js +38 -11
- package/dist/accordion-group/index.d.ts +16 -0
- package/dist/alert/Alert.js +183 -84
- package/dist/alert/index.d.ts +51 -0
- package/dist/badge/Badge.js +63 -0
- package/dist/box/Box.js +31 -23
- package/dist/box/index.d.ts +25 -0
- package/dist/button/Button.js +63 -27
- package/dist/button/index.d.ts +24 -0
- package/dist/card/Card.js +72 -35
- package/dist/card/index.d.ts +22 -0
- package/dist/checkbox/Checkbox.js +99 -40
- package/dist/checkbox/index.d.ts +24 -0
- package/dist/chip/Chip.js +97 -40
- package/dist/chip/index.d.ts +22 -0
- package/dist/common/RequiredComponent.js +2 -8
- package/dist/common/utils.js +2 -22
- package/dist/common/variables.js +1444 -304
- package/dist/date/Date.js +75 -52
- package/dist/date/index.d.ts +27 -0
- package/dist/date-input/DateInput.js +400 -0
- package/dist/date-input/index.d.ts +95 -0
- package/dist/dialog/Dialog.js +58 -37
- package/dist/dialog/index.d.ts +18 -0
- package/dist/dropdown/Dropdown.js +176 -81
- package/dist/dropdown/index.d.ts +26 -0
- package/dist/file-input/FileInput.js +644 -0
- package/dist/file-input/FileItem.js +287 -0
- package/dist/file-input/index.d.ts +81 -0
- package/dist/footer/Footer.js +90 -40
- package/dist/footer/Icons.js +77 -0
- package/dist/footer/index.d.ts +25 -0
- package/dist/header/Header.js +192 -95
- package/dist/header/Icons.js +59 -0
- package/dist/header/index.d.ts +25 -0
- package/dist/heading/Heading.js +93 -16
- package/dist/heading/index.d.ts +17 -0
- package/dist/input-text/Icons.js +22 -0
- package/dist/input-text/InputText.js +248 -113
- package/dist/input-text/index.d.ts +36 -0
- package/dist/layout/ApplicationLayout.js +18 -26
- package/dist/layout/Icons.js +55 -0
- package/dist/link/Link.js +89 -41
- package/dist/link/index.d.ts +23 -0
- package/dist/main.d.ts +40 -0
- package/dist/main.js +88 -16
- package/dist/number-input/NumberInput.js +136 -0
- package/dist/number-input/NumberInputContext.js +16 -0
- package/dist/number-input/index.d.ts +113 -0
- package/dist/paginator/Icons.js +66 -0
- package/dist/paginator/Paginator.js +144 -71
- package/dist/paginator/index.d.ts +20 -0
- package/dist/password-input/PasswordInput.js +203 -0
- package/dist/password-input/index.d.ts +94 -0
- package/dist/progress-bar/ProgressBar.js +95 -38
- package/dist/progress-bar/index.d.ts +18 -0
- package/dist/radio/Radio.js +31 -17
- package/dist/radio/index.d.ts +23 -0
- package/dist/resultsetTable/ResultsetTable.js +82 -65
- package/dist/resultsetTable/index.d.ts +19 -0
- package/dist/select/Select.js +903 -280
- package/dist/select/index.d.ts +53 -0
- package/dist/sidenav/Sidenav.js +66 -15
- package/dist/sidenav/index.d.ts +13 -0
- package/dist/slider/Slider.js +211 -73
- package/dist/slider/index.d.ts +29 -0
- package/dist/spinner/Spinner.js +247 -59
- package/dist/spinner/index.d.ts +17 -0
- package/dist/stories/Button.js +71 -0
- package/dist/stories/Button.stories.js +55 -0
- package/dist/stories/Header.js +67 -0
- package/dist/stories/Header.stories.js +31 -0
- package/dist/stories/Introduction.stories.mdx +211 -0
- package/dist/stories/Page.js +68 -0
- package/dist/stories/Page.stories.js +39 -0
- package/dist/stories/assets/code-brackets.svg +1 -0
- package/dist/stories/assets/colors.svg +1 -0
- package/dist/stories/assets/comments.svg +1 -0
- package/dist/stories/assets/direction.svg +1 -0
- package/dist/stories/assets/flow.svg +1 -0
- package/dist/stories/assets/plugin.svg +1 -0
- package/dist/stories/assets/repo.svg +1 -0
- package/dist/stories/assets/stackalt.svg +1 -0
- package/dist/stories/button.css +30 -0
- package/dist/stories/header.css +26 -0
- package/dist/stories/page.css +69 -0
- package/dist/switch/Switch.js +50 -27
- package/dist/switch/index.d.ts +24 -0
- package/dist/table/Table.js +51 -24
- package/dist/table/index.d.ts +13 -0
- package/dist/tabs/Tabs.js +193 -35
- package/dist/tabs/index.d.ts +19 -0
- package/dist/tag/Tag.js +68 -35
- package/dist/tag/index.d.ts +24 -0
- package/dist/text-input/TextInput.js +974 -0
- package/dist/text-input/index.d.ts +135 -0
- package/dist/textarea/Textarea.js +248 -106
- package/dist/textarea/index.d.ts +117 -0
- package/dist/toggle/Toggle.js +16 -19
- package/dist/toggle/index.d.ts +21 -0
- package/dist/toggle-group/ToggleGroup.js +142 -41
- package/dist/toggle-group/index.d.ts +21 -0
- package/dist/upload/Upload.js +13 -8
- package/dist/upload/buttons-upload/ButtonsUpload.js +32 -19
- package/dist/upload/buttons-upload/Icons.js +40 -0
- package/dist/upload/dragAndDropArea/DragAndDropArea.js +84 -34
- package/dist/upload/dragAndDropArea/Icons.js +39 -0
- package/dist/upload/file-upload/FileToUpload.js +64 -33
- package/dist/upload/file-upload/Icons.js +66 -0
- package/dist/upload/files-upload/FilesToUpload.js +16 -16
- package/dist/upload/index.d.ts +15 -0
- package/dist/upload/transaction/Icons.js +160 -0
- package/dist/upload/transaction/Transaction.js +42 -49
- package/dist/upload/transactions/Transactions.js +38 -20
- package/dist/useTheme.js +22 -0
- package/dist/wizard/Icons.js +65 -0
- package/dist/wizard/Wizard.js +125 -60
- package/dist/wizard/index.d.ts +18 -0
- package/package.json +20 -10
- package/test/AccordionGroup.test.js +66 -52
- package/test/Date.test.js +15 -13
- package/test/DateInput.test.js +242 -0
- package/test/Dropdown.test.js +15 -0
- package/test/FileInput.test.js +201 -0
- package/test/Footer.test.js +2 -7
- package/test/Header.test.js +5 -10
- package/test/Heading.test.js +60 -12
- package/test/InputText.test.js +2 -3
- package/test/Link.test.js +12 -2
- package/test/NumberInput.test.js +259 -0
- package/test/Paginator.test.js +44 -57
- package/test/PasswordInput.test.js +83 -0
- package/test/ResultsetTable.test.js +32 -6
- package/test/Select.test.js +371 -148
- package/test/Slider.test.js +9 -17
- package/test/Spinner.test.js +5 -0
- package/test/Tabs.test.js +21 -0
- package/test/TextInput.test.js +732 -0
- package/test/Textarea.test.js +193 -0
- package/test/ToggleGroup.test.js +5 -1
- package/test/Upload.test.js +1 -1
- package/test/V3Select.test.js +212 -0
- package/test/{TextArea.test.js → V3TextArea.test.js} +6 -7
- package/dist/accordion/Accordion.stories.js +0 -207
- package/dist/accordion/readme.md +0 -96
- package/dist/accordion-group/AccordionGroup.stories.js +0 -207
- package/dist/accordion-group/readme.md +0 -70
- package/dist/alert/Alert.stories.js +0 -158
- package/dist/alert/close.svg +0 -4
- package/dist/alert/error.svg +0 -4
- package/dist/alert/info.svg +0 -4
- package/dist/alert/readme.md +0 -43
- package/dist/alert/success.svg +0 -4
- package/dist/alert/warning.svg +0 -4
- package/dist/button/Button.stories.js +0 -224
- package/dist/button/readme.md +0 -93
- package/dist/checkbox/Checkbox.stories.js +0 -144
- package/dist/checkbox/readme.md +0 -116
- package/dist/common/services/example-service.js +0 -10
- package/dist/common/services/example-service.test.js +0 -12
- package/dist/date/Date.stories.js +0 -205
- package/dist/date/calendar.svg +0 -1
- package/dist/date/calendar_dark.svg +0 -1
- package/dist/date/readme.md +0 -73
- package/dist/dialog/Dialog.stories.js +0 -217
- package/dist/dialog/readme.md +0 -32
- package/dist/dropdown/Dropdown.stories.js +0 -249
- package/dist/dropdown/baseline-arrow_drop_down.svg +0 -1
- package/dist/dropdown/baseline-arrow_drop_down_wh.svg +0 -4
- package/dist/dropdown/baseline-arrow_drop_up.svg +0 -1
- package/dist/dropdown/baseline-arrow_drop_up_wh.svg +0 -4
- package/dist/dropdown/readme.md +0 -69
- package/dist/footer/Footer.stories.js +0 -94
- package/dist/footer/dxc_logo_wht.png +0 -0
- 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.png +0 -0
- package/dist/header/dxc_logo_blk_rgb.svg +0 -6
- package/dist/header/dxc_logo_white.png +0 -0
- 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/link/readme.md +0 -51
- 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/progress-bar/ProgressBar.stories.js +0 -280
- package/dist/progress-bar/readme.md +0 -63
- package/dist/radio/Radio.stories.js +0 -166
- package/dist/radio/readme.md +0 -70
- 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/slider/readme.md +0 -64
- package/dist/spinner/Spinner.stories.js +0 -183
- package/dist/spinner/readme.md +0 -65
- package/dist/switch/Switch.stories.js +0 -134
- package/dist/switch/readme.md +0 -133
- package/dist/tabs/Tabs.stories.js +0 -130
- package/dist/tabs/readme.md +0 -78
- package/dist/tabs-for-sections/TabsForSections.js +0 -92
- package/dist/tabs-for-sections/readme.md +0 -78
- package/dist/toggle/Toggle.stories.js +0 -297
- package/dist/toggle/readme.md +0 -80
- package/dist/toggle-group/readme.md +0 -82
- package/dist/upload/Upload.stories.js +0 -72
- package/dist/upload/buttons-upload/drag-drop-icon.svg +0 -4
- package/dist/upload/buttons-upload/upload-button.svg +0 -1
- package/dist/upload/dragAndDropArea/upload_drop.svg +0 -4
- package/dist/upload/dragAndDropArea/upload_file.svg +0 -4
- 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/readme.md +0 -37
- 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 -6
- package/dist/wizard/valid_icon.svg +0 -6
- package/dist/wizard/validation-wrong.svg +0 -6
- package/test/TabsForSections.test.js +0 -34
package/test/Paginator.test.js
CHANGED
|
@@ -40,48 +40,51 @@ describe("Paginator component tests", () => {
|
|
|
40
40
|
expect(getByText("Page: 2 of 2")).toBeTruthy();
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
test("
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
<DxcPaginator nextFunction={onClick} currentPage={1} itemsPerPage={10} totalItems={20}></DxcPaginator>
|
|
43
|
+
test("Paginator renders goToPage select", () => {
|
|
44
|
+
const { getByText } = render(
|
|
45
|
+
<DxcPaginator currentPage={2} showGoToPage={true} itemsPerPage={10} totalItems={20}></DxcPaginator>
|
|
47
46
|
);
|
|
48
|
-
|
|
49
|
-
userEvent.click(nextButton);
|
|
50
|
-
expect(onClick).toHaveBeenCalled();
|
|
47
|
+
expect(getByText("Go to page:")).toBeTruthy();
|
|
51
48
|
});
|
|
52
49
|
|
|
53
|
-
test("
|
|
50
|
+
test("Paginator goToPage call correct function", () => {
|
|
54
51
|
const onClick = jest.fn();
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
window.HTMLElement.prototype.scrollIntoView = () => {};
|
|
53
|
+
window.HTMLElement.prototype.scrollTo = () => {};
|
|
54
|
+
const { getByText, getAllByRole, getByRole } = render(
|
|
55
|
+
<DxcPaginator
|
|
56
|
+
currentPage={1}
|
|
57
|
+
itemsPerPage={10}
|
|
58
|
+
totalItems={27}
|
|
59
|
+
showGoToPage={true}
|
|
60
|
+
onPageChange={onClick}
|
|
61
|
+
></DxcPaginator>
|
|
57
62
|
);
|
|
58
|
-
const
|
|
59
|
-
|
|
63
|
+
const goToPageSelect = getAllByRole("combobox")[0];
|
|
64
|
+
act(() => {
|
|
65
|
+
userEvent.click(goToPageSelect);
|
|
66
|
+
});
|
|
67
|
+
const goToPageOption = getByText("2");
|
|
68
|
+
act(() => {
|
|
69
|
+
userEvent.click(goToPageOption);
|
|
70
|
+
});
|
|
60
71
|
expect(onClick).toHaveBeenCalledWith(2);
|
|
61
72
|
});
|
|
62
73
|
|
|
63
|
-
test("Call correct
|
|
64
|
-
const onClick = jest.fn();
|
|
65
|
-
const { getByRole } = render(
|
|
66
|
-
<DxcPaginator prevFunction={onClick} currentPage={2} itemsPerPage={10} totalItems={20}></DxcPaginator>
|
|
67
|
-
);
|
|
68
|
-
const prevButton = getByRole("button");
|
|
69
|
-
userEvent.click(prevButton);
|
|
70
|
-
expect(onClick).toHaveBeenCalled();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
test("Call correct firstFunction", () => {
|
|
74
|
+
test("Call correct goToPageFunction", () => {
|
|
74
75
|
const onClick = jest.fn();
|
|
75
|
-
const {
|
|
76
|
-
<DxcPaginator
|
|
76
|
+
const { getAllByRole } = render(
|
|
77
|
+
<DxcPaginator onPageChange={onClick} currentPage={1} itemsPerPage={10} totalItems={20}></DxcPaginator>
|
|
77
78
|
);
|
|
78
|
-
const
|
|
79
|
-
userEvent.click(
|
|
79
|
+
const nextButton = getAllByRole("button")[2];
|
|
80
|
+
userEvent.click(nextButton);
|
|
80
81
|
expect(onClick).toHaveBeenCalled();
|
|
81
82
|
});
|
|
82
83
|
|
|
83
84
|
test("Call correct itemsPerPageFunction", () => {
|
|
84
85
|
const onClick = jest.fn();
|
|
86
|
+
window.HTMLElement.prototype.scrollIntoView = () => {};
|
|
87
|
+
window.HTMLElement.prototype.scrollTo = () => {};
|
|
85
88
|
const { getAllByText, getByText } = render(
|
|
86
89
|
<DxcPaginator
|
|
87
90
|
currentPage={1}
|
|
@@ -104,10 +107,10 @@ describe("Paginator component tests", () => {
|
|
|
104
107
|
|
|
105
108
|
test("Next button is disable in last page", () => {
|
|
106
109
|
const onClick = jest.fn();
|
|
107
|
-
const {
|
|
108
|
-
<DxcPaginator
|
|
110
|
+
const { getAllByRole } = render(
|
|
111
|
+
<DxcPaginator onPageChange={onClick} currentPage={2} itemsPerPage={10} totalItems={20}></DxcPaginator>
|
|
109
112
|
);
|
|
110
|
-
const nextButton =
|
|
113
|
+
const nextButton = getAllByRole("button")[2];
|
|
111
114
|
expect(nextButton.hasAttribute("disabled")).toBeTruthy();
|
|
112
115
|
userEvent.click(nextButton);
|
|
113
116
|
expect(onClick).toHaveBeenCalledTimes(0);
|
|
@@ -115,10 +118,10 @@ describe("Paginator component tests", () => {
|
|
|
115
118
|
|
|
116
119
|
test("Last button is disable in last page", () => {
|
|
117
120
|
const onClick = jest.fn();
|
|
118
|
-
const {
|
|
119
|
-
<DxcPaginator
|
|
121
|
+
const { getAllByRole } = render(
|
|
122
|
+
<DxcPaginator onPageChange={onClick} currentPage={2} itemsPerPage={10} totalItems={20}></DxcPaginator>
|
|
120
123
|
);
|
|
121
|
-
const lastButton =
|
|
124
|
+
const lastButton = getAllByRole("button")[3];
|
|
122
125
|
expect(lastButton.hasAttribute("disabled")).toBeTruthy();
|
|
123
126
|
userEvent.click(lastButton);
|
|
124
127
|
expect(onClick).toHaveBeenCalledTimes(0);
|
|
@@ -126,10 +129,10 @@ describe("Paginator component tests", () => {
|
|
|
126
129
|
|
|
127
130
|
test("First button is disable in first page", () => {
|
|
128
131
|
const onClick = jest.fn();
|
|
129
|
-
const {
|
|
130
|
-
<DxcPaginator
|
|
132
|
+
const { getAllByRole } = render(
|
|
133
|
+
<DxcPaginator onPageChange={onClick} currentPage={1} itemsPerPage={10} totalItems={20}></DxcPaginator>
|
|
131
134
|
);
|
|
132
|
-
const lastButton =
|
|
135
|
+
const lastButton = getAllByRole("button")[0];
|
|
133
136
|
expect(lastButton.hasAttribute("disabled")).toBeTruthy();
|
|
134
137
|
userEvent.click(lastButton);
|
|
135
138
|
expect(onClick).toHaveBeenCalledTimes(0);
|
|
@@ -137,10 +140,10 @@ describe("Paginator component tests", () => {
|
|
|
137
140
|
|
|
138
141
|
test("Previous button is disable in first page", () => {
|
|
139
142
|
const onClick = jest.fn();
|
|
140
|
-
const {
|
|
141
|
-
<DxcPaginator
|
|
143
|
+
const { getAllByRole } = render(
|
|
144
|
+
<DxcPaginator onPageChange={onClick} currentPage={1} itemsPerPage={10} totalItems={20}></DxcPaginator>
|
|
142
145
|
);
|
|
143
|
-
const lastButton =
|
|
146
|
+
const lastButton = getAllByRole("button")[1];
|
|
144
147
|
expect(lastButton.hasAttribute("disabled")).toBeTruthy();
|
|
145
148
|
userEvent.click(lastButton);
|
|
146
149
|
expect(onClick).toHaveBeenCalledTimes(0);
|
|
@@ -149,15 +152,7 @@ describe("Paginator component tests", () => {
|
|
|
149
152
|
test("Last and next buttons are disable in last page", () => {
|
|
150
153
|
const onClick = jest.fn();
|
|
151
154
|
const { getAllByRole } = render(
|
|
152
|
-
<DxcPaginator
|
|
153
|
-
prevFunction={onClick}
|
|
154
|
-
firstFunction={onClick}
|
|
155
|
-
nextFunction={onClick}
|
|
156
|
-
lastFunction={onClick}
|
|
157
|
-
currentPage={2}
|
|
158
|
-
itemsPerPage={10}
|
|
159
|
-
totalItems={20}
|
|
160
|
-
></DxcPaginator>
|
|
155
|
+
<DxcPaginator onPageChange={onClick} currentPage={2} itemsPerPage={10} totalItems={20}></DxcPaginator>
|
|
161
156
|
);
|
|
162
157
|
const firstButton = getAllByRole("button")[0];
|
|
163
158
|
const prevButton = getAllByRole("button")[1];
|
|
@@ -172,15 +167,7 @@ describe("Paginator component tests", () => {
|
|
|
172
167
|
test("First and previous buttons are disable in first page", () => {
|
|
173
168
|
const onClick = jest.fn();
|
|
174
169
|
const { getAllByRole } = render(
|
|
175
|
-
<DxcPaginator
|
|
176
|
-
prevFunction={onClick}
|
|
177
|
-
firstFunction={onClick}
|
|
178
|
-
nextFunction={onClick}
|
|
179
|
-
lastFunction={onClick}
|
|
180
|
-
currentPage={1}
|
|
181
|
-
itemsPerPage={10}
|
|
182
|
-
totalItems={20}
|
|
183
|
-
></DxcPaginator>
|
|
170
|
+
<DxcPaginator onPageChange={onClick} currentPage={1} itemsPerPage={10} totalItems={20}></DxcPaginator>
|
|
184
171
|
);
|
|
185
172
|
const firstButton = getAllByRole("button")[0];
|
|
186
173
|
const prevButton = getAllByRole("button")[1];
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, fireEvent } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import DxcPasswordInput from "../src/password-input/PasswordInput";
|
|
5
|
+
|
|
6
|
+
describe("Password input component tests", () => {
|
|
7
|
+
test("Password input renders with label", () => {
|
|
8
|
+
const { getByText } = render(<DxcPasswordInput label="Password input label" />);
|
|
9
|
+
expect(getByText("Password input label")).toBeTruthy();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test("Password input renders with helper text", () => {
|
|
13
|
+
const { getByText } = render(<DxcPasswordInput helperText="Helper text" />);
|
|
14
|
+
expect(getByText("Helper text")).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("Password input renders error", () => {
|
|
18
|
+
const { getByText } = render(<DxcPasswordInput error="Error message." />);
|
|
19
|
+
expect(getByText("Error message.")).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("onChange function is called correctly", () => {
|
|
23
|
+
const onChange = jest.fn();
|
|
24
|
+
const { getByRole } = render(<DxcPasswordInput label="Password input" onChange={onChange} />);
|
|
25
|
+
const passwordInput = getByRole("textbox");
|
|
26
|
+
userEvent.type(passwordInput, "Pa$$w0rd");
|
|
27
|
+
expect(onChange).toHaveBeenCalledWith({ value: "P", error: null });
|
|
28
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("onBlur function is called correctly", () => {
|
|
32
|
+
const onBlur = jest.fn();
|
|
33
|
+
const { getByRole } = render(<DxcPasswordInput label="Password input" onBlur={onBlur} />);
|
|
34
|
+
const passwordInput = getByRole("textbox");
|
|
35
|
+
userEvent.type(passwordInput, "Pa$$w0rd");
|
|
36
|
+
fireEvent.blur(passwordInput);
|
|
37
|
+
expect(onBlur).toHaveBeenCalledWith({ value: "Pa$$w0rd", error: null });
|
|
38
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("Clear password input value", () => {
|
|
42
|
+
const { getAllByRole, getByRole } = render(<DxcPasswordInput label="Password input" clearable />);
|
|
43
|
+
const passwordInput = getByRole("textbox");
|
|
44
|
+
userEvent.type(passwordInput, "Pa$$w0rd");
|
|
45
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
46
|
+
const clearButton = getAllByRole("button")[0];
|
|
47
|
+
userEvent.click(clearButton);
|
|
48
|
+
expect(passwordInput.value).toBe("");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("Non clearable password input has no clear icon", () => {
|
|
52
|
+
const { getAllByRole, getByRole } = render(<DxcPasswordInput label="Password input" />);
|
|
53
|
+
const passwordInput = getByRole("textbox");
|
|
54
|
+
userEvent.type(passwordInput, "Pa$$w0rd");
|
|
55
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
56
|
+
const buttons = getAllByRole("button");
|
|
57
|
+
expect(buttons.length).toBe(1);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("Show/hide password input button works correctly", () => {
|
|
61
|
+
const { getAllByRole, getByRole } = render(<DxcPasswordInput label="Password input" clearable />);
|
|
62
|
+
const passwordInput = getByRole("textbox");
|
|
63
|
+
userEvent.type(passwordInput, "Pa$$w0rd");
|
|
64
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
65
|
+
expect(passwordInput.type).toBe("password");
|
|
66
|
+
const showButton = getAllByRole("button")[1];
|
|
67
|
+
userEvent.click(showButton);
|
|
68
|
+
expect(passwordInput.type).toBe("text");
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test("Password input has correct accesibility attributes", () => {
|
|
72
|
+
const { getByRole } = render(<DxcPasswordInput label="Password input" />);
|
|
73
|
+
const passwordInput = getByRole("textbox");
|
|
74
|
+
expect(passwordInput.getAttribute("aria-autocomplete")).toBeNull();
|
|
75
|
+
expect(passwordInput.getAttribute("aria-controls")).toBeNull();
|
|
76
|
+
const showButton = getByRole("button");
|
|
77
|
+
expect(showButton.getAttribute("aria-expanded")).toBe("false");
|
|
78
|
+
expect(showButton.getAttribute("aria-label")).toBe("Show");
|
|
79
|
+
userEvent.click(showButton);
|
|
80
|
+
expect(showButton.getAttribute("aria-expanded")).toBe("true");
|
|
81
|
+
expect(showButton.getAttribute("aria-label")).toBe("Hide");
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { render, fireEvent } from "@testing-library/react";
|
|
2
|
+
import { render, fireEvent, act } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
|
|
3
5
|
import DxcResultsetTable from "../src/resultsetTable/ResultsetTable";
|
|
4
6
|
|
|
5
7
|
const columns = [
|
|
@@ -245,7 +247,33 @@ describe("ResultsetTable component tests", () => {
|
|
|
245
247
|
const nextButton = getAllByRole("button")[2];
|
|
246
248
|
fireEvent.click(nextButton);
|
|
247
249
|
expect(getByText("4 to 6 of 10")).toBeTruthy();
|
|
248
|
-
expect(getByText("Page: 2 of 4")).toBeTruthy();
|
|
250
|
+
// expect(getByText("Page: 2 of 4")).toBeTruthy();
|
|
251
|
+
expect(getByText("Rick")).toBeTruthy();
|
|
252
|
+
expect(getByText("Mark")).toBeTruthy();
|
|
253
|
+
expect(getByText("Cris")).toBeTruthy();
|
|
254
|
+
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
test("Resultsettable goToPage works as expected", () => {
|
|
258
|
+
window.HTMLElement.prototype.scrollIntoView = () => {};
|
|
259
|
+
window.HTMLElement.prototype.scrollTo = () => {};
|
|
260
|
+
const { getByText, getAllByRole, getByRole } = render(
|
|
261
|
+
<DxcResultsetTable columns={columns} showGoToPage={true} rows={rows} itemsPerPage={3}></DxcResultsetTable>
|
|
262
|
+
);
|
|
263
|
+
expect(getByText("Peter")).toBeTruthy();
|
|
264
|
+
expect(getByText("Louis")).toBeTruthy();
|
|
265
|
+
expect(getByText("Lana")).toBeTruthy();
|
|
266
|
+
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
267
|
+
const goToPageSelect = getAllByRole("button")[2];
|
|
268
|
+
act(() => {
|
|
269
|
+
userEvent.click(goToPageSelect);
|
|
270
|
+
});
|
|
271
|
+
const goToPageOption = getByText("2");
|
|
272
|
+
act(() => {
|
|
273
|
+
userEvent.click(goToPageOption);
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
expect(getByText("4 to 6 of 10")).toBeTruthy();
|
|
249
277
|
expect(getByText("Rick")).toBeTruthy();
|
|
250
278
|
expect(getByText("Mark")).toBeTruthy();
|
|
251
279
|
expect(getByText("Cris")).toBeTruthy();
|
|
@@ -259,7 +287,6 @@ describe("ResultsetTable component tests", () => {
|
|
|
259
287
|
const lastButton = getAllByRole("button")[3];
|
|
260
288
|
fireEvent.click(lastButton);
|
|
261
289
|
expect(getByText("10 to 10 of 10")).toBeTruthy();
|
|
262
|
-
expect(getByText("Page: 4 of 4")).toBeTruthy();
|
|
263
290
|
expect(getAllByRole("row")).toHaveLength(2);
|
|
264
291
|
expect(getByText("Cosmin")).toBeTruthy();
|
|
265
292
|
});
|
|
@@ -293,12 +320,11 @@ describe("ResultsetTable component tests", () => {
|
|
|
293
320
|
itemsPerPageOptions={[2, 3]}
|
|
294
321
|
></DxcResultsetTable>
|
|
295
322
|
);
|
|
296
|
-
const lastButton = getAllByRole("button")[
|
|
323
|
+
const lastButton = getAllByRole("button")[3];
|
|
297
324
|
fireEvent.click(lastButton);
|
|
298
325
|
expect(getAllByRole("row").length - 1).toEqual(1);
|
|
299
|
-
expect(queryByText("Page: 4 of 4")).toBeTruthy();
|
|
300
326
|
rerender(<DxcResultsetTable columns={columns} rows={rows} itemsPerPage={6}></DxcResultsetTable>);
|
|
301
327
|
expect(getAllByRole("row").length - 1).toEqual(6);
|
|
302
|
-
expect(queryByText("
|
|
328
|
+
expect(queryByText("Peter")).toBeTruthy();
|
|
303
329
|
});
|
|
304
330
|
});
|