@dxc-technology/halstack-react 0.0.0-5908eb4 → 0.0.0-5aa300b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BackgroundColorContext.d.ts +10 -0
- package/BackgroundColorContext.js +47 -0
- package/HalstackContext.d.ts +12 -0
- package/HalstackContext.js +294 -0
- package/accordion/Accordion.d.ts +4 -0
- package/accordion/Accordion.js +239 -0
- package/accordion/Accordion.stories.tsx +346 -0
- package/accordion/Accordion.test.js +71 -0
- package/accordion/types.d.ts +69 -0
- package/accordion/types.js +5 -0
- package/accordion-group/AccordionGroup.d.ts +7 -0
- package/accordion-group/AccordionGroup.js +149 -0
- package/accordion-group/AccordionGroup.stories.tsx +251 -0
- package/accordion-group/AccordionGroup.test.js +126 -0
- package/accordion-group/types.d.ts +79 -0
- package/accordion-group/types.js +5 -0
- package/alert/Alert.d.ts +4 -0
- package/alert/Alert.js +293 -0
- package/alert/Alert.stories.tsx +170 -0
- package/alert/Alert.test.js +92 -0
- package/alert/types.d.ts +49 -0
- package/alert/types.js +5 -0
- package/badge/Badge.d.ts +4 -0
- package/badge/Badge.js +61 -0
- package/badge/types.d.ts +5 -0
- package/badge/types.js +5 -0
- package/bleed/Bleed.d.ts +3 -0
- package/bleed/Bleed.js +51 -0
- package/bleed/Bleed.stories.tsx +341 -0
- package/bleed/types.d.ts +37 -0
- package/bleed/types.js +5 -0
- package/box/Box.d.ts +4 -0
- package/box/Box.js +116 -0
- package/box/Box.stories.tsx +132 -0
- package/box/Box.test.js +18 -0
- package/box/types.d.ts +44 -0
- package/box/types.js +5 -0
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +123 -0
- package/bulleted-list/BulletedList.stories.tsx +200 -0
- package/bulleted-list/types.d.ts +11 -0
- package/bulleted-list/types.js +5 -0
- package/button/Button.d.ts +4 -0
- package/button/Button.js +154 -0
- package/button/Button.stories.tsx +334 -0
- package/button/Button.test.js +35 -0
- package/button/types.d.ts +53 -0
- package/button/types.js +5 -0
- package/card/Card.d.ts +4 -0
- package/card/Card.js +161 -0
- package/card/Card.stories.tsx +201 -0
- package/card/Card.test.js +50 -0
- package/card/ice-cream.jpg +0 -0
- package/card/types.d.ts +68 -0
- package/card/types.js +5 -0
- package/checkbox/Checkbox.d.ts +4 -0
- package/checkbox/Checkbox.js +250 -0
- package/checkbox/Checkbox.stories.tsx +208 -0
- package/checkbox/Checkbox.test.js +155 -0
- package/checkbox/types.d.ts +68 -0
- package/checkbox/types.js +5 -0
- package/chip/Chip.d.ts +4 -0
- package/chip/Chip.js +149 -0
- package/chip/Chip.stories.tsx +151 -0
- package/chip/Chip.test.js +56 -0
- package/chip/types.d.ts +45 -0
- package/chip/types.js +5 -0
- package/{dist/common → common}/OpenSans.css +0 -0
- package/{dist/common → common}/fonts/OpenSans-Bold.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-BoldItalic.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-ExtraBold.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-Italic.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-Light.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-LightItalic.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-Regular.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-SemiBold.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
- package/{dist/common → common}/utils.js +0 -0
- package/common/variables.js +1512 -0
- package/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +258 -0
- package/date-input/DateInput.d.ts +4 -0
- package/date-input/DateInput.js +227 -0
- package/date-input/DateInput.stories.tsx +151 -0
- package/date-input/DateInput.test.js +752 -0
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +160 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +115 -0
- package/date-input/types.d.ts +160 -0
- package/date-input/types.js +5 -0
- package/dialog/Dialog.d.ts +4 -0
- package/dialog/Dialog.js +162 -0
- package/dialog/Dialog.stories.tsx +267 -0
- package/dialog/Dialog.test.js +70 -0
- package/dialog/types.d.ts +44 -0
- package/dialog/types.js +5 -0
- package/dropdown/Dropdown.d.ts +4 -0
- package/dropdown/Dropdown.js +389 -0
- package/dropdown/Dropdown.stories.tsx +320 -0
- package/dropdown/Dropdown.test.js +585 -0
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +80 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +92 -0
- package/dropdown/types.d.ts +100 -0
- package/dropdown/types.js +5 -0
- package/file-input/FileInput.d.ts +4 -0
- package/file-input/FileInput.js +551 -0
- package/file-input/FileInput.stories.tsx +535 -0
- package/file-input/FileInput.test.js +498 -0
- package/file-input/FileItem.d.ts +4 -0
- package/file-input/FileItem.js +161 -0
- package/file-input/types.d.ts +129 -0
- package/file-input/types.js +5 -0
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +69 -0
- package/flex/Flex.stories.tsx +103 -0
- package/flex/types.d.ts +32 -0
- package/flex/types.js +5 -0
- package/footer/Footer.d.ts +4 -0
- package/footer/Footer.js +185 -0
- package/footer/Footer.stories.tsx +137 -0
- package/footer/Footer.test.js +109 -0
- package/footer/Icons.d.ts +2 -0
- package/footer/Icons.js +77 -0
- package/footer/types.d.ts +66 -0
- package/footer/types.js +5 -0
- package/header/Header.d.ts +7 -0
- package/header/Header.js +305 -0
- package/header/Header.stories.tsx +172 -0
- package/header/Header.test.js +79 -0
- package/header/Icons.d.ts +2 -0
- package/header/Icons.js +34 -0
- package/header/types.d.ts +48 -0
- package/header/types.js +5 -0
- package/heading/Heading.d.ts +4 -0
- package/{dist/heading → heading}/Heading.js +31 -94
- package/heading/Heading.stories.tsx +54 -0
- package/heading/Heading.test.js +186 -0
- package/heading/types.d.ts +33 -0
- package/heading/types.js +5 -0
- package/inset/Inset.d.ts +3 -0
- package/inset/Inset.js +51 -0
- package/inset/Inset.stories.tsx +229 -0
- package/inset/types.d.ts +37 -0
- package/inset/types.js +5 -0
- package/layout/ApplicationLayout.d.ts +20 -0
- package/layout/ApplicationLayout.js +171 -0
- package/layout/ApplicationLayout.stories.tsx +162 -0
- package/layout/Icons.d.ts +5 -0
- package/layout/Icons.js +66 -0
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +19 -0
- package/layout/types.d.ts +42 -0
- package/layout/types.js +5 -0
- package/link/Link.d.ts +4 -0
- package/link/Link.js +136 -0
- package/link/Link.stories.tsx +193 -0
- package/link/Link.test.js +83 -0
- package/link/types.d.ts +54 -0
- package/link/types.js +5 -0
- package/main.d.ts +44 -0
- package/{dist/main.js → main.js} +132 -106
- package/number-input/NumberInput.d.ts +4 -0
- package/number-input/NumberInput.js +76 -0
- package/number-input/NumberInput.stories.tsx +115 -0
- package/number-input/NumberInput.test.js +542 -0
- package/number-input/NumberInputContext.d.ts +4 -0
- package/{dist/number/NumberContext.js → number-input/NumberInputContext.js} +6 -3
- package/number-input/numberInputContextTypes.d.ts +19 -0
- package/number-input/numberInputContextTypes.js +5 -0
- package/number-input/types.d.ts +124 -0
- package/number-input/types.js +5 -0
- package/package.json +46 -39
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +54 -0
- package/paginator/Paginator.d.ts +4 -0
- package/paginator/Paginator.js +165 -0
- package/paginator/Paginator.stories.tsx +63 -0
- package/paginator/Paginator.test.js +308 -0
- package/paginator/types.d.ts +38 -0
- package/paginator/types.js +5 -0
- package/paragraph/Paragraph.d.ts +6 -0
- package/paragraph/Paragraph.js +38 -0
- package/paragraph/Paragraph.stories.tsx +44 -0
- package/password-input/PasswordInput.d.ts +4 -0
- package/password-input/PasswordInput.js +166 -0
- package/password-input/PasswordInput.stories.tsx +131 -0
- package/password-input/PasswordInput.test.js +181 -0
- package/password-input/types.d.ts +110 -0
- package/password-input/types.js +5 -0
- package/progress-bar/ProgressBar.d.ts +4 -0
- package/progress-bar/ProgressBar.js +176 -0
- package/progress-bar/ProgressBar.stories.jsx +60 -0
- package/progress-bar/ProgressBar.test.js +110 -0
- package/progress-bar/types.d.ts +36 -0
- package/progress-bar/types.js +5 -0
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +117 -0
- package/quick-nav/QuickNav.stories.tsx +342 -0
- package/quick-nav/types.d.ts +21 -0
- package/quick-nav/types.js +5 -0
- package/radio-group/Radio.d.ts +4 -0
- package/radio-group/Radio.js +156 -0
- package/radio-group/RadioGroup.d.ts +4 -0
- package/radio-group/RadioGroup.js +283 -0
- package/radio-group/RadioGroup.stories.tsx +101 -0
- package/radio-group/RadioGroup.test.js +722 -0
- package/radio-group/types.d.ts +114 -0
- package/radio-group/types.js +5 -0
- package/resultsetTable/Icons.d.ts +7 -0
- package/resultsetTable/Icons.js +51 -0
- package/resultsetTable/ResultsetTable.d.ts +4 -0
- package/resultsetTable/ResultsetTable.js +195 -0
- package/resultsetTable/ResultsetTable.stories.tsx +300 -0
- package/resultsetTable/ResultsetTable.test.js +330 -0
- package/resultsetTable/types.d.ts +67 -0
- package/resultsetTable/types.js +5 -0
- package/select/Icons.d.ts +10 -0
- package/select/Icons.js +93 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +198 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +108 -0
- package/select/Select.d.ts +4 -0
- package/select/Select.js +645 -0
- package/select/Select.stories.tsx +683 -0
- package/select/Select.test.js +2233 -0
- package/select/types.d.ts +210 -0
- package/select/types.js +5 -0
- package/sidenav/Sidenav.d.ts +10 -0
- package/sidenav/Sidenav.js +266 -0
- package/sidenav/Sidenav.stories.tsx +189 -0
- package/sidenav/Sidenav.test.js +44 -0
- package/sidenav/types.d.ts +73 -0
- package/sidenav/types.js +5 -0
- package/slider/Slider.d.ts +4 -0
- package/slider/Slider.js +343 -0
- package/slider/Slider.stories.tsx +183 -0
- package/slider/Slider.test.js +250 -0
- package/slider/types.d.ts +86 -0
- package/slider/types.js +5 -0
- package/spinner/Spinner.d.ts +4 -0
- package/spinner/Spinner.js +250 -0
- package/spinner/Spinner.stories.jsx +103 -0
- package/spinner/Spinner.test.js +64 -0
- package/spinner/types.d.ts +32 -0
- package/spinner/types.js +5 -0
- package/switch/Switch.d.ts +4 -0
- package/switch/Switch.js +262 -0
- package/switch/Switch.stories.tsx +138 -0
- package/switch/Switch.test.js +225 -0
- package/switch/types.d.ts +66 -0
- package/switch/types.js +5 -0
- package/table/Table.d.ts +4 -0
- package/{dist/table → table}/Table.js +14 -24
- package/table/Table.stories.jsx +277 -0
- package/table/Table.test.js +26 -0
- package/table/types.d.ts +21 -0
- package/table/types.js +5 -0
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +133 -0
- package/tabs/Tabs.d.ts +4 -0
- package/tabs/Tabs.js +467 -0
- package/tabs/Tabs.stories.tsx +188 -0
- package/tabs/Tabs.test.js +351 -0
- package/tabs/types.d.ts +92 -0
- package/tabs/types.js +5 -0
- package/tabs-nav/NavTabs.d.ts +8 -0
- package/tabs-nav/NavTabs.js +125 -0
- package/tabs-nav/NavTabs.stories.tsx +172 -0
- package/tabs-nav/NavTabs.test.js +82 -0
- package/tabs-nav/Tab.d.ts +4 -0
- package/tabs-nav/Tab.js +128 -0
- package/tabs-nav/types.d.ts +53 -0
- package/tabs-nav/types.js +5 -0
- package/tag/Tag.d.ts +4 -0
- package/tag/Tag.js +183 -0
- package/tag/Tag.stories.tsx +142 -0
- package/tag/Tag.test.js +60 -0
- package/tag/types.d.ts +69 -0
- package/tag/types.js +5 -0
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +60 -0
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +84 -0
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +134 -0
- package/text-input/TextInput.d.ts +4 -0
- package/text-input/TextInput.js +673 -0
- package/text-input/TextInput.stories.tsx +500 -0
- package/text-input/TextInput.test.js +1724 -0
- package/text-input/types.d.ts +197 -0
- package/text-input/types.js +5 -0
- package/textarea/Textarea.d.ts +4 -0
- package/textarea/Textarea.js +277 -0
- package/textarea/Textarea.stories.jsx +157 -0
- package/textarea/Textarea.test.js +437 -0
- package/textarea/types.d.ts +137 -0
- package/textarea/types.js +5 -0
- package/toggle-group/ToggleGroup.d.ts +4 -0
- package/toggle-group/ToggleGroup.js +215 -0
- package/toggle-group/ToggleGroup.stories.tsx +173 -0
- package/toggle-group/ToggleGroup.test.js +156 -0
- package/toggle-group/types.d.ts +105 -0
- package/toggle-group/types.js +5 -0
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +131 -0
- package/typography/Typography.stories.tsx +198 -0
- package/typography/types.d.ts +18 -0
- package/typography/types.js +5 -0
- package/useTheme.d.ts +2 -0
- package/{dist/useTheme.js → useTheme.js} +2 -2
- package/useTranslatedLabels.d.ts +2 -0
- package/useTranslatedLabels.js +20 -0
- package/wizard/Wizard.d.ts +4 -0
- package/wizard/Wizard.js +285 -0
- package/wizard/Wizard.stories.tsx +233 -0
- package/wizard/Wizard.test.js +141 -0
- package/wizard/types.d.ts +65 -0
- package/wizard/types.js +5 -0
- package/README.md +0 -66
- package/babel.config.js +0 -8
- package/dist/BackgroundColorContext.js +0 -46
- package/dist/ThemeContext.js +0 -216
- package/dist/accordion/Accordion.js +0 -346
- package/dist/accordion/Accordion.stories.js +0 -207
- package/dist/accordion/readme.md +0 -96
- package/dist/accordion-group/AccordionGroup.js +0 -188
- package/dist/accordion-group/AccordionGroup.stories.js +0 -207
- package/dist/accordion-group/readme.md +0 -70
- package/dist/alert/Alert.js +0 -388
- 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/badge/Badge.js +0 -63
- package/dist/box/Box.js +0 -164
- package/dist/button/Button.js +0 -232
- package/dist/button/Button.stories.js +0 -224
- package/dist/button/readme.md +0 -93
- package/dist/card/Card.js +0 -254
- package/dist/checkbox/Checkbox.js +0 -294
- package/dist/checkbox/Checkbox.stories.js +0 -144
- package/dist/checkbox/readme.md +0 -116
- package/dist/chip/Chip.js +0 -269
- package/dist/common/RequiredComponent.js +0 -40
- package/dist/common/variables.js +0 -1305
- package/dist/date/Date.js +0 -381
- package/dist/date/Date.stories.js +0 -205
- package/dist/date/readme.md +0 -73
- package/dist/dialog/Dialog.js +0 -235
- package/dist/dialog/Dialog.stories.js +0 -217
- package/dist/dialog/readme.md +0 -32
- package/dist/dropdown/Dropdown.js +0 -493
- 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.js +0 -407
- 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.js +0 -431
- 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.js +0 -672
- 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/ApplicationLayout.js +0 -331
- package/dist/layout/facebook.svg +0 -45
- package/dist/layout/linkedin.svg +0 -50
- package/dist/layout/twitter.svg +0 -53
- package/dist/link/Link.js +0 -241
- package/dist/link/readme.md +0 -51
- package/dist/new-date/NewDate.js +0 -391
- package/dist/new-input-text/NewInputText.js +0 -929
- package/dist/number/Number.js +0 -127
- package/dist/paginator/Paginator.js +0 -283
- 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/Password.js +0 -139
- package/dist/password/styles.css +0 -3
- package/dist/progress-bar/ProgressBar.js +0 -206
- package/dist/progress-bar/ProgressBar.stories.js +0 -280
- package/dist/progress-bar/readme.md +0 -63
- package/dist/radio/Radio.js +0 -209
- package/dist/radio/Radio.stories.js +0 -166
- package/dist/radio/readme.md +0 -70
- package/dist/resultsetTable/ResultsetTable.js +0 -358
- 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.js +0 -563
- package/dist/select/Select.stories.js +0 -235
- package/dist/select/readme.md +0 -72
- package/dist/sidenav/Sidenav.js +0 -183
- package/dist/slider/Slider.js +0 -315
- package/dist/slider/Slider.stories.js +0 -241
- package/dist/slider/readme.md +0 -64
- package/dist/spinner/Spinner.js +0 -214
- package/dist/spinner/Spinner.stories.js +0 -183
- package/dist/spinner/readme.md +0 -65
- package/dist/switch/Switch.js +0 -222
- package/dist/switch/Switch.stories.js +0 -134
- package/dist/switch/readme.md +0 -133
- package/dist/tabs/Tabs.js +0 -343
- 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/tag/Tag.js +0 -280
- package/dist/textarea/Textarea.js +0 -260
- package/dist/toggle/Toggle.js +0 -220
- package/dist/toggle/Toggle.stories.js +0 -297
- package/dist/toggle/readme.md +0 -80
- package/dist/toggle-group/ToggleGroup.js +0 -241
- package/dist/toggle-group/readme.md +0 -82
- package/dist/upload/Upload.js +0 -205
- package/dist/upload/Upload.stories.js +0 -72
- package/dist/upload/buttons-upload/ButtonsUpload.js +0 -135
- 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/DragAndDropArea.js +0 -325
- package/dist/upload/dragAndDropArea/upload_drop.svg +0 -4
- package/dist/upload/dragAndDropArea/upload_file.svg +0 -4
- package/dist/upload/file-upload/FileToUpload.js +0 -184
- 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/files-upload/FilesToUpload.js +0 -123
- package/dist/upload/readme.md +0 -37
- package/dist/upload/transaction/Transaction.js +0 -171
- 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/upload/transactions/Transactions.js +0 -138
- package/dist/wizard/Wizard.js +0 -411
- 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/Accordion.test.js +0 -33
- package/test/AccordionGroup.test.js +0 -125
- package/test/Alert.test.js +0 -53
- package/test/Box.test.js +0 -10
- package/test/Button.test.js +0 -18
- package/test/Card.test.js +0 -30
- package/test/Checkbox.test.js +0 -45
- package/test/Chip.test.js +0 -25
- package/test/Date.test.js +0 -393
- package/test/Dialog.test.js +0 -23
- package/test/Dropdown.test.js +0 -130
- package/test/Footer.test.js +0 -99
- package/test/Header.test.js +0 -39
- package/test/Heading.test.js +0 -35
- package/test/InputText.test.js +0 -240
- package/test/Link.test.js +0 -43
- package/test/NewDate.test.js +0 -189
- package/test/NewInputText.test.js +0 -663
- package/test/Number.test.js +0 -205
- package/test/Paginator.test.js +0 -177
- package/test/Password.test.js +0 -63
- package/test/ProgressBar.test.js +0 -35
- package/test/Radio.test.js +0 -37
- package/test/ResultsetTable.test.js +0 -330
- package/test/Select.test.js +0 -192
- package/test/Sidenav.test.js +0 -45
- package/test/Slider.test.js +0 -82
- package/test/Spinner.test.js +0 -27
- package/test/Switch.test.js +0 -45
- package/test/Table.test.js +0 -36
- package/test/Tabs.test.js +0 -109
- package/test/TabsForSections.test.js +0 -34
- package/test/Tag.test.js +0 -32
- package/test/TextArea.test.js +0 -52
- package/test/ToggleGroup.test.js +0 -81
- package/test/Upload.test.js +0 -60
- package/test/Wizard.test.js +0 -130
- package/test/mocks/pngMock.js +0 -1
- package/test/mocks/svgMock.js +0 -1
|
@@ -1,663 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render, fireEvent, waitForElementToBeRemoved } from "@testing-library/react";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
|
|
5
|
-
import DxcNewInputText from "../src/new-input-text/NewInputText";
|
|
6
|
-
|
|
7
|
-
const countries = [
|
|
8
|
-
"Afghanistan",
|
|
9
|
-
"Albania",
|
|
10
|
-
"Algeria",
|
|
11
|
-
"Andorra",
|
|
12
|
-
"Angola",
|
|
13
|
-
"Antigua and Barbuda",
|
|
14
|
-
"Bahamas",
|
|
15
|
-
"Bahrain",
|
|
16
|
-
"Bangladesh",
|
|
17
|
-
"Barbados",
|
|
18
|
-
"Cabo Verde",
|
|
19
|
-
"Cambodia",
|
|
20
|
-
"Cameroon",
|
|
21
|
-
"Canada",
|
|
22
|
-
"Cayman Islands, The",
|
|
23
|
-
"Central African Republic",
|
|
24
|
-
"Chad",
|
|
25
|
-
"Democratic Republic of the Congo",
|
|
26
|
-
"Dominican Republic",
|
|
27
|
-
"Dominica",
|
|
28
|
-
"Denmark",
|
|
29
|
-
"Djibouti",
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
describe("NewInputText component tests", () => {
|
|
33
|
-
test("Renders with correct label", () => {
|
|
34
|
-
const { getByText } = render(<DxcNewInputText label="Example label" />);
|
|
35
|
-
expect(getByText("Example label")).toBeTruthy();
|
|
36
|
-
});
|
|
37
|
-
test("Renders with correct label and helper text", () => {
|
|
38
|
-
const { getByText } = render(<DxcNewInputText label="Example label" helperText="Example helper text" />);
|
|
39
|
-
expect(getByText("Example label")).toBeTruthy();
|
|
40
|
-
expect(getByText("Example helper text")).toBeTruthy();
|
|
41
|
-
});
|
|
42
|
-
test("Renders with correct label and optional", () => {
|
|
43
|
-
const { getByText } = render(<DxcNewInputText label="Example label" helperText="Example helper text" optional />);
|
|
44
|
-
expect(getByText("Example label")).toBeTruthy();
|
|
45
|
-
expect(getByText("(Optional)")).toBeTruthy();
|
|
46
|
-
expect(getByText("Example helper text")).toBeTruthy();
|
|
47
|
-
});
|
|
48
|
-
test("Renders with correct placeholder", () => {
|
|
49
|
-
const { getByRole } = render(<DxcNewInputText label="Example label" placeholder="Placeholder" />);
|
|
50
|
-
const input = getByRole("textbox");
|
|
51
|
-
expect(input.getAttribute("placeholder")).toBe("Placeholder");
|
|
52
|
-
});
|
|
53
|
-
test("Renders with error message", () => {
|
|
54
|
-
const { getByText } = render(
|
|
55
|
-
<DxcNewInputText label="Error label" placeholder="Placeholder" error="Error message" />
|
|
56
|
-
);
|
|
57
|
-
expect(getByText("Error message")).toBeTruthy();
|
|
58
|
-
});
|
|
59
|
-
test("Input Strict - Pattern constraint", () => {
|
|
60
|
-
const onChange = jest.fn();
|
|
61
|
-
const onBlur = jest.fn();
|
|
62
|
-
const { getByLabelText, getByText, queryByText } = render(
|
|
63
|
-
<DxcNewInputText
|
|
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
|
-
/>
|
|
72
|
-
);
|
|
73
|
-
const input = getByLabelText("Input label");
|
|
74
|
-
userEvent.type(input, "pattern test");
|
|
75
|
-
fireEvent.blur(input);
|
|
76
|
-
expect(getByText("Please match the format requested.")).toBeTruthy();
|
|
77
|
-
userEvent.type(input, "pattern4&");
|
|
78
|
-
fireEvent.blur(input);
|
|
79
|
-
expect(queryByText("Please match the format requested.")).toBeFalsy();
|
|
80
|
-
});
|
|
81
|
-
test("Input Strict - Length constraint", () => {
|
|
82
|
-
const onChange = jest.fn();
|
|
83
|
-
const onBlur = jest.fn();
|
|
84
|
-
const { getByLabelText, getByText, queryByText } = render(
|
|
85
|
-
<DxcNewInputText
|
|
86
|
-
label="Input label"
|
|
87
|
-
placeholder="Placeholder"
|
|
88
|
-
onChange={onChange}
|
|
89
|
-
onBlur={onBlur}
|
|
90
|
-
margin={{ left: "medium", right: "medium" }}
|
|
91
|
-
clearable
|
|
92
|
-
length={{ min: "5", max: "10" }}
|
|
93
|
-
/>
|
|
94
|
-
);
|
|
95
|
-
const input = getByLabelText("Input label");
|
|
96
|
-
userEvent.type(input, "test");
|
|
97
|
-
fireEvent.blur(input);
|
|
98
|
-
expect(getByText("Min length 5, Max length 10.")).toBeTruthy();
|
|
99
|
-
userEvent.type(input, "test ");
|
|
100
|
-
fireEvent.blur(input);
|
|
101
|
-
expect(queryByText(/Min length /)).toBeFalsy();
|
|
102
|
-
});
|
|
103
|
-
test("Input Strict - Pattern and length constraints", () => {
|
|
104
|
-
const onChange = jest.fn();
|
|
105
|
-
const onBlur = jest.fn();
|
|
106
|
-
const { getByLabelText, getByText, queryByText } = render(
|
|
107
|
-
<DxcNewInputText
|
|
108
|
-
label="Input label"
|
|
109
|
-
placeholder="Placeholder"
|
|
110
|
-
onChange={onChange}
|
|
111
|
-
onBlur={onBlur}
|
|
112
|
-
margin={{ left: "medium", right: "medium" }}
|
|
113
|
-
clearable
|
|
114
|
-
pattern='^.*(?=.*[a-zA-Z])(?=.*\d)(?=.*[!&$%&? "]).*$'
|
|
115
|
-
length={{ min: "5", max: "10" }}
|
|
116
|
-
/>
|
|
117
|
-
);
|
|
118
|
-
const input = getByLabelText("Input label");
|
|
119
|
-
userEvent.type(input, "test");
|
|
120
|
-
fireEvent.blur(input);
|
|
121
|
-
expect(getByText("Min length 5, Max length 10.")).toBeTruthy();
|
|
122
|
-
userEvent.type(input, "test ");
|
|
123
|
-
fireEvent.blur(input);
|
|
124
|
-
expect(getByText("Please match the format requested.")).toBeTruthy();
|
|
125
|
-
userEvent.type(input, "test 4");
|
|
126
|
-
fireEvent.blur(input);
|
|
127
|
-
expect(queryByText("Please match the format requested.")).toBeFalsy();
|
|
128
|
-
});
|
|
129
|
-
test("Input Non Strict - Pattern constraint", () => {
|
|
130
|
-
const onChange = jest.fn((value) => {
|
|
131
|
-
expect(value).toBe("t");
|
|
132
|
-
});
|
|
133
|
-
const onBlur = jest.fn(({ value, error }) => {
|
|
134
|
-
expect(value).toBe("t");
|
|
135
|
-
expect(error).toBe("Please match the format requested.");
|
|
136
|
-
});
|
|
137
|
-
const { getByLabelText } = render(
|
|
138
|
-
<DxcNewInputText
|
|
139
|
-
label="Input label"
|
|
140
|
-
placeholder="Placeholder"
|
|
141
|
-
onChange={onChange}
|
|
142
|
-
onBlur={onBlur}
|
|
143
|
-
margin={{ left: "medium", right: "medium" }}
|
|
144
|
-
clearable
|
|
145
|
-
pattern='^.*(?=.*[a-zA-Z])(?=.*\d)(?=.*[!&$%&? "]).*$'
|
|
146
|
-
/>
|
|
147
|
-
);
|
|
148
|
-
const input = getByLabelText("Input label");
|
|
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 { getByLabelText } = 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
|
-
length={{ min: "5", max: "10" }}
|
|
169
|
-
/>
|
|
170
|
-
);
|
|
171
|
-
const input = getByLabelText("Input label");
|
|
172
|
-
userEvent.type(input, "t");
|
|
173
|
-
fireEvent.blur(input);
|
|
174
|
-
});
|
|
175
|
-
test("Input Non Strict - Pattern and length constraints", () => {
|
|
176
|
-
const onChange = jest.fn((value) => {
|
|
177
|
-
expect(value).toBe("t");
|
|
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 { getByLabelText } = 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 = getByLabelText("Input label");
|
|
195
|
-
userEvent.type(input, "t");
|
|
196
|
-
fireEvent.blur(input);
|
|
197
|
-
});
|
|
198
|
-
test("onChange function is called correctly", () => {
|
|
199
|
-
const onChange = jest.fn();
|
|
200
|
-
const { getByRole } = render(<DxcNewInputText label="Input label" onChange={onChange} />);
|
|
201
|
-
const input = getByRole("textbox");
|
|
202
|
-
userEvent.type(input, "onchange event test");
|
|
203
|
-
expect(input.value).toBe("onchange event test");
|
|
204
|
-
expect(onChange).toHaveBeenCalled();
|
|
205
|
-
expect(onChange).toHaveBeenCalledWith("onchange event test");
|
|
206
|
-
});
|
|
207
|
-
test("onBlur function is called correctly", () => {
|
|
208
|
-
const onBlur = jest.fn();
|
|
209
|
-
const onChange = jest.fn();
|
|
210
|
-
const { getByRole } = render(<DxcNewInputText label="Input label" onChange={onChange} onBlur={onBlur} />);
|
|
211
|
-
const input = getByRole("textbox");
|
|
212
|
-
userEvent.type(input, "Test string");
|
|
213
|
-
fireEvent.blur(input);
|
|
214
|
-
expect(onBlur).toHaveBeenCalled();
|
|
215
|
-
expect(onBlur).toHaveBeenCalledWith({ value: "Test string", error: null });
|
|
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 });
|
|
239
|
-
});
|
|
240
|
-
test("Clear action onClick cleans the input", () => {
|
|
241
|
-
const { getByRole } = render(<DxcNewInputText label="Input label" clearable />);
|
|
242
|
-
const input = getByRole("textbox");
|
|
243
|
-
userEvent.type(input, "Test");
|
|
244
|
-
const closeAction = getByRole("button");
|
|
245
|
-
userEvent.click(closeAction);
|
|
246
|
-
expect(input.value).toBe("");
|
|
247
|
-
});
|
|
248
|
-
test("Disabled input (action must be shown but not clickable)", () => {
|
|
249
|
-
const onClick = jest.fn();
|
|
250
|
-
const action = {
|
|
251
|
-
onClick: onClick,
|
|
252
|
-
icon: (
|
|
253
|
-
<svg
|
|
254
|
-
data-testid="image"
|
|
255
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
256
|
-
height="24px"
|
|
257
|
-
viewBox="0 0 24 24"
|
|
258
|
-
width="24px"
|
|
259
|
-
fill="currentColor"
|
|
260
|
-
>
|
|
261
|
-
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
262
|
-
<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" />
|
|
263
|
-
</svg>
|
|
264
|
-
),
|
|
265
|
-
};
|
|
266
|
-
const { getByRole } = render(<DxcNewInputText label="Disabled input label" action={action} disabled />);
|
|
267
|
-
expect(getByRole("textbox").disabled).toBeTruthy();
|
|
268
|
-
userEvent.click(getByRole("button"));
|
|
269
|
-
expect(onClick).not.toHaveBeenCalled();
|
|
270
|
-
});
|
|
271
|
-
test("Disabled input (clear default action should not be displayed, even with text written on the input)", () => {
|
|
272
|
-
const { getByRole, queryByRole } = render(
|
|
273
|
-
<DxcNewInputText label="Disabled input label" value="Sample text" disabled clearable />
|
|
274
|
-
);
|
|
275
|
-
expect(getByRole("textbox").disabled).toBeTruthy();
|
|
276
|
-
expect(queryByRole("button")).toBeFalsy();
|
|
277
|
-
});
|
|
278
|
-
test("Disabled input (suffix and preffix must be displayed)", () => {
|
|
279
|
-
const { getByRole, getByText } = render(
|
|
280
|
-
<DxcNewInputText label="Disabled input label" value="Sample text" prefix="+34" suffix="USD" disabled />
|
|
281
|
-
);
|
|
282
|
-
expect(getByRole("textbox").disabled).toBeTruthy();
|
|
283
|
-
expect(getByText("+34")).toBeTruthy();
|
|
284
|
-
expect(getByText("USD")).toBeTruthy();
|
|
285
|
-
});
|
|
286
|
-
test("Action prop: image displayed and onClick event", () => {
|
|
287
|
-
const onClick = jest.fn();
|
|
288
|
-
const action = {
|
|
289
|
-
onClick: onClick,
|
|
290
|
-
icon: (
|
|
291
|
-
<svg
|
|
292
|
-
data-testid="image"
|
|
293
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
294
|
-
height="24px"
|
|
295
|
-
viewBox="0 0 24 24"
|
|
296
|
-
width="24px"
|
|
297
|
-
fill="currentColor"
|
|
298
|
-
>
|
|
299
|
-
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
300
|
-
<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" />
|
|
301
|
-
</svg>
|
|
302
|
-
),
|
|
303
|
-
};
|
|
304
|
-
const { getByRole, getByTestId } = render(<DxcNewInputText label="Input label" action={action} />);
|
|
305
|
-
expect(getByTestId("image")).toBeTruthy();
|
|
306
|
-
userEvent.click(getByRole("button"));
|
|
307
|
-
expect(onClick).toHaveBeenCalled();
|
|
308
|
-
});
|
|
309
|
-
test("Renders with correct prefix and suffix (text)", () => {
|
|
310
|
-
const { getByText } = render(<DxcNewInputText label="Input label" prefix="+34" suffix="USD" />);
|
|
311
|
-
expect(getByText("+34")).toBeTruthy();
|
|
312
|
-
expect(getByText("USD")).toBeTruthy();
|
|
313
|
-
});
|
|
314
|
-
test("Renders with correct prefix (icon)", () => {
|
|
315
|
-
const { getByTestId } = render(
|
|
316
|
-
<DxcNewInputText
|
|
317
|
-
label="Input label"
|
|
318
|
-
prefix={
|
|
319
|
-
<svg
|
|
320
|
-
data-testid="image"
|
|
321
|
-
version="1.1"
|
|
322
|
-
x="0px"
|
|
323
|
-
y="0px"
|
|
324
|
-
width="24px"
|
|
325
|
-
height="24px"
|
|
326
|
-
viewBox="0 0 24 24"
|
|
327
|
-
enable-background="new 0 0 24 24"
|
|
328
|
-
>
|
|
329
|
-
<g id="Bounding_Box">
|
|
330
|
-
<rect fill="none" width="24" height="24" />
|
|
331
|
-
</g>
|
|
332
|
-
<g id="Master">
|
|
333
|
-
<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" />
|
|
334
|
-
</g>
|
|
335
|
-
</svg>
|
|
336
|
-
}
|
|
337
|
-
/>
|
|
338
|
-
);
|
|
339
|
-
expect(getByTestId("image")).toBeTruthy();
|
|
340
|
-
});
|
|
341
|
-
test("Renders with correct suffix (icon)", () => {
|
|
342
|
-
const { getByTestId } = render(
|
|
343
|
-
<DxcNewInputText
|
|
344
|
-
label="Input label"
|
|
345
|
-
suffix={
|
|
346
|
-
<svg
|
|
347
|
-
data-testid="image"
|
|
348
|
-
version="1.1"
|
|
349
|
-
x="0px"
|
|
350
|
-
y="0px"
|
|
351
|
-
width="24px"
|
|
352
|
-
height="24px"
|
|
353
|
-
viewBox="0 0 24 24"
|
|
354
|
-
enable-background="new 0 0 24 24"
|
|
355
|
-
>
|
|
356
|
-
<g id="Bounding_Box">
|
|
357
|
-
<rect fill="none" width="24" height="24" />
|
|
358
|
-
</g>
|
|
359
|
-
<g id="Master">
|
|
360
|
-
<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" />
|
|
361
|
-
</g>
|
|
362
|
-
</svg>
|
|
363
|
-
}
|
|
364
|
-
/>
|
|
365
|
-
);
|
|
366
|
-
expect(getByTestId("image")).toBeTruthy();
|
|
367
|
-
});
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
describe("NewInputText component synchronous autosuggest tests", () => {
|
|
371
|
-
test("Autosuggest is shown when the input gains focus", async () => {
|
|
372
|
-
const onChange = jest.fn();
|
|
373
|
-
const { getByRole, getByText } = render(
|
|
374
|
-
<DxcNewInputText label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
|
|
375
|
-
);
|
|
376
|
-
const input = getByRole("textbox");
|
|
377
|
-
fireEvent.focus(input);
|
|
378
|
-
expect(getByRole("list")).toBeTruthy();
|
|
379
|
-
expect(getByText("Afghanistan")).toBeTruthy();
|
|
380
|
-
expect(getByText("Albania")).toBeTruthy();
|
|
381
|
-
expect(getByText("Algeria")).toBeTruthy();
|
|
382
|
-
expect(getByText("Andorra")).toBeTruthy();
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
test("Autosuggest is not shown when prop suggestions is an empty array", async () => {
|
|
386
|
-
const onChange = jest.fn();
|
|
387
|
-
const { queryByRole } = render(
|
|
388
|
-
<DxcNewInputText label="Autocomplete Countries" suggestions={[]} onChange={onChange} />
|
|
389
|
-
);
|
|
390
|
-
const input = queryByRole("textbox");
|
|
391
|
-
fireEvent.focus(input);
|
|
392
|
-
expect(queryByRole("list")).toBeFalsy();
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
test("Autosuggest shows 'No results found' message when there are no matches with the user's input", async () => {
|
|
396
|
-
const onChange = jest.fn();
|
|
397
|
-
const { getByRole, getByText } = render(
|
|
398
|
-
<DxcNewInputText label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
|
|
399
|
-
);
|
|
400
|
-
const input = getByRole("textbox");
|
|
401
|
-
fireEvent.focus(input);
|
|
402
|
-
expect(getByRole("list")).toBeTruthy();
|
|
403
|
-
expect(getByText("Afghanistan")).toBeTruthy();
|
|
404
|
-
userEvent.type(input, "x");
|
|
405
|
-
expect(getByRole("list")).toBeTruthy();
|
|
406
|
-
expect(getByText("No results found")).toBeTruthy();
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
test("Autosuggest uncontrolled suggestion selected", async () => {
|
|
410
|
-
const onChange = jest.fn();
|
|
411
|
-
const { getByRole, getByText, queryByRole } = render(
|
|
412
|
-
<DxcNewInputText label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
|
|
413
|
-
);
|
|
414
|
-
fireEvent.focus(getByRole("textbox"));
|
|
415
|
-
userEvent.type(getByRole("textbox"), "Alba");
|
|
416
|
-
expect(onChange).toHaveBeenCalled();
|
|
417
|
-
expect(getByText("Alba")).toBeTruthy();
|
|
418
|
-
expect(getByText("nia")).toBeTruthy();
|
|
419
|
-
fireEvent.mouseDown(getByRole("listitem"));
|
|
420
|
-
fireEvent.mouseUp(getByRole("listitem"));
|
|
421
|
-
expect(getByRole("textbox").value).toBe("Albania");
|
|
422
|
-
expect(queryByRole("list")).toBeFalsy();
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
test("Autosuggest controlled suggestions selected", async () => {
|
|
426
|
-
const onChange = jest.fn();
|
|
427
|
-
const { getByRole, getByText, queryByRole } = render(
|
|
428
|
-
<DxcNewInputText label="Autocomplete Countries" value="Andor" suggestions={countries} onChange={onChange} />
|
|
429
|
-
);
|
|
430
|
-
fireEvent.focus(getByRole("textbox"));
|
|
431
|
-
expect(getByRole("textbox").value).toBe("Andor");
|
|
432
|
-
expect(getByText("Andor")).toBeTruthy();
|
|
433
|
-
expect(getByText("ra")).toBeTruthy();
|
|
434
|
-
fireEvent.mouseDown(getByRole("listitem"));
|
|
435
|
-
fireEvent.mouseUp(getByRole("listitem"));
|
|
436
|
-
expect(onChange).toHaveBeenCalledWith("Andorra");
|
|
437
|
-
expect(queryByRole("list")).toBeFalsy();
|
|
438
|
-
});
|
|
439
|
-
|
|
440
|
-
test("Autosuggest Strict - Pattern constraint", async () => {
|
|
441
|
-
const onChange = jest.fn();
|
|
442
|
-
const { getByRole, getByText, queryByText } = render(
|
|
443
|
-
<DxcNewInputText
|
|
444
|
-
label="Autocomplete Countries"
|
|
445
|
-
value="Andor"
|
|
446
|
-
suggestions={countries}
|
|
447
|
-
onChange={onChange}
|
|
448
|
-
pattern='^.*(?=.*[a-zA-Z])(?=.*\d)(?=.*[!&$%&? "]).*$'
|
|
449
|
-
/>
|
|
450
|
-
);
|
|
451
|
-
const input = getByRole("textbox");
|
|
452
|
-
userEvent.type(input, "Andor");
|
|
453
|
-
expect(getByText("Andor")).toBeTruthy();
|
|
454
|
-
expect(getByText("ra")).toBeTruthy();
|
|
455
|
-
fireEvent.mouseDown(getByRole("listitem"));
|
|
456
|
-
fireEvent.mouseUp(getByRole("listitem"));
|
|
457
|
-
expect(onChange).toHaveBeenCalledWith("Andorra");
|
|
458
|
-
fireEvent.blur(input);
|
|
459
|
-
expect(queryByText("Please match the format requested.")).toBeTruthy();
|
|
460
|
-
});
|
|
461
|
-
|
|
462
|
-
test("Autosuggest Strict - Length constraint", async () => {
|
|
463
|
-
const onChange = jest.fn();
|
|
464
|
-
const { getByRole, getByText, queryByText } = render(
|
|
465
|
-
<DxcNewInputText
|
|
466
|
-
label="Autocomplete Countries"
|
|
467
|
-
value="Cha"
|
|
468
|
-
suggestions={countries}
|
|
469
|
-
onChange={onChange}
|
|
470
|
-
length={{ min: "5", max: "10" }}
|
|
471
|
-
/>
|
|
472
|
-
);
|
|
473
|
-
const input = getByRole("textbox");
|
|
474
|
-
fireEvent.focus(input);
|
|
475
|
-
userEvent.type(input, "d");
|
|
476
|
-
fireEvent.mouseDown(getByRole("listitem"));
|
|
477
|
-
fireEvent.mouseUp(getByRole("listitem"));
|
|
478
|
-
expect(onChange).toHaveBeenCalledWith("Chad");
|
|
479
|
-
fireEvent.blur(input);
|
|
480
|
-
expect(queryByText("Min length 5, Max length 10.")).toBeTruthy();
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
test("Autosuggest keys: arrow down key and select with Enter", async () => {
|
|
484
|
-
Element.prototype.scrollTo = () => {};
|
|
485
|
-
const onChange = jest.fn();
|
|
486
|
-
const { getByRole, queryByRole } = render(
|
|
487
|
-
<DxcNewInputText label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
|
|
488
|
-
);
|
|
489
|
-
fireEvent.focus(getByRole("textbox"));
|
|
490
|
-
fireEvent.keyDown(getByRole("textbox"), { key: "ArrowDown", code: "ArrowDown", keyCode: 40, charCode: 40 });
|
|
491
|
-
fireEvent.keyDown(getByRole("textbox"), { key: "Enter", code: "Enter", keyCode: 13, charCode: 13 });
|
|
492
|
-
expect(getByRole("textbox").value).toBe("Afghanistan");
|
|
493
|
-
expect(queryByRole("list")).toBeFalsy();
|
|
494
|
-
});
|
|
495
|
-
|
|
496
|
-
test("Autosuggest keys: arrow up key and select with Enter", async () => {
|
|
497
|
-
Element.prototype.scrollTo = () => {};
|
|
498
|
-
const onChange = jest.fn();
|
|
499
|
-
const { getByRole, queryByRole } = render(
|
|
500
|
-
<DxcNewInputText label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
|
|
501
|
-
);
|
|
502
|
-
fireEvent.focus(getByRole("textbox"));
|
|
503
|
-
fireEvent.keyDown(getByRole("textbox"), { key: "ArrowUp", code: "ArrowUp", keyCode: 38, charCode: 38 });
|
|
504
|
-
fireEvent.keyDown(getByRole("textbox"), { key: "Enter", code: "Enter", keyCode: 13, charCode: 13 });
|
|
505
|
-
expect(getByRole("textbox").value).toBe("Djibouti");
|
|
506
|
-
expect(queryByRole("list")).toBeFalsy();
|
|
507
|
-
});
|
|
508
|
-
|
|
509
|
-
test("Autosuggest keys: Esc", async () => {
|
|
510
|
-
Element.prototype.scrollTo = () => {};
|
|
511
|
-
const onChange = jest.fn();
|
|
512
|
-
const { getByRole, queryByRole } = render(
|
|
513
|
-
<DxcNewInputText label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
|
|
514
|
-
);
|
|
515
|
-
fireEvent.focus(getByRole("textbox"));
|
|
516
|
-
userEvent.type(getByRole("textbox"), "Bangla");
|
|
517
|
-
expect(getByRole("list")).toBeTruthy();
|
|
518
|
-
fireEvent.keyDown(getByRole("textbox"), { key: "Esc", code: "Esc", keyCode: 27, charCode: 27 });
|
|
519
|
-
expect(getByRole("textbox").value).toBe("");
|
|
520
|
-
expect(queryByRole("list")).toBeFalsy();
|
|
521
|
-
});
|
|
522
|
-
|
|
523
|
-
test("Autosuggest complex key secuence: write, arrow up two times, arrow down and select with Enter", async () => {
|
|
524
|
-
Element.prototype.scrollTo = () => {};
|
|
525
|
-
const onChange = jest.fn();
|
|
526
|
-
const { getByRole, queryByRole } = render(
|
|
527
|
-
<DxcNewInputText label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
|
|
528
|
-
);
|
|
529
|
-
fireEvent.focus(getByRole("textbox"));
|
|
530
|
-
userEvent.type(getByRole("textbox"), "Ba");
|
|
531
|
-
fireEvent.keyDown(getByRole("textbox"), { key: "ArrowUp", code: "ArrowUp", keyCode: 38, charCode: 38 });
|
|
532
|
-
fireEvent.keyDown(getByRole("textbox"), { key: "ArrowUp", code: "ArrowUp", keyCode: 38, charCode: 38 });
|
|
533
|
-
fireEvent.keyDown(getByRole("textbox"), { key: "ArrowDown", code: "ArrowDown", keyCode: 40, charCode: 40 });
|
|
534
|
-
fireEvent.keyDown(getByRole("textbox"), { key: "Enter", code: "Enter", keyCode: 13, charCode: 13 });
|
|
535
|
-
expect(getByRole("textbox").value).toBe("Barbados");
|
|
536
|
-
expect(queryByRole("list")).toBeFalsy();
|
|
537
|
-
fireEvent.keyDown(getByRole("textbox"), { key: "Esc", code: "Esp", keyCode: 27, charCode: 27 });
|
|
538
|
-
expect(getByRole("textbox").value).toBe("");
|
|
539
|
-
expect(queryByRole("list")).toBeFalsy();
|
|
540
|
-
});
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
describe("NewInputText component asynchronous autosuggest tests", () => {
|
|
544
|
-
test("Autosuggest 'Searching...' message is shown", async () => {
|
|
545
|
-
const callbackFunc = jest.fn((newValue) => {
|
|
546
|
-
const result = new Promise((resolve) =>
|
|
547
|
-
setTimeout(() => {
|
|
548
|
-
resolve(
|
|
549
|
-
newValue ? countries.filter((option) => option.toUpperCase().includes(newValue.toUpperCase())) : countries
|
|
550
|
-
);
|
|
551
|
-
}, 1000)
|
|
552
|
-
);
|
|
553
|
-
return result;
|
|
554
|
-
});
|
|
555
|
-
const onChange = jest.fn();
|
|
556
|
-
const { getByRole, getByText } = render(
|
|
557
|
-
<DxcNewInputText label="Autosuggest Countries" suggestions={callbackFunc} onChange={onChange} />
|
|
558
|
-
);
|
|
559
|
-
fireEvent.focus(getByRole("textbox"));
|
|
560
|
-
expect(getByRole("list")).toBeTruthy();
|
|
561
|
-
await waitForElementToBeRemoved(() => getByText("Searching..."));
|
|
562
|
-
expect(getByText("Afghanistan")).toBeTruthy();
|
|
563
|
-
expect(getByText("Albania")).toBeTruthy();
|
|
564
|
-
expect(getByText("Algeria")).toBeTruthy();
|
|
565
|
-
expect(getByText("Andorra")).toBeTruthy();
|
|
566
|
-
fireEvent.focus(getByRole("textbox"));
|
|
567
|
-
userEvent.type(getByRole("textbox"), "Ab");
|
|
568
|
-
await waitForElementToBeRemoved(() => getByText("Searching..."));
|
|
569
|
-
expect(getByText("Cabo Verde")).toBeTruthy();
|
|
570
|
-
fireEvent.keyDown(getByRole("textbox"), { key: "ArrowUp", code: "ArrowUp", keyCode: 38, charCode: 38 });
|
|
571
|
-
fireEvent.keyDown(getByRole("textbox"), { key: "Enter", code: "Enter", keyCode: 13, charCode: 13 });
|
|
572
|
-
expect(getByRole("textbox").value).toBe("Cabo Verde");
|
|
573
|
-
});
|
|
574
|
-
|
|
575
|
-
test("Asynchronous uncontrolled autosuggest test", async () => {
|
|
576
|
-
const callbackFunc = jest.fn((newValue) => {
|
|
577
|
-
const result = new Promise((resolve) =>
|
|
578
|
-
setTimeout(() => {
|
|
579
|
-
resolve(
|
|
580
|
-
newValue ? countries.filter((option) => option.toUpperCase().includes(newValue.toUpperCase())) : countries
|
|
581
|
-
);
|
|
582
|
-
}, 1000)
|
|
583
|
-
);
|
|
584
|
-
return result;
|
|
585
|
-
});
|
|
586
|
-
const onChange = jest.fn();
|
|
587
|
-
const { getByRole, getByText } = render(
|
|
588
|
-
<DxcNewInputText label="Autosuggest Countries" onChange={onChange} suggestions={callbackFunc} />
|
|
589
|
-
);
|
|
590
|
-
fireEvent.focus(getByRole("textbox"));
|
|
591
|
-
userEvent.type(getByRole("textbox"), "Den");
|
|
592
|
-
await waitForElementToBeRemoved(() => getByText("Searching..."));
|
|
593
|
-
expect(getByText("Denmark")).toBeTruthy();
|
|
594
|
-
fireEvent.mouseDown(getByRole("listitem"));
|
|
595
|
-
fireEvent.mouseUp(getByRole("listitem"));
|
|
596
|
-
expect(onChange).toHaveBeenCalledWith("Denmark");
|
|
597
|
-
expect(getByRole("textbox").value).toBe("Denmark");
|
|
598
|
-
});
|
|
599
|
-
|
|
600
|
-
test("Asynchronous controlled autosuggest test", async () => {
|
|
601
|
-
const callbackFunc = jest.fn((newValue) => {
|
|
602
|
-
const result = new Promise((resolve) =>
|
|
603
|
-
setTimeout(() => {
|
|
604
|
-
resolve(
|
|
605
|
-
newValue ? countries.filter((option) => option.toUpperCase().includes(newValue.toUpperCase())) : countries
|
|
606
|
-
);
|
|
607
|
-
}, 1000)
|
|
608
|
-
);
|
|
609
|
-
return result;
|
|
610
|
-
});
|
|
611
|
-
const onChange = jest.fn();
|
|
612
|
-
const { getByRole, getByText, queryByRole } = render(
|
|
613
|
-
<DxcNewInputText label="Autosuggest Countries" value="Denm" onChange={onChange} suggestions={callbackFunc} />
|
|
614
|
-
);
|
|
615
|
-
fireEvent.focus(getByRole("textbox"));
|
|
616
|
-
await waitForElementToBeRemoved(() => getByText("Searching..."));
|
|
617
|
-
expect(getByRole("textbox").value).toBe("Denm");
|
|
618
|
-
expect(getByText("Denmark")).toBeTruthy();
|
|
619
|
-
fireEvent.mouseDown(getByRole("listitem"));
|
|
620
|
-
fireEvent.mouseUp(getByRole("listitem"));
|
|
621
|
-
expect(onChange).toHaveBeenCalledWith("Denmark");
|
|
622
|
-
expect(queryByRole("list")).toBeFalsy();
|
|
623
|
-
});
|
|
624
|
-
|
|
625
|
-
test("Asynchronous autosuggest shows 'No results found' after finishing no matches search", async () => {
|
|
626
|
-
const callbackFunc = jest.fn((newValue) => {
|
|
627
|
-
const result = new Promise((resolve) =>
|
|
628
|
-
setTimeout(() => {
|
|
629
|
-
resolve(
|
|
630
|
-
newValue ? countries.filter((option) => option.toUpperCase().includes(newValue.toUpperCase())) : countries
|
|
631
|
-
);
|
|
632
|
-
}, 1000)
|
|
633
|
-
);
|
|
634
|
-
return result;
|
|
635
|
-
});
|
|
636
|
-
const onChange = jest.fn();
|
|
637
|
-
const { getByRole, getByText } = render(
|
|
638
|
-
<DxcNewInputText label="Autosuggest Countries" onChange={onChange} suggestions={callbackFunc} />
|
|
639
|
-
);
|
|
640
|
-
fireEvent.focus(getByRole("textbox"));
|
|
641
|
-
userEvent.type(getByRole("textbox"), "Example text");
|
|
642
|
-
await waitForElementToBeRemoved(() => getByText("Searching..."));
|
|
643
|
-
expect(getByText("No results found")).toBeTruthy();
|
|
644
|
-
});
|
|
645
|
-
|
|
646
|
-
test("Asynchronous autosuggest request failed, shows 'Error fetching data' message", async () => {
|
|
647
|
-
const errorCallbackFunc = jest.fn(() => {
|
|
648
|
-
const result = new Promise((resolve, reject) =>
|
|
649
|
-
setTimeout(() => {
|
|
650
|
-
reject("err");
|
|
651
|
-
}, 1000)
|
|
652
|
-
);
|
|
653
|
-
return result;
|
|
654
|
-
});
|
|
655
|
-
const onChange = jest.fn();
|
|
656
|
-
const { getByRole, getByText } = render(
|
|
657
|
-
<DxcNewInputText label="Autosuggest Countries" onChange={onChange} suggestions={errorCallbackFunc} />
|
|
658
|
-
);
|
|
659
|
-
fireEvent.focus(getByRole("textbox"));
|
|
660
|
-
await waitForElementToBeRemoved(() => getByText("Searching..."));
|
|
661
|
-
expect(getByText("Error fetching data")).toBeTruthy();
|
|
662
|
-
});
|
|
663
|
-
});
|