@dxc-technology/halstack-react 0.0.0-669d8de → 0.0.0-69ca263
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 +1 -1
- package/babel.config.js +0 -1
- package/dist/ThemeContext.js +134 -100
- 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 +44 -39
- package/dist/accordion/index.d.ts +28 -0
- package/dist/accordion-group/AccordionGroup.js +1 -3
- package/dist/accordion-group/index.d.ts +16 -0
- package/dist/alert/Alert.js +6 -6
- package/dist/alert/index.d.ts +51 -0
- package/dist/box/index.d.ts +25 -0
- package/dist/button/Button.js +31 -24
- package/dist/button/index.d.ts +24 -0
- package/dist/card/index.d.ts +22 -0
- package/dist/checkbox/Checkbox.js +22 -17
- package/dist/checkbox/index.d.ts +24 -0
- package/dist/chip/index.d.ts +22 -0
- package/dist/common/variables.js +535 -393
- package/dist/date/Date.js +5 -7
- package/dist/date/index.d.ts +27 -0
- package/dist/{new-date/NewDate.js → date-input/DateInput.js} +69 -72
- package/dist/date-input/index.d.ts +95 -0
- package/dist/dialog/Dialog.js +8 -30
- package/dist/dialog/index.d.ts +18 -0
- package/dist/dropdown/Dropdown.js +108 -68
- 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 +44 -18
- package/dist/footer/Icons.js +77 -0
- package/dist/footer/index.d.ts +25 -0
- package/dist/header/Header.js +115 -68
- package/dist/header/Icons.js +59 -0
- package/dist/header/index.d.ts +25 -0
- package/dist/heading/Heading.js +12 -0
- package/dist/heading/index.d.ts +17 -0
- package/dist/input-text/Icons.js +22 -0
- package/dist/input-text/InputText.js +4 -6
- package/dist/input-text/index.d.ts +36 -0
- package/dist/layout/ApplicationLayout.js +5 -9
- package/dist/layout/Icons.js +55 -0
- package/dist/link/Link.js +4 -8
- package/dist/link/index.d.ts +23 -0
- package/dist/main.d.ts +40 -0
- package/dist/main.js +38 -30
- 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 +53 -37
- package/dist/paginator/index.d.ts +20 -0
- package/dist/{password/Password.js → password-input/PasswordInput.js} +17 -14
- package/dist/password-input/index.d.ts +94 -0
- package/dist/progress-bar/ProgressBar.js +62 -26
- package/dist/progress-bar/index.d.ts +18 -0
- package/dist/radio/index.d.ts +23 -0
- package/dist/resultsetTable/index.d.ts +19 -0
- package/dist/select/Select.js +869 -358
- package/dist/select/index.d.ts +53 -0
- package/dist/sidenav/Sidenav.js +6 -4
- package/dist/sidenav/index.d.ts +13 -0
- package/dist/slider/Slider.js +155 -66
- package/dist/slider/index.d.ts +29 -0
- package/dist/spinner/Spinner.js +217 -54
- 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/index.d.ts +24 -0
- package/dist/table/index.d.ts +13 -0
- package/dist/tabs/index.d.ts +19 -0
- package/dist/tag/Tag.js +26 -32
- package/dist/tag/index.d.ts +24 -0
- package/dist/{new-input-text/NewInputText.js → text-input/TextInput.js} +186 -173
- 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/index.d.ts +21 -0
- package/dist/toggle-group/ToggleGroup.js +130 -44
- package/dist/toggle-group/index.d.ts +21 -0
- package/dist/upload/buttons-upload/ButtonsUpload.js +7 -11
- package/dist/upload/buttons-upload/Icons.js +40 -0
- package/dist/upload/dragAndDropArea/DragAndDropArea.js +14 -14
- package/dist/upload/dragAndDropArea/Icons.js +39 -0
- package/dist/upload/file-upload/FileToUpload.js +26 -21
- package/dist/upload/file-upload/Icons.js +66 -0
- package/dist/upload/index.d.ts +15 -0
- 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/dist/wizard/index.d.ts +18 -0
- package/package.json +15 -10
- package/test/Date.test.js +13 -11
- 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/Heading.test.js +60 -12
- package/test/InputText.test.js +1 -2
- package/test/{Number.test.js → NumberInput.test.js} +84 -66
- package/test/Paginator.test.js +6 -2
- package/test/PasswordInput.test.js +83 -0
- package/test/ResultsetTable.test.js +6 -6
- package/test/Select.test.js +371 -145
- package/test/Slider.test.js +9 -17
- package/test/Spinner.test.js +5 -0
- package/test/{NewInputText.test.js → TextInput.test.js} +148 -233
- 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/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/date/Date.stories.js +0 -205
- 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.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/link/readme.md +0 -51
- 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/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 -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
- package/test/TabsForSections.test.js +0 -34
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxc-technology/halstack-react",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-69ca263",
|
|
4
4
|
"description": "DXC Halstack React components library",
|
|
5
5
|
"repository": "dxc-technology/halstack-react",
|
|
6
6
|
"homepage": "http://developer.dxc.com/tools/react",
|
|
@@ -11,10 +11,11 @@
|
|
|
11
11
|
"url": "https://dxc.com"
|
|
12
12
|
},
|
|
13
13
|
"main": "./dist/main.js",
|
|
14
|
+
"types": "./dist/main.d.ts",
|
|
14
15
|
"peerDependencies": {
|
|
15
|
-
"react": "^
|
|
16
|
-
"react-dom": "^
|
|
17
|
-
"styled-components": "
|
|
16
|
+
"react": "^17.0.1",
|
|
17
|
+
"react-dom": "^17.0.1",
|
|
18
|
+
"styled-components": "^5.0.1"
|
|
18
19
|
},
|
|
19
20
|
"dependencies": {
|
|
20
21
|
"@date-io/date-fns": "^1.3.9",
|
|
@@ -28,7 +29,6 @@
|
|
|
28
29
|
"date-fns": "^2.0.0-beta.4",
|
|
29
30
|
"moment": "2.24.0",
|
|
30
31
|
"prop-types": "^15.7.2",
|
|
31
|
-
"react-use-scrollspy": "^2.0.0",
|
|
32
32
|
"rgb-hex": "^3.0.0",
|
|
33
33
|
"uuid": "^8.3.2"
|
|
34
34
|
},
|
|
@@ -36,7 +36,9 @@
|
|
|
36
36
|
"test": "jest",
|
|
37
37
|
"test:watch": "npm test -- --watch --coverage",
|
|
38
38
|
"build": "babel src --out-dir dist --copy-files --verbose && node ../scripts/build/copy-readme.js",
|
|
39
|
-
"build:watch": "babel src --watch --out-dir dist --copy-files --verbose"
|
|
39
|
+
"build:watch": "babel src --watch --out-dir dist --copy-files --verbose",
|
|
40
|
+
"storybook": "start-storybook -p 6006",
|
|
41
|
+
"build-storybook": "build-storybook"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
44
|
"@babel/cli": "^7.6.2",
|
|
@@ -47,9 +49,14 @@
|
|
|
47
49
|
"@babel/plugin-transform-runtime": "^7.10.1",
|
|
48
50
|
"@babel/preset-env": "^7.6.2",
|
|
49
51
|
"@babel/preset-react": "^7.0.0",
|
|
52
|
+
"@storybook/addon-actions": "^6.4.9",
|
|
53
|
+
"@storybook/addon-essentials": "^6.4.9",
|
|
54
|
+
"@storybook/addon-links": "^6.4.9",
|
|
55
|
+
"@storybook/react": "^6.4.9",
|
|
50
56
|
"@testing-library/react": "^11.2.5",
|
|
51
57
|
"babel-jest": "^24.8.0",
|
|
52
58
|
"babel-loader": "^8.0.6",
|
|
59
|
+
"chromatic": "^6.3.3",
|
|
53
60
|
"eslint": "^5.16.0",
|
|
54
61
|
"eslint-config-airbnb": "^17.1.0",
|
|
55
62
|
"eslint-config-prettier": "^6.7.0",
|
|
@@ -58,6 +65,7 @@
|
|
|
58
65
|
"eslint-plugin-jsx-a11y": "^6.2.1",
|
|
59
66
|
"eslint-plugin-react": "^7.13.0",
|
|
60
67
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
68
|
+
"eslint-plugin-storybook": "^0.5.5",
|
|
61
69
|
"identity-obj-proxy": "^3.0.0",
|
|
62
70
|
"jest": "^25.5.4",
|
|
63
71
|
"react": "file:../node_modules/react",
|
|
@@ -70,9 +78,6 @@
|
|
|
70
78
|
"\\.(css|less|scss|sass)$": "identity-obj-proxy",
|
|
71
79
|
"\\.(svg)$": "<rootDir>/test/mocks/svgMock.js",
|
|
72
80
|
"\\.(png)$": "<rootDir>/test/mocks/pngMock.js"
|
|
73
|
-
}
|
|
74
|
-
"transformIgnorePatterns": [
|
|
75
|
-
"/node_modules/(?!react-use-scrollspy).+\\.js$"
|
|
76
|
-
]
|
|
81
|
+
}
|
|
77
82
|
}
|
|
78
83
|
}
|
package/test/Date.test.js
CHANGED
|
@@ -51,7 +51,7 @@ describe("Controlled Date Component", () => {
|
|
|
51
51
|
|
|
52
52
|
test("Calendar´s value is the same as the input´s date if it´s right (Depending on the format)", () => {
|
|
53
53
|
const { getByRole, getByText, getByTestId } = render(<DxcDate label="Birthdate" value="16-10-2020" />);
|
|
54
|
-
fireEvent.click(getByTestId(
|
|
54
|
+
fireEvent.click(getByTestId("calendarIcon"));
|
|
55
55
|
expect(getByText("Fri, Oct 16")).toBeTruthy();
|
|
56
56
|
});
|
|
57
57
|
|
|
@@ -64,7 +64,7 @@ describe("Controlled Date Component", () => {
|
|
|
64
64
|
fireEvent.change(input, { target: { value: "10-02-2020" } });
|
|
65
65
|
|
|
66
66
|
rerender(<DxcDate label="Birthdate" value="10-02-2020" />);
|
|
67
|
-
const calendarButton = getByTestId(
|
|
67
|
+
const calendarButton = getByTestId("calendarIcon");
|
|
68
68
|
fireEvent.click(calendarButton);
|
|
69
69
|
expect(getByText("Mon, Feb 10")).toBeTruthy();
|
|
70
70
|
});
|
|
@@ -152,7 +152,7 @@ describe("Controlled Date Component", () => {
|
|
|
152
152
|
const onChange = jest.fn();
|
|
153
153
|
|
|
154
154
|
const component = render(<DxcDate label="Birthdate" value="01-02-2020" onChange={onChange} />);
|
|
155
|
-
const calendarButton = component.getByTestId(
|
|
155
|
+
const calendarButton = component.getByTestId("calendarIcon");
|
|
156
156
|
fireEvent.click(calendarButton);
|
|
157
157
|
const dayButton = component.getByRole("button", { name: "10" });
|
|
158
158
|
fireEvent.click(dayButton);
|
|
@@ -166,7 +166,7 @@ describe("Controlled Date Component", () => {
|
|
|
166
166
|
});
|
|
167
167
|
|
|
168
168
|
const component = render(<DxcDate label="Birthdate" value="30-10-2020" onChange={onChange} />);
|
|
169
|
-
const calendarButton = component.getByTestId(
|
|
169
|
+
const calendarButton = component.getByTestId("calendarIcon");
|
|
170
170
|
fireEvent.click(calendarButton);
|
|
171
171
|
const dayButton = component.getByRole("button", { name: "16" });
|
|
172
172
|
fireEvent.click(dayButton);
|
|
@@ -179,7 +179,7 @@ describe("Controlled Date Component", () => {
|
|
|
179
179
|
});
|
|
180
180
|
|
|
181
181
|
const component = render(<DxcDate label="Birthdate" value="01-10-2020" onChange={onChange} />);
|
|
182
|
-
const calendarButton = component.getByTestId(
|
|
182
|
+
const calendarButton = component.getByTestId("calendarIcon");
|
|
183
183
|
fireEvent.click(calendarButton);
|
|
184
184
|
const dayButton = component.getByRole("button", { name: "16" });
|
|
185
185
|
fireEvent.click(dayButton);
|
|
@@ -192,7 +192,7 @@ describe("Controlled Date Component", () => {
|
|
|
192
192
|
});
|
|
193
193
|
|
|
194
194
|
const component = render(<DxcDate label="Birthdate" format="yyyy/MM/dd" value="2020/10/01" onChange={onChange} />);
|
|
195
|
-
const calendarButton = component.getByTestId(
|
|
195
|
+
const calendarButton = component.getByTestId("calendarIcon");
|
|
196
196
|
fireEvent.click(calendarButton);
|
|
197
197
|
const dayButton = component.getByRole("button", { name: "16" });
|
|
198
198
|
fireEvent.click(dayButton);
|
|
@@ -201,7 +201,7 @@ describe("Controlled Date Component", () => {
|
|
|
201
201
|
|
|
202
202
|
test("Check selected date on calendar is the same date as the one on the input", () => {
|
|
203
203
|
const component = render(<DxcDate label="Birthdate" value="01-10-2020" />);
|
|
204
|
-
const calendarButton = component.getByTestId(
|
|
204
|
+
const calendarButton = component.getByTestId("calendarIcon");
|
|
205
205
|
fireEvent.click(calendarButton);
|
|
206
206
|
const dayButton = component.getByRole("button", { name: "1" });
|
|
207
207
|
expect(dayButton.classList.contains("MuiPickersDay-daySelected")).toBe(true);
|
|
@@ -249,14 +249,16 @@ describe("Uncontrolled Date Component", () => {
|
|
|
249
249
|
const date = new Date("2020-10-16 00:00:00");
|
|
250
250
|
|
|
251
251
|
test("Calendar´s value is the same as the input´s date if it´s right after changing the input value", () => {
|
|
252
|
-
const { getByRole, getByText, rerender, getByPlaceholderText, getByTestId } = render(
|
|
252
|
+
const { getByRole, getByText, rerender, getByPlaceholderText, getByTestId } = render(
|
|
253
|
+
<DxcDate label="Birthdate" placeholder />
|
|
254
|
+
);
|
|
253
255
|
// const input = getByRole("textbox");
|
|
254
256
|
const input = getByPlaceholderText(defaultFormat);
|
|
255
257
|
|
|
256
258
|
fireEvent.change(input, { target: { value: "10-02-2020" } });
|
|
257
259
|
|
|
258
260
|
rerender(<DxcDate label="Birthdate" value="10-02-2020" />);
|
|
259
|
-
const calendarButton = getByTestId(
|
|
261
|
+
const calendarButton = getByTestId("calendarIcon");
|
|
260
262
|
fireEvent.click(calendarButton);
|
|
261
263
|
expect(getByText("Mon, Feb 10")).toBeTruthy();
|
|
262
264
|
});
|
|
@@ -336,7 +338,7 @@ describe("Uncontrolled Date Component", () => {
|
|
|
336
338
|
const onChange = jest.fn();
|
|
337
339
|
|
|
338
340
|
const component = render(<DxcDate label="Birthdate" onChange={onChange} />);
|
|
339
|
-
const calendarButton = component.getByTestId(
|
|
341
|
+
const calendarButton = component.getByTestId("calendarIcon");
|
|
340
342
|
fireEvent.click(calendarButton);
|
|
341
343
|
const dayButton = component.getByRole("button", { name: "10" });
|
|
342
344
|
fireEvent.click(dayButton);
|
|
@@ -350,7 +352,7 @@ describe("Uncontrolled Date Component", () => {
|
|
|
350
352
|
const input = component.getByPlaceholderText(defaultFormat);
|
|
351
353
|
|
|
352
354
|
fireEvent.change(input, { target: { value: "10-02-2020" } });
|
|
353
|
-
const calendarButton = component.getByTestId(
|
|
355
|
+
const calendarButton = component.getByTestId("calendarIcon");
|
|
354
356
|
fireEvent.click(calendarButton);
|
|
355
357
|
const dayButton = component.getByRole("button", { name: "10" });
|
|
356
358
|
expect(dayButton.classList.contains("MuiPickersDay-daySelected")).toBe(true);
|
|
@@ -2,41 +2,55 @@ import React from "react";
|
|
|
2
2
|
import { render, fireEvent } from "@testing-library/react";
|
|
3
3
|
import userEvent from "@testing-library/user-event";
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import DxcDateInput from "../src/date-input/DateInput";
|
|
6
6
|
|
|
7
|
-
describe("
|
|
7
|
+
describe("DateInput component tests", () => {
|
|
8
8
|
test("Renders with correct label, helper text, optional, placeholder and clearable action", () => {
|
|
9
9
|
const { getByText, getByRole, getAllByRole } = render(
|
|
10
|
-
<
|
|
10
|
+
<DxcDateInput label="Example label" helperText="Example of helper text" placeholder optional clearable />
|
|
11
11
|
);
|
|
12
12
|
const input = getByRole("textbox");
|
|
13
13
|
expect(getByText("Example label")).toBeTruthy();
|
|
14
14
|
expect(getByText("Example of helper text")).toBeTruthy();
|
|
15
15
|
expect(getByText("(Optional)")).toBeTruthy();
|
|
16
16
|
expect(input.getAttribute("placeholder")).toBe("DD-MM-YYYY");
|
|
17
|
-
userEvent.type(input, "10/
|
|
17
|
+
userEvent.type(input, "10/10/2010");
|
|
18
18
|
const closeAction = getAllByRole("button")[0];
|
|
19
19
|
userEvent.click(closeAction);
|
|
20
20
|
expect(input.value).toBe("");
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
test("Renders with personalized error", () => {
|
|
24
|
-
const { getByText } = render(<
|
|
25
|
-
|
|
24
|
+
const { getByText } = render(<DxcDateInput error="Personalized error." />);
|
|
26
25
|
expect(getByText("Personalized error.")).toBeTruthy();
|
|
27
26
|
});
|
|
28
27
|
|
|
29
|
-
test("Renders with correct format: user typed date but it's invalid", () => {
|
|
30
|
-
const
|
|
28
|
+
test("Renders with correct format: user typed date but it's invalid, onBlur error", () => {
|
|
29
|
+
const onBlur = jest.fn(({ value, error }) => {
|
|
30
|
+
expect(value).toBe("10/90/2010");
|
|
31
|
+
expect(error).toBe("Invalid date.");
|
|
32
|
+
});
|
|
33
|
+
const { getByRole } = render(<DxcDateInput label="With format MM/dd/yyyy" format="MM/dd/yyyy" onBlur={onBlur} />);
|
|
31
34
|
const input = getByRole("textbox");
|
|
32
35
|
|
|
33
36
|
userEvent.type(input, "10/90/2010");
|
|
34
37
|
fireEvent.blur(input);
|
|
35
|
-
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("Renders with correct format: user typed date but it's invalid, onChange error", () => {
|
|
41
|
+
const onChange = jest.fn();
|
|
42
|
+
const { getByRole } = render(
|
|
43
|
+
<DxcDateInput label="With format MM/dd/yyyy" format="MM/dd/yyyy" onChange={onChange} />
|
|
44
|
+
);
|
|
45
|
+
const input = getByRole("textbox");
|
|
46
|
+
|
|
47
|
+
userEvent.type(input, "10/90/2010");
|
|
48
|
+
expect(onChange).toHaveBeenCalledTimes(10);
|
|
49
|
+
expect(onChange).toHaveBeenCalledWith({ value: "10/90/2010", error: "Invalid date.", date: null });
|
|
36
50
|
});
|
|
37
51
|
|
|
38
52
|
test("Calendar renders with correct date: today's date", () => {
|
|
39
|
-
const { getByText, getByRole } = render(<
|
|
53
|
+
const { getByText, getByRole } = render(<DxcDateInput />);
|
|
40
54
|
const calendarAction = getByRole("button");
|
|
41
55
|
const d = new Date();
|
|
42
56
|
const options = { weekday: "short", month: "short", day: "numeric" };
|
|
@@ -46,7 +60,7 @@ describe("NewDate component tests", () => {
|
|
|
46
60
|
});
|
|
47
61
|
|
|
48
62
|
test("Calendar renders with correct date: value prop", () => {
|
|
49
|
-
const { getByText, getByRole } = render(<
|
|
63
|
+
const { getByText, getByRole } = render(<DxcDateInput value="20-10-2019" />);
|
|
50
64
|
const calendarAction = getByRole("button");
|
|
51
65
|
const d = new Date(2019, 9, 20);
|
|
52
66
|
const options = { weekday: "short", month: "short", day: "numeric" };
|
|
@@ -56,7 +70,7 @@ describe("NewDate component tests", () => {
|
|
|
56
70
|
});
|
|
57
71
|
|
|
58
72
|
test("Calendar renders with correct date: user typed value", () => {
|
|
59
|
-
const { getByText, getByRole } = render(<
|
|
73
|
+
const { getByText, getByRole } = render(<DxcDateInput />);
|
|
60
74
|
const calendarAction = getByRole("button");
|
|
61
75
|
const d = new Date(2010, 0, 1);
|
|
62
76
|
const options = { weekday: "short", month: "short", day: "numeric" };
|
|
@@ -68,7 +82,8 @@ describe("NewDate component tests", () => {
|
|
|
68
82
|
});
|
|
69
83
|
|
|
70
84
|
test("Calendar renders with correct date: invalid date, renders with today's date", () => {
|
|
71
|
-
const
|
|
85
|
+
const onBlur = jest.fn();
|
|
86
|
+
const { getByText, getByRole } = render(<DxcDateInput onBlur={onBlur} />);
|
|
72
87
|
const calendarAction = getByRole("button");
|
|
73
88
|
const d = new Date();
|
|
74
89
|
const options = { weekday: "short", month: "short", day: "numeric" };
|
|
@@ -76,17 +91,18 @@ describe("NewDate component tests", () => {
|
|
|
76
91
|
|
|
77
92
|
userEvent.type(input, "01-01-xxxx");
|
|
78
93
|
fireEvent.blur(input);
|
|
79
|
-
expect(
|
|
94
|
+
expect(onBlur).toHaveBeenCalled();
|
|
95
|
+
expect(onBlur).toHaveBeenCalledWith({ value: "01-01-xxxx", error: "Invalid date.", date: null });
|
|
80
96
|
userEvent.click(calendarAction);
|
|
81
97
|
expect(getByText(d.toLocaleString("en-US", options))).toBeTruthy();
|
|
82
98
|
});
|
|
83
99
|
|
|
84
100
|
test("Selecting a date from the calendar with an specific format", () => {
|
|
85
|
-
const { getByText, getByRole } = render(<
|
|
101
|
+
const { getByText, getByRole } = render(<DxcDateInput label="With format M-dd-yyyy" format="M-dd-yyyy" />);
|
|
86
102
|
const input = getByRole("textbox");
|
|
87
103
|
const calendarAction = getByRole("button");
|
|
88
104
|
userEvent.click(calendarAction);
|
|
89
|
-
const dayButton =
|
|
105
|
+
const dayButton = getByText("10").closest("button");
|
|
90
106
|
fireEvent.click(dayButton);
|
|
91
107
|
const d = new Date();
|
|
92
108
|
d.setDate(10);
|
|
@@ -97,7 +113,7 @@ describe("NewDate component tests", () => {
|
|
|
97
113
|
});
|
|
98
114
|
|
|
99
115
|
test("Selecting a date from the calendar (using keyboard presses)", () => {
|
|
100
|
-
const { getByRole } = render(<
|
|
116
|
+
const { getByRole } = render(<DxcDateInput />);
|
|
101
117
|
const calendarAction = getByRole("button");
|
|
102
118
|
const input = getByRole("textbox");
|
|
103
119
|
|
|
@@ -114,14 +130,14 @@ describe("NewDate component tests", () => {
|
|
|
114
130
|
test("onChange & onBlur functions are called correctly", () => {
|
|
115
131
|
const onBlur = jest.fn();
|
|
116
132
|
const onChange = jest.fn();
|
|
117
|
-
const { getByRole } = render(<
|
|
133
|
+
const { getByRole } = render(<DxcDateInput onChange={onChange} onBlur={onBlur} />);
|
|
118
134
|
const input = getByRole("textbox");
|
|
119
135
|
const d = new Date(2011, 9, 10);
|
|
120
136
|
|
|
121
137
|
userEvent.type(input, "10-10-2011");
|
|
122
138
|
expect(input.value).toBe("10-10-2011");
|
|
123
139
|
expect(onChange).toHaveBeenCalledTimes(10);
|
|
124
|
-
expect(onChange).toHaveBeenCalledWith({ value: "10-10-2011", date: d });
|
|
140
|
+
expect(onChange).toHaveBeenCalledWith({ value: "10-10-2011", error: null, date: d });
|
|
125
141
|
fireEvent.blur(input);
|
|
126
142
|
expect(onBlur).toHaveBeenCalled();
|
|
127
143
|
expect(onBlur).toHaveBeenCalledWith({ value: "10-10-2011", error: null, date: d });
|
|
@@ -130,14 +146,13 @@ describe("NewDate component tests", () => {
|
|
|
130
146
|
test("onChange & onBlur functions are called correctly, also with errors", () => {
|
|
131
147
|
const onBlur = jest.fn();
|
|
132
148
|
const onChange = jest.fn();
|
|
133
|
-
const { getByRole } = render(<
|
|
149
|
+
const { getByRole } = render(<DxcDateInput onChange={onChange} onBlur={onBlur} />);
|
|
134
150
|
const input = getByRole("textbox");
|
|
135
|
-
const d = new Date(2011, 9, 10);
|
|
136
151
|
|
|
137
152
|
userEvent.type(input, "10-10-");
|
|
138
153
|
expect(input.value).toBe("10-10-");
|
|
139
154
|
expect(onChange).toHaveBeenCalledTimes(6);
|
|
140
|
-
expect(onChange).toHaveBeenCalledWith({ value: "10-10-", date: null });
|
|
155
|
+
expect(onChange).toHaveBeenCalledWith({ value: "10-10-", error: "Invalid date.", date: null });
|
|
141
156
|
fireEvent.blur(input);
|
|
142
157
|
expect(onBlur).toHaveBeenCalled();
|
|
143
158
|
expect(onBlur).toHaveBeenCalledWith({ value: "10-10-", error: "Invalid date.", date: null });
|
|
@@ -145,7 +160,7 @@ describe("NewDate component tests", () => {
|
|
|
145
160
|
|
|
146
161
|
test("onBlur function removes the error when it is fixed", () => {
|
|
147
162
|
const onBlur = jest.fn();
|
|
148
|
-
const { getByRole } = render(<
|
|
163
|
+
const { getByRole } = render(<DxcDateInput onBlur={onBlur} />);
|
|
149
164
|
const input = getByRole("textbox");
|
|
150
165
|
const d = new Date(2002, 1, 20);
|
|
151
166
|
|
|
@@ -164,7 +179,7 @@ describe("NewDate component tests", () => {
|
|
|
164
179
|
|
|
165
180
|
test("onBlur function removes the error when the input is empty", () => {
|
|
166
181
|
const onBlur = jest.fn();
|
|
167
|
-
const { getByRole } = render(<
|
|
182
|
+
const { getByRole } = render(<DxcDateInput onBlur={onBlur} optional />);
|
|
168
183
|
const input = getByRole("textbox");
|
|
169
184
|
|
|
170
185
|
userEvent.type(input, "test");
|
|
@@ -178,8 +193,32 @@ describe("NewDate component tests", () => {
|
|
|
178
193
|
expect(onBlur).toHaveBeenCalledWith({ value: "", error: null, date: null });
|
|
179
194
|
});
|
|
180
195
|
|
|
181
|
-
test("
|
|
182
|
-
const
|
|
196
|
+
test("onBlur & onChange functions error: required field (not optional)", () => {
|
|
197
|
+
const onBlur = jest.fn();
|
|
198
|
+
const onChange = jest.fn();
|
|
199
|
+
const { getByRole } = render(<DxcDateInput onBlur={onBlur} onChange={onChange} />);
|
|
200
|
+
const date = getByRole("textbox");
|
|
201
|
+
|
|
202
|
+
userEvent.type(date, "t");
|
|
203
|
+
expect(date.value).toBe("t");
|
|
204
|
+
userEvent.clear(date);
|
|
205
|
+
fireEvent.blur(date);
|
|
206
|
+
expect(onBlur).toHaveBeenCalled();
|
|
207
|
+
expect(onBlur).toHaveBeenCalledWith({
|
|
208
|
+
value: "",
|
|
209
|
+
error: "This field is required. Please, enter a value.",
|
|
210
|
+
date: null,
|
|
211
|
+
});
|
|
212
|
+
expect(onChange).toHaveBeenCalled();
|
|
213
|
+
expect(onChange).toHaveBeenCalledWith({
|
|
214
|
+
value: "",
|
|
215
|
+
error: "This field is required. Please, enter a value.",
|
|
216
|
+
date: null,
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
test("Disabled date input (calendar action must be shown but not clickable)", () => {
|
|
221
|
+
const { getByRole, queryByText } = render(<DxcDateInput disabled />);
|
|
183
222
|
const calendarAction = getByRole("button");
|
|
184
223
|
const d = new Date();
|
|
185
224
|
const options = { weekday: "short", month: "short", day: "numeric" };
|
|
@@ -190,7 +229,7 @@ describe("NewDate component tests", () => {
|
|
|
190
229
|
});
|
|
191
230
|
|
|
192
231
|
test("Input has correct accesibility attributes", () => {
|
|
193
|
-
const { getByRole } = render(<
|
|
232
|
+
const { getByRole } = render(<DxcDateInput label="Date input label" />);
|
|
194
233
|
const input = getByRole("textbox");
|
|
195
234
|
expect(input.getAttribute("aria-autocomplete")).toBeNull();
|
|
196
235
|
expect(input.getAttribute("aria-controls")).toBeNull();
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, fireEvent, waitFor } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
|
|
5
|
+
import DxcFileInput from "../src/file-input/FileInput";
|
|
6
|
+
|
|
7
|
+
describe("FileInput component tests", () => {
|
|
8
|
+
const file1 = new File(["file1"], "file1.png", { type: "image/png" });
|
|
9
|
+
const file2 = new File(["file2"], "file2.txt", {
|
|
10
|
+
type: "text/plain",
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const files = [
|
|
14
|
+
{
|
|
15
|
+
error: null,
|
|
16
|
+
preview: null,
|
|
17
|
+
file: file1,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
error: "Error message",
|
|
21
|
+
preview: null,
|
|
22
|
+
file: file2,
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
test("Renders with correct labels and helper text in file mode", () => {
|
|
27
|
+
const { getByText } = render(<DxcFileInput label="File input label" helperText="File input helper text" />);
|
|
28
|
+
expect(getByText("File input label")).toBeTruthy();
|
|
29
|
+
expect(getByText("File input helper text")).toBeTruthy();
|
|
30
|
+
});
|
|
31
|
+
test("Renders with correct button label in file mode", () => {
|
|
32
|
+
const { getByText } = render(<DxcFileInput label="File input label" helperText="File input helper text" />);
|
|
33
|
+
expect(getByText("Select files")).toBeTruthy();
|
|
34
|
+
});
|
|
35
|
+
test("Renders with correct labels in filedrop mode", () => {
|
|
36
|
+
const { getByText } = render(
|
|
37
|
+
<DxcFileInput label="File input label" helperText="File input helper text" mode="filedrop" />
|
|
38
|
+
);
|
|
39
|
+
expect(getByText("Select")).toBeTruthy();
|
|
40
|
+
expect(getByText("or drop files")).toBeTruthy();
|
|
41
|
+
});
|
|
42
|
+
test("Renders with correct labels in dropzone mode", () => {
|
|
43
|
+
const { getByText } = render(
|
|
44
|
+
<DxcFileInput label="File input label" helperText="File input helper text" mode="dropzone" />
|
|
45
|
+
);
|
|
46
|
+
expect(getByText("Select")).toBeTruthy();
|
|
47
|
+
expect(getByText("or drop files")).toBeTruthy();
|
|
48
|
+
});
|
|
49
|
+
test("Disabled file input", () => {
|
|
50
|
+
const { getByText, getByRole } = render(
|
|
51
|
+
<DxcFileInput label="File input label" helperText="File input helper text" disabled />
|
|
52
|
+
);
|
|
53
|
+
expect(getByText("Select files")).toBeTruthy();
|
|
54
|
+
const button = getByRole("button");
|
|
55
|
+
expect(button.disabled).toBeTruthy();
|
|
56
|
+
});
|
|
57
|
+
test("Renders file items passed in value when multiple file input", () => {
|
|
58
|
+
const callbackFile = jest.fn();
|
|
59
|
+
const { getByText } = render(
|
|
60
|
+
<DxcFileInput
|
|
61
|
+
label="File input label"
|
|
62
|
+
helperText="File input helper text"
|
|
63
|
+
value={files}
|
|
64
|
+
callbackFile={callbackFile}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
expect(getByText("file1.png")).toBeTruthy();
|
|
68
|
+
expect(getByText("file2.txt")).toBeTruthy();
|
|
69
|
+
expect(getByText("Error message")).toBeTruthy();
|
|
70
|
+
});
|
|
71
|
+
test("Renders file items when single file input", () => {
|
|
72
|
+
const callbackFile = jest.fn();
|
|
73
|
+
const { getByText } = render(
|
|
74
|
+
<DxcFileInput
|
|
75
|
+
label="File input label"
|
|
76
|
+
helperText="File input helper text"
|
|
77
|
+
multiple={false}
|
|
78
|
+
value={files}
|
|
79
|
+
callbackFile={callbackFile}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
expect(getByText("file1.png")).toBeTruthy();
|
|
83
|
+
expect(getByText("file2.txt")).toBeTruthy();
|
|
84
|
+
expect(getByText("Error message")).toBeTruthy();
|
|
85
|
+
});
|
|
86
|
+
test("Add file item when single file input", async () => {
|
|
87
|
+
const newFile = new File(["newFile"], "newFile.pdf", { type: "pdf" });
|
|
88
|
+
const callbackFile = jest.fn();
|
|
89
|
+
const { getByText, getByLabelText } = render(
|
|
90
|
+
<DxcFileInput
|
|
91
|
+
label="File input label"
|
|
92
|
+
helperText="File input helper text"
|
|
93
|
+
value={files}
|
|
94
|
+
callbackFile={callbackFile}
|
|
95
|
+
multiple={false}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
expect(getByText("file1.png")).toBeTruthy();
|
|
99
|
+
expect(getByText("file2.txt")).toBeTruthy();
|
|
100
|
+
expect(getByText("Error message")).toBeTruthy();
|
|
101
|
+
const inputFile = getByLabelText("File input label", { hidden: true });
|
|
102
|
+
fireEvent.change(inputFile, { target: { files: [newFile] } });
|
|
103
|
+
await waitFor(() => {
|
|
104
|
+
expect(callbackFile).toHaveBeenCalledWith([
|
|
105
|
+
{
|
|
106
|
+
error: undefined,
|
|
107
|
+
file: newFile,
|
|
108
|
+
preview: (
|
|
109
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
|
|
110
|
+
<path fill="none" d="M0 0h24v24H0V0z" />
|
|
111
|
+
<path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z" />
|
|
112
|
+
</svg>
|
|
113
|
+
),
|
|
114
|
+
},
|
|
115
|
+
]);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
test("Renders file items and delete one file", async () => {
|
|
119
|
+
const callbackFile = jest.fn();
|
|
120
|
+
const { getByText, getAllByRole } = render(
|
|
121
|
+
<DxcFileInput
|
|
122
|
+
label="File input label"
|
|
123
|
+
helperText="File input helper text"
|
|
124
|
+
value={files}
|
|
125
|
+
callbackFile={callbackFile}
|
|
126
|
+
/>
|
|
127
|
+
);
|
|
128
|
+
expect(getByText("file1.png")).toBeTruthy();
|
|
129
|
+
expect(getByText("file2.txt")).toBeTruthy();
|
|
130
|
+
expect(getByText("Error message")).toBeTruthy();
|
|
131
|
+
const removeBtn = getAllByRole("button")[1];
|
|
132
|
+
userEvent.click(removeBtn);
|
|
133
|
+
await waitFor(() => {
|
|
134
|
+
expect(callbackFile).toHaveBeenCalledWith([{ error: "Error message", file: file2, preview: null }]);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test("CallbackFile is correctly called", async () => {
|
|
139
|
+
const newFile = new File(["newFile"], "newFile.pdf", { type: "pdf" });
|
|
140
|
+
const callbackFile = jest.fn();
|
|
141
|
+
const { getByLabelText } = render(
|
|
142
|
+
<DxcFileInput
|
|
143
|
+
label="File input label"
|
|
144
|
+
helperText="File input helper text"
|
|
145
|
+
value={files}
|
|
146
|
+
callbackFile={callbackFile}
|
|
147
|
+
/>
|
|
148
|
+
);
|
|
149
|
+
const inputFile = getByLabelText("File input label", { hidden: true });
|
|
150
|
+
fireEvent.change(inputFile, { target: { files: [newFile] } });
|
|
151
|
+
await waitFor(() => {
|
|
152
|
+
expect(callbackFile).toHaveBeenCalledWith([
|
|
153
|
+
{ error: null, preview: null, file: file1 },
|
|
154
|
+
{ error: "Error message", preview: null, file: file2 },
|
|
155
|
+
{
|
|
156
|
+
error: undefined,
|
|
157
|
+
file: newFile,
|
|
158
|
+
preview: (
|
|
159
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
|
|
160
|
+
<path fill="none" d="M0 0h24v24H0V0z" />
|
|
161
|
+
<path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z" />
|
|
162
|
+
</svg>
|
|
163
|
+
),
|
|
164
|
+
},
|
|
165
|
+
]);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test("Callback called correctly when a file size does not comply minSize or maxSize", async () => {
|
|
170
|
+
const newFile = new File(["newFile"], "newFile.pdf", { type: "pdf" });
|
|
171
|
+
const callbackFile = jest.fn();
|
|
172
|
+
const { getByLabelText } = render(
|
|
173
|
+
<DxcFileInput
|
|
174
|
+
label="File input label"
|
|
175
|
+
helperText="File input helper text"
|
|
176
|
+
minSize={1000}
|
|
177
|
+
maxSize={20000}
|
|
178
|
+
value={files}
|
|
179
|
+
callbackFile={callbackFile}
|
|
180
|
+
/>
|
|
181
|
+
);
|
|
182
|
+
const inputFile = getByLabelText("File input label", { hidden: true });
|
|
183
|
+
fireEvent.change(inputFile, { target: { files: [newFile] } });
|
|
184
|
+
await waitFor(() => {
|
|
185
|
+
expect(callbackFile).toHaveBeenCalledWith([
|
|
186
|
+
{ error: null, preview: null, file: file1 },
|
|
187
|
+
{ error: "Error message", preview: null, file: file2 },
|
|
188
|
+
{
|
|
189
|
+
error: "File size must be greater than min size.",
|
|
190
|
+
file: newFile,
|
|
191
|
+
preview: (
|
|
192
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
|
|
193
|
+
<path fill="none" d="M0 0h24v24H0V0z" />
|
|
194
|
+
<path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z" />
|
|
195
|
+
</svg>
|
|
196
|
+
),
|
|
197
|
+
},
|
|
198
|
+
]);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
});
|
package/test/Footer.test.js
CHANGED
|
@@ -5,13 +5,8 @@ import icon from "../../app/src/images/linkedin.svg";
|
|
|
5
5
|
|
|
6
6
|
describe("Footer component tests", () => {
|
|
7
7
|
test("Footer renders with default logo", () => {
|
|
8
|
-
const {
|
|
9
|
-
expect(
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test("Footer renders with logo", () => {
|
|
13
|
-
const { getByRole } = render(<DxcFooter logoSrc={icon}></DxcFooter>);
|
|
14
|
-
expect(getByRole("img")).toBeTruthy();
|
|
8
|
+
const { getByTitle } = render(<DxcFooter></DxcFooter>);
|
|
9
|
+
expect(getByTitle("DXC Logo")).toBeTruthy();
|
|
15
10
|
});
|
|
16
11
|
|
|
17
12
|
test("Footer renders with social links", () => {
|
package/test/Header.test.js
CHANGED
|
@@ -5,25 +5,20 @@ import icon from "../../app/src/images/linkedin.svg";
|
|
|
5
5
|
|
|
6
6
|
describe("Header component tests", () => {
|
|
7
7
|
test("Header renders with default logo", () => {
|
|
8
|
-
const {
|
|
9
|
-
expect(
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test("Header renders with logo", () => {
|
|
13
|
-
const { getByRole } = render(<DxcHeader logoSrc={icon}></DxcHeader>);
|
|
14
|
-
expect(getByRole("img")).toBeTruthy();
|
|
8
|
+
const { getByTitle } = render(<DxcHeader></DxcHeader>);
|
|
9
|
+
expect(getByTitle("DXC Logo")).toBeTruthy();
|
|
15
10
|
});
|
|
16
11
|
|
|
17
12
|
test("Call correct function on logo click", () => {
|
|
18
13
|
const onClick = jest.fn();
|
|
19
|
-
const {
|
|
20
|
-
const logo =
|
|
14
|
+
const { getByTitle } = render(<DxcHeader onClick={onClick}></DxcHeader>);
|
|
15
|
+
const logo = getByTitle("DXC Logo");
|
|
21
16
|
fireEvent.click(logo);
|
|
22
17
|
expect(onClick).toHaveBeenCalled();
|
|
23
18
|
});
|
|
24
19
|
|
|
25
20
|
test("Header renders with correct children", () => {
|
|
26
|
-
//We need to force the offsetWidth value
|
|
21
|
+
// We need to force the offsetWidth value
|
|
27
22
|
Object.defineProperty(HTMLElement.prototype, "offsetWidth", { configurable: true, value: 1024 });
|
|
28
23
|
|
|
29
24
|
const { getByText } = render(<DxcHeader content={<p>header-child-text</p>}></DxcHeader>);
|