@ukic/canary-web-components 2.0.0-canary.8 → 2.0.0-canary.9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/core.cjs.js +1 -1
- package/dist/cjs/date-helpers-c9551119.js +150 -0
- package/dist/cjs/date-helpers-c9551119.js.map +1 -0
- package/dist/cjs/{helpers-b525d45a.js → helpers-7a069459.js} +7 -2
- package/dist/cjs/helpers-7a069459.js.map +1 -0
- package/dist/cjs/{helpers-93c5fc92.js → helpers-f75cf7cf.js} +94 -12
- package/dist/cjs/helpers-f75cf7cf.js.map +1 -0
- package/dist/cjs/ic-accordion.cjs.entry.js +1 -1
- package/dist/cjs/ic-alert.cjs.entry.js +1 -1
- package/dist/cjs/ic-back-to-top.cjs.entry.js +1 -1
- package/dist/cjs/ic-badge.cjs.entry.js +1 -1
- package/dist/cjs/ic-breadcrumb-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-breadcrumb.cjs.entry.js +1 -1
- package/dist/cjs/ic-button_3.cjs.entry.js +8 -2
- package/dist/cjs/ic-button_3.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-card.cjs.entry.js +1 -1
- package/dist/cjs/ic-checkbox-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-checkbox.cjs.entry.js +1 -1
- package/dist/cjs/ic-chip.cjs.entry.js +1 -1
- package/dist/cjs/ic-data-row.cjs.entry.js +1 -1
- package/dist/cjs/ic-date-input.cjs.entry.js +1073 -0
- package/dist/cjs/ic-date-input.cjs.entry.js.map +1 -0
- package/dist/cjs/ic-date-picker.cjs.entry.js +1043 -0
- package/dist/cjs/ic-date-picker.cjs.entry.js.map +1 -0
- package/dist/cjs/ic-dialog.cjs.entry.js +1 -1
- package/dist/cjs/ic-divider.cjs.entry.js +1 -1
- package/dist/cjs/ic-empty-state.cjs.entry.js +1 -1
- package/dist/cjs/ic-footer-link-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-footer-link.cjs.entry.js +1 -1
- package/dist/cjs/ic-footer.cjs.entry.js +1 -1
- package/dist/cjs/ic-hero.cjs.entry.js +1 -1
- package/dist/cjs/ic-horizontal-scroll.cjs.entry.js +1 -1
- package/dist/cjs/ic-input-component-container_4.cjs.entry.js +150 -0
- package/dist/cjs/ic-input-component-container_4.cjs.entry.js.map +1 -0
- package/dist/cjs/ic-link.cjs.entry.js +1 -1
- package/dist/cjs/ic-menu-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-menu-item.cjs.entry.js +1 -1
- package/dist/cjs/ic-menu-with-multi.cjs.entry.js +1 -1
- package/dist/cjs/ic-menu-with-multi.cjs.entry.js.map +1 -1
- package/dist/cjs/{ic-input-component-container_3.cjs.entry.js → ic-menu.cjs.entry.js} +3 -67
- package/dist/cjs/ic-menu.cjs.entry.js.map +1 -0
- package/dist/cjs/ic-navigation-button.cjs.entry.js +1 -1
- package/dist/cjs/ic-navigation-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-navigation-item.cjs.entry.js +1 -1
- package/dist/cjs/ic-navigation-menu.cjs.entry.js +1 -1
- package/dist/cjs/ic-page-header.cjs.entry.js +1 -1
- package/dist/cjs/ic-pagination-bar.cjs.entry.js +1 -1
- package/dist/cjs/ic-pagination_4.cjs.entry.js +1 -1
- package/dist/cjs/ic-popover-menu.cjs.entry.js +1 -1
- package/dist/cjs/ic-radio-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-radio-option.cjs.entry.js +1 -1
- package/dist/cjs/ic-search-bar.cjs.entry.js +1 -1
- package/dist/cjs/ic-select-with-multi.cjs.entry.js +6 -19
- package/dist/cjs/ic-select-with-multi.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-side-navigation.cjs.entry.js +1 -1
- package/dist/cjs/ic-status-tag.cjs.entry.js +1 -1
- package/dist/cjs/ic-step.cjs.entry.js +1 -1
- package/dist/cjs/ic-stepper.cjs.entry.js +1 -1
- package/dist/cjs/ic-switch.cjs.entry.js +1 -1
- package/dist/cjs/ic-tab-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-tab-panel.cjs.entry.js +1 -1
- package/dist/cjs/ic-tab.cjs.entry.js +1 -1
- package/dist/cjs/ic-theme.cjs.entry.js +1 -1
- package/dist/cjs/ic-toast.cjs.entry.js +1 -1
- package/dist/cjs/ic-toggle-button.cjs.entry.js +1 -1
- package/dist/cjs/ic-top-navigation.cjs.entry.js +1 -1
- package/dist/cjs/ic-typography.cjs.entry.js +1 -1
- package/dist/cjs/index-4cf27b16.js +12 -4
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/assets/calendar.svg +3 -0
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/ic-date-input/ic-date-input.css +560 -0
- package/dist/collection/components/ic-date-input/ic-date-input.js +1668 -0
- package/dist/collection/components/ic-date-input/ic-date-input.js.map +1 -0
- package/dist/collection/components/ic-date-input/story-data.js +28 -0
- package/dist/collection/components/ic-date-input/story-data.js.map +1 -0
- package/dist/collection/components/ic-date-input/test/basic/ic-date-input.spec.js +1156 -0
- package/dist/collection/components/ic-date-input/test/basic/ic-date-input.spec.js.map +1 -0
- package/dist/collection/components/ic-date-input/test/helpers/ic-date-input.js +42 -0
- package/dist/collection/components/ic-date-input/test/helpers/ic-date-input.js.map +1 -0
- package/dist/collection/components/ic-date-picker/ic-date-picker.css +878 -0
- package/dist/collection/components/ic-date-picker/ic-date-picker.js +1499 -0
- package/dist/collection/components/ic-date-picker/ic-date-picker.js.map +1 -0
- package/dist/collection/components/ic-date-picker/ic-day-button.js +36 -0
- package/dist/collection/components/ic-date-picker/ic-day-button.js.map +1 -0
- package/dist/collection/components/ic-date-picker/ic-month-picker.js +29 -0
- package/dist/collection/components/ic-date-picker/ic-month-picker.js.map +1 -0
- package/dist/collection/components/ic-date-picker/ic-year-picker.js +39 -0
- package/dist/collection/components/ic-date-picker/ic-year-picker.js.map +1 -0
- package/dist/collection/components/ic-date-picker/story-data.js +143 -0
- package/dist/collection/components/ic-date-picker/story-data.js.map +1 -0
- package/dist/collection/components/ic-date-picker/test/a11y/ic-date-picker.test.a11y.js +13 -0
- package/dist/collection/components/ic-date-picker/test/a11y/ic-date-picker.test.a11y.js.map +1 -0
- package/dist/collection/components/ic-date-picker/test/basic/ic-date-picker-utils.spec.js +207 -0
- package/dist/collection/components/ic-date-picker/test/basic/ic-date-picker-utils.spec.js.map +1 -0
- package/dist/collection/components/ic-date-picker/test/basic/ic-date-picker.spec.js +962 -0
- package/dist/collection/components/ic-date-picker/test/basic/ic-date-picker.spec.js.map +1 -0
- package/dist/collection/components/ic-menu-with-multi/ic-menu.js +2 -2
- package/dist/collection/components/ic-menu-with-multi/ic-menu.js.map +1 -1
- package/dist/collection/components/ic-select-with-multi/ic-select.js +2 -2
- package/dist/collection/components/ic-select-with-multi/ic-select.js.map +1 -1
- package/dist/collection/utils/constants.js +55 -0
- package/dist/collection/utils/constants.js.map +1 -1
- package/dist/collection/utils/date-helpers.js +133 -0
- package/dist/collection/utils/date-helpers.js.map +1 -0
- package/dist/collection/utils/helpers.js +259 -10
- package/dist/collection/utils/helpers.js.map +1 -1
- package/dist/collection/utils/types.js +45 -0
- package/dist/collection/utils/types.js.map +1 -1
- package/dist/components/helpers.js +7 -2
- package/dist/components/helpers.js.map +1 -1
- package/dist/components/helpers2.js +91 -12
- package/dist/components/helpers2.js.map +1 -1
- package/dist/components/ic-button2.js +11 -3
- package/dist/components/ic-button2.js.map +1 -1
- package/dist/components/ic-card.js +1 -1
- package/dist/components/ic-checkbox-group.js +1 -1
- package/dist/components/ic-checkbox.js +1 -1
- package/dist/components/ic-chip.js +1 -1
- package/dist/components/ic-date-input.d.ts +11 -0
- package/dist/components/ic-date-input.js +8 -0
- package/dist/components/ic-date-input.js.map +1 -0
- package/dist/components/ic-date-input2.js +1301 -0
- package/dist/components/ic-date-input2.js.map +1 -0
- package/dist/components/ic-date-picker.d.ts +11 -0
- package/dist/components/ic-date-picker.js +1164 -0
- package/dist/components/ic-date-picker.js.map +1 -0
- package/dist/components/ic-input-component-container2.js +1 -1
- package/dist/components/ic-input-component-container2.js.map +1 -1
- package/dist/components/ic-link2.js +1 -1
- package/dist/components/ic-menu-item2.js +1 -1
- package/dist/components/ic-menu3.js +1 -1
- package/dist/components/ic-menu3.js.map +1 -1
- package/dist/components/ic-navigation-button.js +1 -1
- package/dist/components/ic-pagination-item2.js +1 -1
- package/dist/components/ic-pagination2.js +1 -1
- package/dist/components/ic-radio-group.js +1 -1
- package/dist/components/ic-radio-option.js +1 -1
- package/dist/components/ic-search-bar.js +1 -1
- package/dist/components/ic-select-with-multi.js +1 -14
- package/dist/components/ic-select-with-multi.js.map +1 -1
- package/dist/components/ic-select2.js +1 -1
- package/dist/components/ic-switch.js +1 -1
- package/dist/components/ic-tab.js +1 -1
- package/dist/components/ic-text-field2.js +1 -1
- package/dist/components/ic-toggle-button.js +1 -1
- package/dist/core/core.css +1 -1
- package/dist/core/core.esm.js +1 -1
- package/dist/core/core.esm.js.map +1 -1
- package/dist/core/{p-8b08d8fe.entry.js → p-06ae5bec.entry.js} +2 -2
- package/dist/core/{p-f843da01.entry.js → p-0939ce92.entry.js} +2 -2
- package/dist/core/{p-e0462b23.entry.js → p-16f67397.entry.js} +2 -2
- package/dist/core/{p-db9c03c0.entry.js → p-1832f4b5.entry.js} +2 -2
- package/dist/core/{p-ab09986c.entry.js → p-1b7d426b.entry.js} +2 -2
- package/dist/core/{p-5e0c830b.entry.js → p-1ce75941.entry.js} +2 -2
- package/dist/core/{p-1ca332ca.entry.js → p-2e2e0099.entry.js} +2 -2
- package/dist/core/p-33679c06.entry.js +2 -0
- package/dist/core/p-33679c06.entry.js.map +1 -0
- package/dist/core/{p-4753bac8.entry.js → p-36508aad.entry.js} +2 -2
- package/dist/core/{p-10fb4c46.entry.js → p-3745da83.entry.js} +2 -2
- package/dist/core/{p-3803a5b5.entry.js → p-3f2e77c3.entry.js} +2 -2
- package/dist/core/{p-88d54b72.entry.js → p-47ac6838.entry.js} +2 -2
- package/dist/core/{p-4baa0916.entry.js → p-4f1ffa39.entry.js} +2 -2
- package/dist/core/{p-f7a14c01.entry.js → p-5759d771.entry.js} +2 -2
- package/dist/core/{p-6c3044b6.entry.js → p-5e2e6c3b.entry.js} +2 -2
- package/dist/core/{p-2eac7dcc.entry.js → p-5fe96107.entry.js} +2 -2
- package/dist/core/{p-b82dcc29.entry.js → p-62e22508.entry.js} +2 -2
- package/dist/core/{p-75dac3d1.entry.js → p-6690bc04.entry.js} +2 -2
- package/dist/core/{p-c125b65a.entry.js → p-6c0e2ceb.entry.js} +2 -2
- package/dist/core/{p-a0f8efb2.entry.js → p-76d26018.entry.js} +2 -2
- package/dist/core/{p-4f413fc0.entry.js → p-776671cf.entry.js} +2 -2
- package/dist/core/{p-5ae93c16.entry.js → p-7cecf5d5.entry.js} +2 -2
- package/dist/core/{p-7ef8d616.entry.js → p-85609bdd.entry.js} +2 -2
- package/dist/core/{p-a43c12cd.entry.js → p-86012178.entry.js} +2 -2
- package/dist/core/{p-942282cd.entry.js → p-8a7e7d23.entry.js} +2 -2
- package/dist/core/{p-a50c3b9e.entry.js → p-8c90110a.entry.js} +2 -2
- package/dist/core/{p-045359e1.entry.js → p-8ea47d42.entry.js} +2 -2
- package/dist/core/{p-e834344e.entry.js → p-982a6e88.entry.js} +2 -2
- package/dist/core/{p-d8469ac0.entry.js → p-98448bdb.entry.js} +2 -2
- package/dist/core/{p-6933f8e9.entry.js → p-9d01a7ad.entry.js} +2 -2
- package/dist/core/{p-595be57d.entry.js → p-9d540656.entry.js} +2 -2
- package/dist/core/{p-fde45b29.entry.js → p-9e3178e8.entry.js} +2 -2
- package/dist/core/{p-fde45b29.entry.js.map → p-9e3178e8.entry.js.map} +1 -1
- package/dist/core/{p-81ddc39d.entry.js → p-a0f9b259.entry.js} +2 -2
- package/dist/core/{p-a31031a5.entry.js → p-a42c2f37.entry.js} +2 -2
- package/dist/core/{p-869954a2.entry.js → p-a6447b13.entry.js} +2 -2
- package/dist/core/p-aabab75f.entry.js +2 -0
- package/dist/core/p-aabab75f.entry.js.map +1 -0
- package/dist/core/{p-e3997d60.entry.js → p-ae422058.entry.js} +2 -2
- package/dist/core/{p-a434c3d4.entry.js → p-b306cbc8.entry.js} +2 -2
- package/dist/core/{p-ac4e40a7.entry.js → p-c7590421.entry.js} +2 -2
- package/dist/core/{p-f3c840cd.entry.js → p-c7820c23.entry.js} +2 -2
- package/dist/core/{p-917c5721.entry.js → p-ca8cbd6a.entry.js} +2 -2
- package/dist/core/{p-73be1251.entry.js → p-caf857de.entry.js} +2 -2
- package/dist/core/p-cc7bc438.entry.js +2 -0
- package/dist/core/p-cc7bc438.entry.js.map +1 -0
- package/dist/core/p-cd799087.js +2 -0
- package/dist/core/p-cd799087.js.map +1 -0
- package/dist/core/p-d32692e2.entry.js +2 -0
- package/dist/core/p-d32692e2.entry.js.map +1 -0
- package/dist/core/p-d35c7c18.js +2 -0
- package/dist/core/p-d35c7c18.js.map +1 -0
- package/dist/core/{p-c34848da.entry.js → p-d3856ed3.entry.js} +2 -2
- package/dist/core/{p-204ace96.entry.js → p-d4fdd8c1.entry.js} +2 -2
- package/dist/core/{p-ba86928c.entry.js → p-d5c99ec3.entry.js} +2 -2
- package/dist/core/p-e473bbf8.entry.js +2 -0
- package/dist/core/p-e473bbf8.entry.js.map +1 -0
- package/dist/core/{p-624d4f5f.entry.js → p-e74f1d09.entry.js} +2 -2
- package/dist/core/{p-fc5611e2.entry.js → p-e84b0310.entry.js} +2 -2
- package/dist/core/p-f55ad6ae.entry.js +2 -0
- package/dist/core/{p-f14454b1.entry.js.map → p-f55ad6ae.entry.js.map} +1 -1
- package/dist/core/p-f8cf2978.js +2 -0
- package/dist/core/p-f8cf2978.js.map +1 -0
- package/dist/core/p-f91527a0.entry.js +2 -0
- package/dist/core/p-f91527a0.entry.js.map +1 -0
- package/dist/core/{p-169bfa51.entry.js → p-fbf4e9b7.entry.js} +2 -2
- package/dist/esm/core.js +1 -1
- package/dist/esm/date-helpers-4f432e92.js +136 -0
- package/dist/esm/date-helpers-4f432e92.js.map +1 -0
- package/dist/esm/{helpers-12b4266a.js → helpers-7aa21b0a.js} +7 -2
- package/dist/esm/helpers-7aa21b0a.js.map +1 -0
- package/dist/esm/{helpers-5271897c.js → helpers-f328a7b6.js} +92 -13
- package/dist/esm/helpers-f328a7b6.js.map +1 -0
- package/dist/esm/ic-accordion.entry.js +1 -1
- package/dist/esm/ic-alert.entry.js +1 -1
- package/dist/esm/ic-back-to-top.entry.js +1 -1
- package/dist/esm/ic-badge.entry.js +1 -1
- package/dist/esm/ic-breadcrumb-group.entry.js +1 -1
- package/dist/esm/ic-breadcrumb.entry.js +1 -1
- package/dist/esm/ic-button_3.entry.js +8 -2
- package/dist/esm/ic-button_3.entry.js.map +1 -1
- package/dist/esm/ic-card.entry.js +1 -1
- package/dist/esm/ic-checkbox-group.entry.js +1 -1
- package/dist/esm/ic-checkbox.entry.js +1 -1
- package/dist/esm/ic-chip.entry.js +1 -1
- package/dist/esm/ic-data-row.entry.js +1 -1
- package/dist/esm/ic-date-input.entry.js +1069 -0
- package/dist/esm/ic-date-input.entry.js.map +1 -0
- package/dist/esm/ic-date-picker.entry.js +1039 -0
- package/dist/esm/ic-date-picker.entry.js.map +1 -0
- package/dist/esm/ic-dialog.entry.js +1 -1
- package/dist/esm/ic-divider.entry.js +1 -1
- package/dist/esm/ic-empty-state.entry.js +1 -1
- package/dist/esm/ic-footer-link-group.entry.js +1 -1
- package/dist/esm/ic-footer-link.entry.js +1 -1
- package/dist/esm/ic-footer.entry.js +1 -1
- package/dist/esm/ic-hero.entry.js +1 -1
- package/dist/esm/ic-horizontal-scroll.entry.js +1 -1
- package/dist/esm/ic-input-component-container_4.entry.js +143 -0
- package/dist/esm/ic-input-component-container_4.entry.js.map +1 -0
- package/dist/esm/ic-link.entry.js +1 -1
- package/dist/esm/ic-menu-group.entry.js +1 -1
- package/dist/esm/ic-menu-item.entry.js +1 -1
- package/dist/esm/ic-menu-with-multi.entry.js +1 -1
- package/dist/esm/ic-menu-with-multi.entry.js.map +1 -1
- package/dist/esm/{ic-input-component-container_3.entry.js → ic-menu.entry.js} +5 -67
- package/dist/esm/ic-menu.entry.js.map +1 -0
- package/dist/esm/ic-navigation-button.entry.js +1 -1
- package/dist/esm/ic-navigation-group.entry.js +1 -1
- package/dist/esm/ic-navigation-item.entry.js +1 -1
- package/dist/esm/ic-navigation-menu.entry.js +1 -1
- package/dist/esm/ic-page-header.entry.js +1 -1
- package/dist/esm/ic-pagination-bar.entry.js +1 -1
- package/dist/esm/ic-pagination_4.entry.js +1 -1
- package/dist/esm/ic-popover-menu.entry.js +1 -1
- package/dist/esm/ic-radio-group.entry.js +1 -1
- package/dist/esm/ic-radio-option.entry.js +1 -1
- package/dist/esm/ic-search-bar.entry.js +1 -1
- package/dist/esm/ic-select-with-multi.entry.js +1 -14
- package/dist/esm/ic-select-with-multi.entry.js.map +1 -1
- package/dist/esm/ic-side-navigation.entry.js +1 -1
- package/dist/esm/ic-status-tag.entry.js +1 -1
- package/dist/esm/ic-step.entry.js +1 -1
- package/dist/esm/ic-stepper.entry.js +1 -1
- package/dist/esm/ic-switch.entry.js +1 -1
- package/dist/esm/ic-tab-group.entry.js +1 -1
- package/dist/esm/ic-tab-panel.entry.js +1 -1
- package/dist/esm/ic-tab.entry.js +1 -1
- package/dist/esm/ic-theme.entry.js +1 -1
- package/dist/esm/ic-toast.entry.js +1 -1
- package/dist/esm/ic-toggle-button.entry.js +1 -1
- package/dist/esm/ic-top-navigation.entry.js +1 -1
- package/dist/esm/ic-typography.entry.js +1 -1
- package/dist/esm/index-93509377.js +12 -4
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/ic-date-input/ic-date-input.d.ts +242 -0
- package/dist/types/components/ic-date-input/story-data.d.ts +1 -0
- package/dist/types/components/ic-date-input/test/helpers/ic-date-input.d.ts +23 -0
- package/dist/types/components/ic-date-picker/ic-date-picker.d.ts +251 -0
- package/dist/types/components/ic-date-picker/ic-day-button.d.ts +16 -0
- package/dist/types/components/ic-date-picker/ic-month-picker.d.ts +14 -0
- package/dist/types/components/ic-date-picker/ic-year-picker.d.ts +16 -0
- package/dist/types/components/ic-date-picker/story-data.d.ts +22 -0
- package/dist/types/components/ic-date-picker/test/a11y/ic-date-picker.test.a11y.d.ts +1 -0
- package/dist/types/components/ic-menu-with-multi/ic-menu.d.ts +2 -2
- package/dist/types/components/ic-select-with-multi/ic-select.d.ts +2 -2
- package/dist/types/components.d.ts +439 -4
- package/dist/types/utils/constants.d.ts +37 -0
- package/dist/types/utils/date-helpers.d.ts +22 -0
- package/dist/types/utils/helpers.d.ts +83 -11
- package/dist/types/utils/types.d.ts +92 -1
- package/hydrate/index.js +2653 -253
- package/package.json +3 -3
- package/dist/cjs/helpers-93c5fc92.js.map +0 -1
- package/dist/cjs/helpers-b525d45a.js.map +0 -1
- package/dist/cjs/ic-input-component-container_3.cjs.entry.js.map +0 -1
- package/dist/cjs/ic-input-label_2.cjs.entry.js +0 -86
- package/dist/cjs/ic-input-label_2.cjs.entry.js.map +0 -1
- package/dist/core/p-21150122.entry.js +0 -2
- package/dist/core/p-21150122.entry.js.map +0 -1
- package/dist/core/p-99cad6c2.js +0 -2
- package/dist/core/p-99cad6c2.js.map +0 -1
- package/dist/core/p-9caf19eb.js +0 -2
- package/dist/core/p-9caf19eb.js.map +0 -1
- package/dist/core/p-e0a94f2d.entry.js +0 -2
- package/dist/core/p-e0a94f2d.entry.js.map +0 -1
- package/dist/core/p-f14454b1.entry.js +0 -2
- package/dist/core/p-f6888309.entry.js +0 -2
- package/dist/core/p-f6888309.entry.js.map +0 -1
- package/dist/core/p-f74a8752.entry.js +0 -2
- package/dist/core/p-f74a8752.entry.js.map +0 -1
- package/dist/esm/helpers-12b4266a.js.map +0 -1
- package/dist/esm/helpers-5271897c.js.map +0 -1
- package/dist/esm/ic-input-component-container_3.entry.js.map +0 -1
- package/dist/esm/ic-input-label_2.entry.js +0 -81
- package/dist/esm/ic-input-label_2.entry.js.map +0 -1
- /package/dist/core/{p-8b08d8fe.entry.js.map → p-06ae5bec.entry.js.map} +0 -0
- /package/dist/core/{p-f843da01.entry.js.map → p-0939ce92.entry.js.map} +0 -0
- /package/dist/core/{p-e0462b23.entry.js.map → p-16f67397.entry.js.map} +0 -0
- /package/dist/core/{p-db9c03c0.entry.js.map → p-1832f4b5.entry.js.map} +0 -0
- /package/dist/core/{p-ab09986c.entry.js.map → p-1b7d426b.entry.js.map} +0 -0
- /package/dist/core/{p-5e0c830b.entry.js.map → p-1ce75941.entry.js.map} +0 -0
- /package/dist/core/{p-1ca332ca.entry.js.map → p-2e2e0099.entry.js.map} +0 -0
- /package/dist/core/{p-4753bac8.entry.js.map → p-36508aad.entry.js.map} +0 -0
- /package/dist/core/{p-10fb4c46.entry.js.map → p-3745da83.entry.js.map} +0 -0
- /package/dist/core/{p-3803a5b5.entry.js.map → p-3f2e77c3.entry.js.map} +0 -0
- /package/dist/core/{p-88d54b72.entry.js.map → p-47ac6838.entry.js.map} +0 -0
- /package/dist/core/{p-4baa0916.entry.js.map → p-4f1ffa39.entry.js.map} +0 -0
- /package/dist/core/{p-f7a14c01.entry.js.map → p-5759d771.entry.js.map} +0 -0
- /package/dist/core/{p-6c3044b6.entry.js.map → p-5e2e6c3b.entry.js.map} +0 -0
- /package/dist/core/{p-2eac7dcc.entry.js.map → p-5fe96107.entry.js.map} +0 -0
- /package/dist/core/{p-b82dcc29.entry.js.map → p-62e22508.entry.js.map} +0 -0
- /package/dist/core/{p-75dac3d1.entry.js.map → p-6690bc04.entry.js.map} +0 -0
- /package/dist/core/{p-c125b65a.entry.js.map → p-6c0e2ceb.entry.js.map} +0 -0
- /package/dist/core/{p-a0f8efb2.entry.js.map → p-76d26018.entry.js.map} +0 -0
- /package/dist/core/{p-4f413fc0.entry.js.map → p-776671cf.entry.js.map} +0 -0
- /package/dist/core/{p-5ae93c16.entry.js.map → p-7cecf5d5.entry.js.map} +0 -0
- /package/dist/core/{p-7ef8d616.entry.js.map → p-85609bdd.entry.js.map} +0 -0
- /package/dist/core/{p-a43c12cd.entry.js.map → p-86012178.entry.js.map} +0 -0
- /package/dist/core/{p-942282cd.entry.js.map → p-8a7e7d23.entry.js.map} +0 -0
- /package/dist/core/{p-a50c3b9e.entry.js.map → p-8c90110a.entry.js.map} +0 -0
- /package/dist/core/{p-045359e1.entry.js.map → p-8ea47d42.entry.js.map} +0 -0
- /package/dist/core/{p-e834344e.entry.js.map → p-982a6e88.entry.js.map} +0 -0
- /package/dist/core/{p-d8469ac0.entry.js.map → p-98448bdb.entry.js.map} +0 -0
- /package/dist/core/{p-6933f8e9.entry.js.map → p-9d01a7ad.entry.js.map} +0 -0
- /package/dist/core/{p-595be57d.entry.js.map → p-9d540656.entry.js.map} +0 -0
- /package/dist/core/{p-81ddc39d.entry.js.map → p-a0f9b259.entry.js.map} +0 -0
- /package/dist/core/{p-a31031a5.entry.js.map → p-a42c2f37.entry.js.map} +0 -0
- /package/dist/core/{p-869954a2.entry.js.map → p-a6447b13.entry.js.map} +0 -0
- /package/dist/core/{p-e3997d60.entry.js.map → p-ae422058.entry.js.map} +0 -0
- /package/dist/core/{p-a434c3d4.entry.js.map → p-b306cbc8.entry.js.map} +0 -0
- /package/dist/core/{p-ac4e40a7.entry.js.map → p-c7590421.entry.js.map} +0 -0
- /package/dist/core/{p-f3c840cd.entry.js.map → p-c7820c23.entry.js.map} +0 -0
- /package/dist/core/{p-917c5721.entry.js.map → p-ca8cbd6a.entry.js.map} +0 -0
- /package/dist/core/{p-73be1251.entry.js.map → p-caf857de.entry.js.map} +0 -0
- /package/dist/core/{p-c34848da.entry.js.map → p-d3856ed3.entry.js.map} +0 -0
- /package/dist/core/{p-204ace96.entry.js.map → p-d4fdd8c1.entry.js.map} +0 -0
- /package/dist/core/{p-ba86928c.entry.js.map → p-d5c99ec3.entry.js.map} +0 -0
- /package/dist/core/{p-624d4f5f.entry.js.map → p-e74f1d09.entry.js.map} +0 -0
- /package/dist/core/{p-fc5611e2.entry.js.map → p-e84b0310.entry.js.map} +0 -0
- /package/dist/core/{p-169bfa51.entry.js.map → p-fbf4e9b7.entry.js.map} +0 -0
@@ -0,0 +1,1156 @@
|
|
1
|
+
import { newSpecPage } from "@stencil/core/testing";
|
2
|
+
import { DateInput } from "../../ic-date-input";
|
3
|
+
import { handleEvent, createDateInputEnv, keyboardEvent, } from "../helpers/ic-date-input";
|
4
|
+
import { IcButton } from "@ukic/web-components/dist/components/ic-button";
|
5
|
+
import { IcInputLabel } from "@ukic/web-components/dist/components/ic-input-label";
|
6
|
+
const DATE_1970 = "01/01/1970";
|
7
|
+
const DATE_2000 = "01/01/2000";
|
8
|
+
const ZULU_TIME_2000 = new Date("28 November 2001").toISOString();
|
9
|
+
const HYPHEN = "-";
|
10
|
+
const ARIA_INVALID = "aria-invalid";
|
11
|
+
describe("ic-date-input component", () => {
|
12
|
+
it("should render", async () => {
|
13
|
+
const page = await newSpecPage({
|
14
|
+
components: [DateInput, IcInputLabel],
|
15
|
+
html: `<ic-date-input label="Test label"></ic-date-input>`,
|
16
|
+
});
|
17
|
+
expect(page.root).toMatchSnapshot();
|
18
|
+
});
|
19
|
+
it("should render as required", async () => {
|
20
|
+
const page = await newSpecPage({
|
21
|
+
components: [DateInput, IcInputLabel],
|
22
|
+
html: `<ic-date-input label="Test label" required></ic-date-input>`,
|
23
|
+
});
|
24
|
+
expect(page.root).toMatchSnapshot();
|
25
|
+
});
|
26
|
+
it("should render as disabled", async () => {
|
27
|
+
const page = await newSpecPage({
|
28
|
+
components: [DateInput, IcInputLabel],
|
29
|
+
html: `<ic-date-input label="Test label" disabled></ic-date-input>`,
|
30
|
+
});
|
31
|
+
expect(page.root).toMatchSnapshot();
|
32
|
+
});
|
33
|
+
it("should render small", async () => {
|
34
|
+
const page = await newSpecPage({
|
35
|
+
components: [DateInput, IcInputLabel],
|
36
|
+
html: `<ic-date-input label="Test label" size="small" show-calendar-button="true"></ic-date-input>`,
|
37
|
+
});
|
38
|
+
expect(page.root).toMatchSnapshot();
|
39
|
+
});
|
40
|
+
it("should render large", async () => {
|
41
|
+
const page = await newSpecPage({
|
42
|
+
components: [DateInput, IcInputLabel],
|
43
|
+
html: `<ic-date-input label="Test label" size="large" show-calendar-button="true"></ic-date-input>`,
|
44
|
+
});
|
45
|
+
expect(page.root).toMatchSnapshot();
|
46
|
+
});
|
47
|
+
it("should render with custom helper text", async () => {
|
48
|
+
const page = await newSpecPage({
|
49
|
+
components: [DateInput, IcInputLabel],
|
50
|
+
html: `<ic-date-input label="Test label" helper-text="Test helper text"></ic-date-input>`,
|
51
|
+
});
|
52
|
+
expect(page.root).toMatchSnapshot();
|
53
|
+
});
|
54
|
+
it("should render correctly with MM/DD/YYYY format", async () => {
|
55
|
+
const page = await newSpecPage({
|
56
|
+
components: [DateInput, IcInputLabel],
|
57
|
+
html: `<ic-date-input label="Test label" date-format="MM/DD/YYYY"></ic-date-input>`,
|
58
|
+
});
|
59
|
+
expect(page.root).toMatchSnapshot();
|
60
|
+
});
|
61
|
+
it("should render correctly with YYYY/MM/DD format", async () => {
|
62
|
+
const page = await newSpecPage({
|
63
|
+
components: [DateInput, IcInputLabel],
|
64
|
+
html: `<ic-date-input label="Test label" date-format="YYY/MM/DD"></ic-date-input>`,
|
65
|
+
});
|
66
|
+
expect(page.root).toMatchSnapshot();
|
67
|
+
});
|
68
|
+
it("should render with custom validation status and text", async () => {
|
69
|
+
const page = await newSpecPage({
|
70
|
+
components: [DateInput, IcInputLabel],
|
71
|
+
html: `<ic-date-input label="Test label" validation-status="error" validation-text="Test error text"></ic-date-input>`,
|
72
|
+
});
|
73
|
+
expect(page.root).toMatchSnapshot();
|
74
|
+
});
|
75
|
+
it("should render with open calendar button", async () => {
|
76
|
+
const page = await newSpecPage({
|
77
|
+
components: [DateInput, IcInputLabel, IcButton],
|
78
|
+
html: `<ic-date-input label="Test label" value="21/01/2001" show-calendar-button="true"></ic-date-input>`,
|
79
|
+
});
|
80
|
+
expect(page.root).toMatchSnapshot();
|
81
|
+
});
|
82
|
+
it("should render disabled, with calendar button", async () => {
|
83
|
+
const page = await newSpecPage({
|
84
|
+
components: [DateInput, IcInputLabel, IcButton],
|
85
|
+
html: `<ic-date-input label="Test label" value="21/01/2001" show-calendar-button="true" disabled></ic-date-input>`,
|
86
|
+
});
|
87
|
+
expect(page.root).toMatchSnapshot();
|
88
|
+
});
|
89
|
+
describe("date format conversion", () => {
|
90
|
+
it("should handle single digit day and month", async () => {
|
91
|
+
const page = await newSpecPage({
|
92
|
+
components: [DateInput, IcInputLabel],
|
93
|
+
html: `<ic-date-input label="Test label" value="1/1/2001"></ic-date-input>`,
|
94
|
+
});
|
95
|
+
expect(page.root).toMatchSnapshot();
|
96
|
+
});
|
97
|
+
it("should handle US format value - DD/MM/YYYY date format", async () => {
|
98
|
+
const page = await newSpecPage({
|
99
|
+
components: [DateInput, IcInputLabel],
|
100
|
+
html: `<ic-date-input label="Test label" value="07/26/2001"></ic-date-input>`,
|
101
|
+
});
|
102
|
+
expect(page.root).toMatchSnapshot();
|
103
|
+
});
|
104
|
+
it("should handle US format value - MM/DD/YYYY date format", async () => {
|
105
|
+
const page = await newSpecPage({
|
106
|
+
components: [DateInput, IcInputLabel],
|
107
|
+
html: `<ic-date-input label="Test label" value="07/26/2001" date-format="MM/DD/YYYY"></ic-date-input>`,
|
108
|
+
});
|
109
|
+
expect(page.root).toMatchSnapshot();
|
110
|
+
});
|
111
|
+
it("should handle US format value - YYYY/MM/DD date format", async () => {
|
112
|
+
const page = await newSpecPage({
|
113
|
+
components: [DateInput, IcInputLabel],
|
114
|
+
html: `<ic-date-input label="Test label" value="07/26/2001" date-format="YYYY/MM/DD"></ic-date-input>`,
|
115
|
+
});
|
116
|
+
expect(page.root).toMatchSnapshot();
|
117
|
+
});
|
118
|
+
it("should handle ambiguous value - DD/MM/YYYY date format", async () => {
|
119
|
+
const page = await newSpecPage({
|
120
|
+
components: [DateInput, IcInputLabel],
|
121
|
+
html: `<ic-date-input label="Test label" value="07/10/2001" date-format="DD/MM/YYYY"></ic-date-input>`,
|
122
|
+
});
|
123
|
+
expect(page.root).toMatchSnapshot();
|
124
|
+
});
|
125
|
+
it("should handle ambiguous value - MM/DD/YYYY date format", async () => {
|
126
|
+
const page = await newSpecPage({
|
127
|
+
components: [DateInput, IcInputLabel],
|
128
|
+
html: `<ic-date-input label="Test label" value="07/10/2001" date-format="MM/DD/YYYY"></ic-date-input>`,
|
129
|
+
});
|
130
|
+
expect(page.root).toMatchSnapshot();
|
131
|
+
});
|
132
|
+
it("should handle ambiguous value - YYYY/MM/DD date format", async () => {
|
133
|
+
const page = await newSpecPage({
|
134
|
+
components: [DateInput, IcInputLabel],
|
135
|
+
html: `<ic-date-input label="Test label" value="07/10/2001" date-format="YYYY/MM/DD"></ic-date-input>`,
|
136
|
+
});
|
137
|
+
expect(page.root).toMatchSnapshot();
|
138
|
+
});
|
139
|
+
});
|
140
|
+
describe("handleInput", () => {
|
141
|
+
it("should call moveToNextInput, setinputValue and setPreventInput when day set to 4", async () => {
|
142
|
+
const { dayInput, componentInstance } = await createDateInputEnv();
|
143
|
+
const spyMoveToInput = jest.spyOn(componentInstance, "moveToNextInput");
|
144
|
+
const spySetInputValue = jest.spyOn(componentInstance, "setInputValue");
|
145
|
+
const spySetPreventInput = jest.spyOn(componentInstance, "setPreventInput");
|
146
|
+
componentInstance.preventAutoFormatting = false;
|
147
|
+
dayInput.value = "4";
|
148
|
+
componentInstance.handleInput(handleEvent(dayInput));
|
149
|
+
expect(spyMoveToInput).toHaveBeenCalled();
|
150
|
+
expect(spySetInputValue).toHaveBeenCalled();
|
151
|
+
expect(spySetPreventInput).toHaveBeenCalled();
|
152
|
+
});
|
153
|
+
it("should call setInputValue, setPreventInput and moveToNextInput when preventFormatting is set to true and value has 2 characters", async () => {
|
154
|
+
const { dayInput, componentInstance } = await createDateInputEnv();
|
155
|
+
const spyMoveToInput = jest.spyOn(componentInstance, "moveToNextInput");
|
156
|
+
const spySetInputValue = jest.spyOn(componentInstance, "setInputValue");
|
157
|
+
const spySetPreventInput = jest.spyOn(componentInstance, "setPreventInput");
|
158
|
+
componentInstance.preventAutoFormatting = true;
|
159
|
+
dayInput.value = "11";
|
160
|
+
componentInstance.handleInput(handleEvent(dayInput));
|
161
|
+
expect(spyMoveToInput).toHaveBeenCalled();
|
162
|
+
expect(spySetInputValue).toHaveBeenCalled();
|
163
|
+
expect(spySetPreventInput).toHaveBeenCalled();
|
164
|
+
});
|
165
|
+
it("should call setInputValue when formatting is true and event is Arrow key", async () => {
|
166
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
167
|
+
const spyMoveToInput = jest.spyOn(componentInstance, "moveToNextInput");
|
168
|
+
const spySetInputValue = jest.spyOn(componentInstance, "setInputValue");
|
169
|
+
componentInstance.preventAutoFormatting = true;
|
170
|
+
dayInput.value = "1"; // Line 249
|
171
|
+
componentInstance.handleInput(handleEvent(dayInput));
|
172
|
+
expect(spyMoveToInput).not.toHaveBeenCalled();
|
173
|
+
expect(spySetInputValue).toHaveBeenCalled();
|
174
|
+
});
|
175
|
+
it("should not call moveToNextInput and setinputValue when day set to 1", async () => {
|
176
|
+
const { dayInput, componentInstance } = await createDateInputEnv();
|
177
|
+
const spyMoveToInput = jest.spyOn(componentInstance, "moveToNextInput");
|
178
|
+
const spySetInputValue = jest.spyOn(componentInstance, "setInputValue");
|
179
|
+
const spySetPreventInput = jest.spyOn(componentInstance, "setPreventInput");
|
180
|
+
componentInstance.preventAutoFormatting = false;
|
181
|
+
dayInput.value = "1";
|
182
|
+
componentInstance.handleInput(handleEvent(dayInput));
|
183
|
+
expect(spyMoveToInput).not.toHaveBeenCalled();
|
184
|
+
expect(spySetInputValue).not.toHaveBeenCalled();
|
185
|
+
expect(spySetPreventInput).toHaveBeenCalled();
|
186
|
+
});
|
187
|
+
it("should call moveToNextInput and setinputValue when month set to 2", async () => {
|
188
|
+
const { monthInput, componentInstance } = await createDateInputEnv();
|
189
|
+
const spyMoveToInput = jest.spyOn(componentInstance, "moveToNextInput");
|
190
|
+
const spySetInputValue = jest.spyOn(componentInstance, "setInputValue");
|
191
|
+
componentInstance.preventAutoFormatting = false;
|
192
|
+
monthInput.value = "2";
|
193
|
+
componentInstance.handleInput(handleEvent(monthInput));
|
194
|
+
expect(spyMoveToInput).toHaveBeenCalled();
|
195
|
+
expect(spySetInputValue).toHaveBeenCalled();
|
196
|
+
});
|
197
|
+
it("should not call moveToNextInput and setinputValue when month set to 1", async () => {
|
198
|
+
const { monthInput, componentInstance } = await createDateInputEnv();
|
199
|
+
const spyMoveToInput = jest.spyOn(componentInstance, "moveToNextInput");
|
200
|
+
const spySetInputValue = jest.spyOn(componentInstance, "setInputValue");
|
201
|
+
componentInstance.preventAutoFormatting = false;
|
202
|
+
monthInput.value = "1";
|
203
|
+
componentInstance.handleInput(handleEvent(monthInput));
|
204
|
+
expect(spyMoveToInput).not.toHaveBeenCalled();
|
205
|
+
expect(spySetInputValue).not.toHaveBeenCalled();
|
206
|
+
});
|
207
|
+
it("should set day input value to 01 if 00 is day value", async () => {
|
208
|
+
const { dayInput, componentInstance } = await createDateInputEnv();
|
209
|
+
const spyMoveToInput = jest.spyOn(componentInstance, "moveToNextInput");
|
210
|
+
const spySetInputValue = jest.spyOn(componentInstance, "setInputValue");
|
211
|
+
const spySetPreventInput = jest.spyOn(componentInstance, "setPreventInput");
|
212
|
+
componentInstance.preventAutoFormatting = false;
|
213
|
+
dayInput.value = "00";
|
214
|
+
componentInstance.handleInput(handleEvent(dayInput));
|
215
|
+
expect(dayInput.value).toBe("01");
|
216
|
+
expect(spyMoveToInput).toHaveBeenCalled();
|
217
|
+
expect(spySetInputValue).toHaveBeenCalled();
|
218
|
+
expect(spySetPreventInput).toHaveBeenCalled();
|
219
|
+
});
|
220
|
+
it("should set month input value to 01 if 00 is month value", async () => {
|
221
|
+
const { monthInput, componentInstance } = await createDateInputEnv();
|
222
|
+
const spyMoveToInput = jest.spyOn(componentInstance, "moveToNextInput");
|
223
|
+
const spySetInputValue = jest.spyOn(componentInstance, "setInputValue");
|
224
|
+
const spySetPreventInput = jest.spyOn(componentInstance, "setPreventInput");
|
225
|
+
componentInstance.preventAutoFormatting = false;
|
226
|
+
monthInput.value = "00";
|
227
|
+
componentInstance.handleInput(handleEvent(monthInput));
|
228
|
+
expect(monthInput.value).toBe("01");
|
229
|
+
expect(spyMoveToInput).toHaveBeenCalled();
|
230
|
+
expect(spySetInputValue).toHaveBeenCalled();
|
231
|
+
expect(spySetPreventInput).toHaveBeenCalled();
|
232
|
+
});
|
233
|
+
it("should call moveToNextInput, setinputValue and setPreventInput when year set to 2001", async () => {
|
234
|
+
const { yearInput, componentInstance } = await createDateInputEnv();
|
235
|
+
const spyMoveToInput = jest.spyOn(componentInstance, "moveToNextInput");
|
236
|
+
const spySetInputValue = jest.spyOn(componentInstance, "setInputValue");
|
237
|
+
const spySetPreventInput = jest.spyOn(componentInstance, "setPreventInput");
|
238
|
+
componentInstance.preventAutoFormatting = false;
|
239
|
+
yearInput.value = "2001";
|
240
|
+
componentInstance.handleInput(handleEvent(yearInput));
|
241
|
+
expect(spyMoveToInput).toHaveBeenCalled();
|
242
|
+
expect(spySetInputValue).toHaveBeenCalled();
|
243
|
+
expect(spySetPreventInput).toHaveBeenCalled();
|
244
|
+
});
|
245
|
+
it("should not call moveToNextInput when year set to 20", async () => {
|
246
|
+
const { yearInput, componentInstance } = await createDateInputEnv();
|
247
|
+
const spyMoveToInput = jest.spyOn(componentInstance, "moveToNextInput");
|
248
|
+
componentInstance.preventAutoFormatting = false;
|
249
|
+
yearInput.value = "20";
|
250
|
+
componentInstance.handleInput(handleEvent(yearInput));
|
251
|
+
expect(spyMoveToInput).not.toHaveBeenCalled();
|
252
|
+
});
|
253
|
+
it("should not have fit-to-value class when empty string value is set for day input", async () => {
|
254
|
+
const { dayInput, componentInstance } = await createDateInputEnv();
|
255
|
+
dayInput.value = "";
|
256
|
+
componentInstance.handleInput(handleEvent(dayInput));
|
257
|
+
expect(dayInput.className.includes("fit-to-value")).toBeFalsy();
|
258
|
+
});
|
259
|
+
});
|
260
|
+
describe("handleKeyDown", () => {
|
261
|
+
it("should call moveToNextInput when a hyphen, dash or dot are inputted", async () => {
|
262
|
+
const { componentInstance, component } = await createDateInputEnv();
|
263
|
+
const spyMoveToInput = jest.spyOn(componentInstance, "moveToNextInput");
|
264
|
+
const spyPreventInput = jest.spyOn(componentInstance, "preventInput");
|
265
|
+
// const spyNotifyScreenReader = jest.spyOn(
|
266
|
+
// componentInstance,
|
267
|
+
// "notifyScreenReader"
|
268
|
+
// );
|
269
|
+
const event = new KeyboardEvent("keydown", { key: "/" });
|
270
|
+
component === null || component === void 0 ? void 0 : component.dispatchEvent(event);
|
271
|
+
componentInstance.handleKeyDown(event, false);
|
272
|
+
expect(spyMoveToInput).toHaveBeenCalled();
|
273
|
+
expect(spyPreventInput).toHaveBeenCalled();
|
274
|
+
// expect(spyNotifyScreenReader).toHaveBeenCalled();
|
275
|
+
expect(componentInstance.isDateSetFromKeyboardEvent).toBe(true);
|
276
|
+
});
|
277
|
+
it("should call handleLeftRightArrowKeyPress when ArrowLeft is pressed", async () => {
|
278
|
+
const { componentInstance } = await createDateInputEnv();
|
279
|
+
const spyHandleLeftRightArrowKeyPress = jest.spyOn(componentInstance, "handleLeftRightArrowKeyPress");
|
280
|
+
const keyboardEvent = {
|
281
|
+
preventDefault: () => null,
|
282
|
+
key: "ArrowLeft",
|
283
|
+
};
|
284
|
+
componentInstance.handleKeyDown(keyboardEvent);
|
285
|
+
expect(spyHandleLeftRightArrowKeyPress).toHaveBeenCalled();
|
286
|
+
});
|
287
|
+
it("should set preventAutoFormatting as true and call handleUpDownArrowKeyPress when the ArrowUp key is pressed", async () => {
|
288
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
289
|
+
const keyboardEvent = {
|
290
|
+
key: "ArrowUp",
|
291
|
+
preventDefault: () => null,
|
292
|
+
target: dayInput,
|
293
|
+
};
|
294
|
+
const spyHandleUpDownArrowKeyPress = jest.spyOn(componentInstance, "handleUpDownArrowKeyPress");
|
295
|
+
const spyPreventInput = jest.spyOn(componentInstance, "preventInput");
|
296
|
+
componentInstance.handleKeyDown(keyboardEvent, false);
|
297
|
+
expect(componentInstance.preventAutoFormatting).toBe(true);
|
298
|
+
expect(spyHandleUpDownArrowKeyPress).toHaveBeenCalled();
|
299
|
+
expect(spyPreventInput).toHaveBeenCalled();
|
300
|
+
expect(componentInstance.isDateSetFromKeyboardEvent).toBe(true);
|
301
|
+
});
|
302
|
+
it("should set preventAutoFormatting as true and call handleUpDownArrowKeyPress when the ArrowDown key is pressed", async () => {
|
303
|
+
const { dayInput, componentInstance } = await createDateInputEnv();
|
304
|
+
const keyboardEvent = {
|
305
|
+
key: "ArrowDown",
|
306
|
+
preventDefault: () => null,
|
307
|
+
target: dayInput,
|
308
|
+
};
|
309
|
+
const spyHandleUpDownArrowKeyPress = jest.spyOn(componentInstance, "handleUpDownArrowKeyPress");
|
310
|
+
const spyPreventInput = jest.spyOn(componentInstance, "preventInput");
|
311
|
+
componentInstance.handleKeyDown(keyboardEvent, false);
|
312
|
+
expect(componentInstance.preventAutoFormatting).toBe(true);
|
313
|
+
expect(spyHandleUpDownArrowKeyPress).toHaveBeenCalled();
|
314
|
+
expect(spyPreventInput).toHaveBeenCalled();
|
315
|
+
expect(componentInstance.isDateSetFromKeyboardEvent).toBe(true);
|
316
|
+
});
|
317
|
+
});
|
318
|
+
describe("handleBlur", () => {
|
319
|
+
it("should call autocompleteInput method", async () => {
|
320
|
+
const { dayInput, componentInstance } = await createDateInputEnv();
|
321
|
+
const spyAutocompleteInput = jest.spyOn(componentInstance, "autocompleteInput");
|
322
|
+
componentInstance.handleBlur(handleEvent(dayInput));
|
323
|
+
expect(spyAutocompleteInput).toHaveBeenCalled();
|
324
|
+
});
|
325
|
+
});
|
326
|
+
describe("handleLeftRightArrowKeyPress", () => {
|
327
|
+
it("should call moveToNextInput if ArrowRight is pressed", async () => {
|
328
|
+
const { dayInput, componentInstance } = await createDateInputEnv();
|
329
|
+
const spyMoveToNextInput = jest.spyOn(componentInstance, "moveToNextInput");
|
330
|
+
componentInstance.handleLeftRightArrowKeyPress(dayInput, "arrowright");
|
331
|
+
expect(spyMoveToNextInput).toBeCalled();
|
332
|
+
});
|
333
|
+
it("should call moveToPreviousInput if ArrowLeft is pressed", async () => {
|
334
|
+
const { dayInput, componentInstance } = await createDateInputEnv();
|
335
|
+
const spyMoveToPreviousInput = jest.spyOn(componentInstance, "moveToPreviousInput");
|
336
|
+
componentInstance.handleLeftRightArrowKeyPress(dayInput, "ArrowLeft");
|
337
|
+
expect(spyMoveToPreviousInput).toBeCalled();
|
338
|
+
});
|
339
|
+
});
|
340
|
+
describe("handleUpDownArrowKeyPress", () => {
|
341
|
+
it("should set day value to 1 if day value is 31 and ArrowUp is pressed", async () => {
|
342
|
+
const { dayInput, componentInstance } = await createDateInputEnv();
|
343
|
+
dayInput.value = "31";
|
344
|
+
componentInstance.handleUpDownArrowKeyPress(dayInput, keyboardEvent("ArrowUp"));
|
345
|
+
expect(dayInput.value).toBe("01");
|
346
|
+
});
|
347
|
+
it("should set day value to 13 if day value is 12 and ArrowUp is pressed", async () => {
|
348
|
+
const { dayInput, componentInstance } = await createDateInputEnv();
|
349
|
+
dayInput.value = "12";
|
350
|
+
componentInstance.handleUpDownArrowKeyPress(dayInput, keyboardEvent("ArrowUp"));
|
351
|
+
expect(dayInput.value).toBe("13");
|
352
|
+
});
|
353
|
+
it("should set month value to 1 if month value is 12 and ArrowUp is pressed", async () => {
|
354
|
+
const { monthInput, componentInstance } = await createDateInputEnv();
|
355
|
+
monthInput.value = "12";
|
356
|
+
componentInstance.handleUpDownArrowKeyPress(monthInput, keyboardEvent("ArrowUp"));
|
357
|
+
expect(monthInput.value).toBe("01");
|
358
|
+
});
|
359
|
+
it("should set month value to 11 if month value is 10 and ArrowUp is pressed", async () => {
|
360
|
+
const { monthInput, componentInstance } = await createDateInputEnv();
|
361
|
+
monthInput.value = "10";
|
362
|
+
componentInstance.handleUpDownArrowKeyPress(monthInput, keyboardEvent("ArrowUp"));
|
363
|
+
expect(monthInput.value).toBe("11");
|
364
|
+
});
|
365
|
+
it("should set year value to 0 if year value is 9999 and ArrowUp is pressed", async () => {
|
366
|
+
const { yearInput, componentInstance } = await createDateInputEnv();
|
367
|
+
yearInput.value = "9999";
|
368
|
+
componentInstance.handleUpDownArrowKeyPress(yearInput, keyboardEvent("ArrowUp"));
|
369
|
+
expect(yearInput.value).toBe("00");
|
370
|
+
});
|
371
|
+
it("should set day value to 31 if day value is 1 and ArrowDown is pressed", async () => {
|
372
|
+
const { dayInput, componentInstance } = await createDateInputEnv();
|
373
|
+
dayInput.value = "1";
|
374
|
+
componentInstance.handleUpDownArrowKeyPress(dayInput, keyboardEvent("ArrowDown"));
|
375
|
+
expect(dayInput.value).toBe("31");
|
376
|
+
});
|
377
|
+
it("should set day value to 10 if day value is 11 and ArrowDown is pressed", async () => {
|
378
|
+
const { dayInput, componentInstance } = await createDateInputEnv();
|
379
|
+
dayInput.value = "11";
|
380
|
+
componentInstance.handleUpDownArrowKeyPress(dayInput, keyboardEvent("ArrowDown"));
|
381
|
+
expect(dayInput.value).toBe("10");
|
382
|
+
});
|
383
|
+
it("should set month value to 12 if month value is 1 and ArrowDown is pressed", async () => {
|
384
|
+
const { monthInput, componentInstance } = await createDateInputEnv();
|
385
|
+
monthInput.value = "1";
|
386
|
+
componentInstance.handleUpDownArrowKeyPress(monthInput, keyboardEvent("ArrowDown"));
|
387
|
+
expect(monthInput.value).toBe("12");
|
388
|
+
});
|
389
|
+
it("should set year value to 9999 if year value is 0 and ArrowDown is pressed", async () => {
|
390
|
+
const { yearInput, componentInstance } = await createDateInputEnv();
|
391
|
+
yearInput.value = "0";
|
392
|
+
componentInstance.handleUpDownArrowKeyPress(yearInput, keyboardEvent("ArrowDown"));
|
393
|
+
expect(yearInput.value).toBe("9999");
|
394
|
+
});
|
395
|
+
it("should set day value to 31 if day value is empty and ArrowDown is pressed", async () => {
|
396
|
+
const { dayInput, componentInstance } = await createDateInputEnv();
|
397
|
+
dayInput.value = "";
|
398
|
+
componentInstance.handleUpDownArrowKeyPress(dayInput, keyboardEvent("ArrowDown"));
|
399
|
+
expect(dayInput.value).toBe("31");
|
400
|
+
});
|
401
|
+
it("should set month value to 12 if month value is empty and ArrowDown is pressed", async () => {
|
402
|
+
const { monthInput, componentInstance } = await createDateInputEnv();
|
403
|
+
monthInput.value = "";
|
404
|
+
componentInstance.handleUpDownArrowKeyPress(monthInput, keyboardEvent("ArrowDown"));
|
405
|
+
expect(monthInput.value).toBe("12");
|
406
|
+
});
|
407
|
+
it("should set year value to this year if year value is empty and ArrowDown is pressed", async () => {
|
408
|
+
const { yearInput, componentInstance } = await createDateInputEnv();
|
409
|
+
yearInput.value = "";
|
410
|
+
componentInstance.handleUpDownArrowKeyPress(yearInput, keyboardEvent("ArrowDown"));
|
411
|
+
expect(yearInput.value).toBe(`${new Date().getFullYear()}`);
|
412
|
+
});
|
413
|
+
it("should set year value to this year if year value is empty and ArrowUp is pressed", async () => {
|
414
|
+
const { yearInput, componentInstance } = await createDateInputEnv();
|
415
|
+
yearInput.value = "";
|
416
|
+
componentInstance.handleUpDownArrowKeyPress(yearInput, keyboardEvent("ArrowUp"));
|
417
|
+
expect(yearInput.value).toBe(`${new Date().getFullYear()}`);
|
418
|
+
});
|
419
|
+
});
|
420
|
+
describe("handleDateChange", () => {
|
421
|
+
it("should emit icChange with 1st January 2000 as Date object if day, month and year is set", async () => {
|
422
|
+
const { component, componentInstance } = await createDateInputEnv();
|
423
|
+
const eventSpy = jest.fn();
|
424
|
+
componentInstance.day = "01";
|
425
|
+
componentInstance.month = "01";
|
426
|
+
componentInstance.year = "2000";
|
427
|
+
componentInstance.invalidDateText = "";
|
428
|
+
const date = new Date(+componentInstance.year, +componentInstance.month - 1, +componentInstance.day);
|
429
|
+
componentInstance.selectedDate = date;
|
430
|
+
component === null || component === void 0 ? void 0 : component.addEventListener("icChange", eventSpy);
|
431
|
+
componentInstance.handleDateChange();
|
432
|
+
expect(eventSpy).toBeCalledWith(expect.objectContaining({
|
433
|
+
detail: expect.objectContaining({
|
434
|
+
value: date,
|
435
|
+
}),
|
436
|
+
}));
|
437
|
+
});
|
438
|
+
it("should set value as 1st January 2000 as Date object if day, month and year is set", async () => {
|
439
|
+
const { componentInstance } = await createDateInputEnv();
|
440
|
+
componentInstance.day = "01";
|
441
|
+
componentInstance.month = "01";
|
442
|
+
componentInstance.year = "2000";
|
443
|
+
componentInstance.invalidDateText = "";
|
444
|
+
const date = new Date(+componentInstance.year, +componentInstance.month - 1, +componentInstance.day);
|
445
|
+
componentInstance.selectedDate = date;
|
446
|
+
componentInstance.handleDateChange();
|
447
|
+
expect(componentInstance.value).toBe(date);
|
448
|
+
});
|
449
|
+
it("should set selectedDateInfoEl with 1st January 2000 as string if day, month and year is set", async () => {
|
450
|
+
const { componentInstance } = await createDateInputEnv();
|
451
|
+
componentInstance.day = "01";
|
452
|
+
componentInstance.month = "01";
|
453
|
+
componentInstance.year = "2000";
|
454
|
+
componentInstance.invalidDateText = "";
|
455
|
+
const date = new Date(+componentInstance.year, +componentInstance.month - 1, +componentInstance.day);
|
456
|
+
componentInstance.selectedDate = date;
|
457
|
+
componentInstance.handleDateChange();
|
458
|
+
expect(componentInstance.selectedDateInfoEl.textContent).toBe("Selected date: Saturday, 1 January 2000");
|
459
|
+
});
|
460
|
+
it("should emit icChange with null if day, month or year is not set", async () => {
|
461
|
+
const { component, componentInstance } = await createDateInputEnv();
|
462
|
+
const eventSpy = jest.fn();
|
463
|
+
componentInstance.day = "";
|
464
|
+
componentInstance.month = "";
|
465
|
+
componentInstance.year = "2000";
|
466
|
+
componentInstance.invalidDateText = "";
|
467
|
+
const date = new Date(+componentInstance.year, +componentInstance.month - 1, +componentInstance.day);
|
468
|
+
componentInstance.selectedDate = date;
|
469
|
+
component === null || component === void 0 ? void 0 : component.addEventListener("icChange", eventSpy);
|
470
|
+
componentInstance.handleDateChange();
|
471
|
+
expect(eventSpy).toBeCalledWith(expect.objectContaining({
|
472
|
+
detail: expect.objectContaining({
|
473
|
+
value: null,
|
474
|
+
}),
|
475
|
+
}));
|
476
|
+
});
|
477
|
+
it("should set value to null if day, month or year is not set", async () => {
|
478
|
+
const { componentInstance } = await createDateInputEnv();
|
479
|
+
componentInstance.day = "";
|
480
|
+
componentInstance.month = "";
|
481
|
+
componentInstance.year = "2000";
|
482
|
+
componentInstance.invalidDateText = "";
|
483
|
+
const date = new Date(+componentInstance.year, +componentInstance.month - 1, +componentInstance.day);
|
484
|
+
componentInstance.selectedDate = date;
|
485
|
+
componentInstance.handleDateChange();
|
486
|
+
expect(componentInstance.value).toBe(null);
|
487
|
+
});
|
488
|
+
it("should set selectedDateInfoEl with empty string if day, month and year is set", async () => {
|
489
|
+
const { componentInstance } = await createDateInputEnv();
|
490
|
+
componentInstance.day = "";
|
491
|
+
componentInstance.month = "";
|
492
|
+
componentInstance.year = "2000";
|
493
|
+
componentInstance.invalidDateText = "";
|
494
|
+
const date = new Date(+componentInstance.year, +componentInstance.month - 1, +componentInstance.day);
|
495
|
+
componentInstance.selectedDate = date;
|
496
|
+
componentInstance.handleDateChange();
|
497
|
+
expect(componentInstance.selectedDateInfoEl.textContent).toBe("");
|
498
|
+
});
|
499
|
+
it("should set previousSelectedDate as selectedDate if not previously matching", async () => {
|
500
|
+
const { componentInstance } = await createDateInputEnv();
|
501
|
+
componentInstance.day = "01";
|
502
|
+
componentInstance.month = "01";
|
503
|
+
componentInstance.year = "2000";
|
504
|
+
componentInstance.invalidDateText = "";
|
505
|
+
const date = new Date(+componentInstance.year, +componentInstance.month - 1, +componentInstance.day);
|
506
|
+
componentInstance.selectedDate = date;
|
507
|
+
componentInstance.handleDateChange();
|
508
|
+
expect(componentInstance.previousSelectedDate).toBe(componentInstance.selectedDate);
|
509
|
+
});
|
510
|
+
it("should call updateInputValues if isDateSetFromKeyboardEvent is false", async () => {
|
511
|
+
const { componentInstance } = await createDateInputEnv();
|
512
|
+
componentInstance.day = "01";
|
513
|
+
componentInstance.month = "01";
|
514
|
+
componentInstance.year = "2000";
|
515
|
+
componentInstance.invalidDateText = "";
|
516
|
+
const date = new Date(+componentInstance.year, +componentInstance.month - 1, +componentInstance.day);
|
517
|
+
componentInstance.selectedDate = date;
|
518
|
+
const spyUpdateInputValues = jest.spyOn(componentInstance, "updateInputValues");
|
519
|
+
componentInstance.isDateSetFromKeyboardEvent = false;
|
520
|
+
componentInstance.handleDateChange();
|
521
|
+
expect(spyUpdateInputValues).toBeCalled();
|
522
|
+
});
|
523
|
+
});
|
524
|
+
describe("handlePaste", () => {
|
525
|
+
const clipboardEvent = (value, input) => {
|
526
|
+
return {
|
527
|
+
clipboardData: {
|
528
|
+
getData: () => value,
|
529
|
+
},
|
530
|
+
target: input,
|
531
|
+
preventDefault: () => null,
|
532
|
+
};
|
533
|
+
};
|
534
|
+
it("should set day, month and year input values from paste event with 01/01/2000", async () => {
|
535
|
+
const { componentInstance, dayInput, monthInput, yearInput } = await createDateInputEnv();
|
536
|
+
componentInstance.handlePaste(clipboardEvent(DATE_2000));
|
537
|
+
expect(dayInput.value).toBe("01");
|
538
|
+
expect(monthInput.value).toBe("01");
|
539
|
+
expect(yearInput.value).toBe("2000");
|
540
|
+
});
|
541
|
+
it("should set day, month and year input values from paste event with 01-01-2000", async () => {
|
542
|
+
const { componentInstance, dayInput, monthInput, yearInput } = await createDateInputEnv();
|
543
|
+
componentInstance.handlePaste(clipboardEvent("01-01-2000"));
|
544
|
+
expect(dayInput.value).toBe("01");
|
545
|
+
expect(monthInput.value).toBe("01");
|
546
|
+
expect(yearInput.value).toBe("2000");
|
547
|
+
});
|
548
|
+
it("should set day, month and year input values from paste event with 2000/01/01", async () => {
|
549
|
+
const { componentInstance, dayInput, monthInput, yearInput } =
|
550
|
+
// eslint-disable-next-line sonarjs/no-duplicate-string
|
551
|
+
await createDateInputEnv("YYYY/MM/DD");
|
552
|
+
componentInstance.handlePaste(clipboardEvent("2000/01/01"));
|
553
|
+
expect(dayInput.value).toBe("01");
|
554
|
+
expect(monthInput.value).toBe("01");
|
555
|
+
expect(yearInput.value).toBe("2000");
|
556
|
+
});
|
557
|
+
it(`should set day, month and year input values from paste event with ${ZULU_TIME_2000}`, async () => {
|
558
|
+
const { componentInstance, dayInput, monthInput, yearInput } = await createDateInputEnv("YYYY/MM/DD");
|
559
|
+
componentInstance.handlePaste(clipboardEvent(ZULU_TIME_2000)); // 2001-11-28T00:00:00.000Z
|
560
|
+
expect(dayInput.value).toBe("28");
|
561
|
+
expect(monthInput.value).toBe("11");
|
562
|
+
expect(yearInput.value).toBe("2001");
|
563
|
+
});
|
564
|
+
it("should call setInputValue if date valid", async () => {
|
565
|
+
const { componentInstance } = await createDateInputEnv();
|
566
|
+
const spySetInputValue = jest.spyOn(componentInstance, "setInputValue");
|
567
|
+
componentInstance.handlePaste(clipboardEvent(DATE_2000));
|
568
|
+
expect(spySetInputValue).toBeCalled();
|
569
|
+
});
|
570
|
+
it("should not call setInputValue if date invalid", async () => {
|
571
|
+
const { componentInstance } = await createDateInputEnv();
|
572
|
+
const spySetInputValue = jest.spyOn(componentInstance, "setInputValue");
|
573
|
+
componentInstance.handlePaste(clipboardEvent("01:01:2000"));
|
574
|
+
expect(spySetInputValue).not.toBeCalled();
|
575
|
+
});
|
576
|
+
it("should call checkSingleCopiedValueIsValid if copied value is 1", async () => {
|
577
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
578
|
+
const spyCheckSingleCopiedValueIsValid = jest.spyOn(componentInstance, "checkSingleCopiedValueIsValid");
|
579
|
+
componentInstance.handlePaste(clipboardEvent("1", dayInput));
|
580
|
+
expect(spyCheckSingleCopiedValueIsValid).toBeCalled();
|
581
|
+
});
|
582
|
+
it("should call checkSingleCopiedValueIsValid if copied value is 31", async () => {
|
583
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
584
|
+
const spyCheckSingleCopiedValueIsValid = jest.spyOn(componentInstance, "checkSingleCopiedValueIsValid");
|
585
|
+
componentInstance.handlePaste(clipboardEvent("31", dayInput));
|
586
|
+
expect(spyCheckSingleCopiedValueIsValid).toBeCalled();
|
587
|
+
});
|
588
|
+
it("should call checkSingleCopiedValueIsValid if copied value is 2001", async () => {
|
589
|
+
const { componentInstance, yearInput } = await createDateInputEnv();
|
590
|
+
const spyCheckSingleCopiedValueIsValid = jest.spyOn(componentInstance, "checkSingleCopiedValueIsValid");
|
591
|
+
componentInstance.handlePaste(clipboardEvent("2001", yearInput));
|
592
|
+
expect(spyCheckSingleCopiedValueIsValid).toBeCalled();
|
593
|
+
});
|
594
|
+
it("should not call checkSingleCopiedValueIsValid if copied value is :1", async () => {
|
595
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
596
|
+
const spyCheckSingleCopiedValueIsValid = jest.spyOn(componentInstance, "checkSingleCopiedValueIsValid");
|
597
|
+
componentInstance.handlePaste(clipboardEvent(":1", dayInput));
|
598
|
+
expect(spyCheckSingleCopiedValueIsValid).not.toBeCalled();
|
599
|
+
});
|
600
|
+
it("should not call checkSingleCopiedValueIsValid if copied value is :14", async () => {
|
601
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
602
|
+
const spyCheckSingleCopiedValueIsValid = jest.spyOn(componentInstance, "checkSingleCopiedValueIsValid");
|
603
|
+
componentInstance.handlePaste(clipboardEvent(":14", dayInput));
|
604
|
+
expect(spyCheckSingleCopiedValueIsValid).not.toBeCalled();
|
605
|
+
});
|
606
|
+
it("should not call checkSingleCopiedValueIsValid if copied value is -39", async () => {
|
607
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
608
|
+
const spyCheckSingleCopiedValueIsValid = jest.spyOn(componentInstance, "checkSingleCopiedValueIsValid");
|
609
|
+
componentInstance.handlePaste(clipboardEvent("-39", dayInput));
|
610
|
+
expect(spyCheckSingleCopiedValueIsValid).not.toBeCalled();
|
611
|
+
});
|
612
|
+
it("should not call checkSingleCopiedValueIsValid if copied value is 5 digits", async () => {
|
613
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
614
|
+
const spyCheckSingleCopiedValueIsValid = jest.spyOn(componentInstance, "checkSingleCopiedValueIsValid");
|
615
|
+
componentInstance.handlePaste(clipboardEvent("12345", dayInput));
|
616
|
+
expect(spyCheckSingleCopiedValueIsValid).not.toBeCalled();
|
617
|
+
});
|
618
|
+
it("should update invalidText and set validationStatus if invalid copied single value", async () => {
|
619
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
620
|
+
componentInstance.handlePaste(clipboardEvent("-1", dayInput));
|
621
|
+
expect(componentInstance.invalidDateText).toBe("Please paste a valid day");
|
622
|
+
expect(componentInstance.validationStatus).toBe("error");
|
623
|
+
});
|
624
|
+
});
|
625
|
+
describe("setValidationMessage", () => {
|
626
|
+
it("should set invalidDateText if date (day) is not valid", async () => {
|
627
|
+
const { componentInstance } = await createDateInputEnv();
|
628
|
+
componentInstance.day = "32";
|
629
|
+
componentInstance.month = "1";
|
630
|
+
componentInstance.year = "2000";
|
631
|
+
componentInstance.setValidationMessage();
|
632
|
+
expect(componentInstance.invalidDateText).toBe("Please enter a valid date.");
|
633
|
+
});
|
634
|
+
it("should set invalidDateText if date (month) is not valid", async () => {
|
635
|
+
const { componentInstance } = await createDateInputEnv();
|
636
|
+
componentInstance.day = "1";
|
637
|
+
componentInstance.month = "13";
|
638
|
+
componentInstance.year = "2000";
|
639
|
+
componentInstance.setValidationMessage();
|
640
|
+
expect(componentInstance.invalidDateText).toBe("Please enter a valid date.");
|
641
|
+
});
|
642
|
+
it("should set invalidDateText as empty string if date is not complete", async () => {
|
643
|
+
const { componentInstance } = await createDateInputEnv();
|
644
|
+
componentInstance.day = "";
|
645
|
+
componentInstance.month = "1";
|
646
|
+
componentInstance.year = "2000";
|
647
|
+
componentInstance.setValidationMessage();
|
648
|
+
expect(componentInstance.invalidDateText).toBe("");
|
649
|
+
});
|
650
|
+
it("should set invalidDateText to disablePastMessage if date is in past", async () => {
|
651
|
+
const { component, componentInstance } = await createDateInputEnv();
|
652
|
+
component.disablePast = true;
|
653
|
+
componentInstance.day = "10";
|
654
|
+
componentInstance.month = "8";
|
655
|
+
componentInstance.year = "2022";
|
656
|
+
componentInstance.setValidationMessage();
|
657
|
+
expect(componentInstance.invalidDateText).toBe(componentInstance.disablePastMessage);
|
658
|
+
});
|
659
|
+
it("should set invalidDateText to disableFutureMessage if date is in future", async () => {
|
660
|
+
const { component, componentInstance } = await createDateInputEnv();
|
661
|
+
component.disableFuture = true;
|
662
|
+
componentInstance.day = "31";
|
663
|
+
componentInstance.month = "8";
|
664
|
+
componentInstance.year = "2024";
|
665
|
+
componentInstance.setValidationMessage();
|
666
|
+
expect(componentInstance.invalidDateText).toBe(componentInstance.disableFutureMessage);
|
667
|
+
});
|
668
|
+
it("should set invalidDateText empty string if date valid", async () => {
|
669
|
+
const { component, componentInstance } = await createDateInputEnv();
|
670
|
+
component.disableFuture = true;
|
671
|
+
componentInstance.day = "1";
|
672
|
+
componentInstance.month = "1";
|
673
|
+
componentInstance.year = "2000";
|
674
|
+
componentInstance.setValidationMessage();
|
675
|
+
expect(componentInstance.invalidDateText).toBe("");
|
676
|
+
});
|
677
|
+
it("should set invalidDateText to min message if date is before min date", async () => {
|
678
|
+
const { component, componentInstance } = await createDateInputEnv();
|
679
|
+
component.min = "10-07-2023";
|
680
|
+
componentInstance.day = "1";
|
681
|
+
componentInstance.month = "1";
|
682
|
+
componentInstance.year = "2023";
|
683
|
+
componentInstance.setValidationMessage();
|
684
|
+
expect(componentInstance.invalidDateText).toBe("Please enter a date after 10/07/2023.");
|
685
|
+
component.dateFormat = "MM/DD/YYYY";
|
686
|
+
componentInstance.setValidationMessage();
|
687
|
+
expect(componentInstance.invalidDateText).toBe("Please enter a date after 07/10/2023.");
|
688
|
+
component.dateFormat = "YYYY/MM/DD";
|
689
|
+
componentInstance.setValidationMessage();
|
690
|
+
expect(componentInstance.invalidDateText).toBe("Please enter a date after 2023/07/10.");
|
691
|
+
});
|
692
|
+
it("should set invalidDateText to disablePastMessage if both dateUntilNow and min prop have been set", async () => {
|
693
|
+
const { component, componentInstance } = await createDateInputEnv();
|
694
|
+
component.disablePast = true;
|
695
|
+
component.min = "30-07-2024";
|
696
|
+
componentInstance.day = "1";
|
697
|
+
componentInstance.month = "1";
|
698
|
+
componentInstance.year = "2000";
|
699
|
+
componentInstance.setValidationMessage();
|
700
|
+
expect(componentInstance.invalidDateText).toBe(componentInstance.disablePastMessage);
|
701
|
+
});
|
702
|
+
it("should set invalidDateText to max message if date is after max date", async () => {
|
703
|
+
const { component, componentInstance } = await createDateInputEnv();
|
704
|
+
component.max = "10-07-2023";
|
705
|
+
componentInstance.day = "1";
|
706
|
+
componentInstance.month = "8";
|
707
|
+
componentInstance.year = "2023";
|
708
|
+
componentInstance.setValidationMessage();
|
709
|
+
expect(componentInstance.invalidDateText).toBe("Please enter a date before 10/07/2023.");
|
710
|
+
component.dateFormat = "MM/DD/YYYY";
|
711
|
+
componentInstance.setValidationMessage();
|
712
|
+
expect(componentInstance.invalidDateText).toBe("Please enter a date before 07/10/2023.");
|
713
|
+
component.dateFormat = "YYYY/MM/DD";
|
714
|
+
componentInstance.setValidationMessage();
|
715
|
+
expect(componentInstance.invalidDateText).toBe("Please enter a date before 2023/07/10.");
|
716
|
+
});
|
717
|
+
it("should set invalidDateText to disableFutureMessage if both dateFromNow and max prop have been set", async () => {
|
718
|
+
const { component, componentInstance } = await createDateInputEnv();
|
719
|
+
component.disableFuture = true;
|
720
|
+
component.max = "30-07-2023";
|
721
|
+
componentInstance.day = "1";
|
722
|
+
componentInstance.month = "8";
|
723
|
+
componentInstance.year = "2025";
|
724
|
+
componentInstance.setValidationMessage();
|
725
|
+
expect(componentInstance.invalidDateText).toBe(componentInstance.disableFutureMessage);
|
726
|
+
});
|
727
|
+
it("should set invalidDateText to disableDays message if date is on a disabled weekday", async () => {
|
728
|
+
const { component, componentInstance } = await createDateInputEnv();
|
729
|
+
component.disableDays = [0, 1];
|
730
|
+
componentInstance.day = "16";
|
731
|
+
componentInstance.month = "7";
|
732
|
+
componentInstance.year = "2023";
|
733
|
+
componentInstance.setValidationMessage();
|
734
|
+
expect(componentInstance.invalidDateText).toBe(componentInstance.disableDaysMessage);
|
735
|
+
});
|
736
|
+
});
|
737
|
+
describe("setDate", () => {
|
738
|
+
it("should set a date in Date format and call setValidationMessage", async () => {
|
739
|
+
const { componentInstance } = await createDateInputEnv();
|
740
|
+
const spySetValidationMessage = jest.spyOn(componentInstance, "setValidationMessage");
|
741
|
+
componentInstance.setDate(new Date(500000000000));
|
742
|
+
expect(spySetValidationMessage).toHaveBeenCalled();
|
743
|
+
});
|
744
|
+
it("should set a date in string format and call setValidationMessage", async () => {
|
745
|
+
const { componentInstance } = await createDateInputEnv();
|
746
|
+
const spySetValidationMessage = jest.spyOn(componentInstance, "setValidationMessage");
|
747
|
+
componentInstance.setDate(DATE_1970);
|
748
|
+
expect(componentInstance.year).toMatch("1970");
|
749
|
+
expect(spySetValidationMessage).toHaveBeenCalled();
|
750
|
+
});
|
751
|
+
it("should set the Zulu ISOString into the correct date variables", async () => {
|
752
|
+
const { componentInstance } = await createDateInputEnv();
|
753
|
+
componentInstance.setDate(ZULU_TIME_2000); // 2001-11-28T00:00:00.000Z
|
754
|
+
expect(componentInstance.day).toMatch("28");
|
755
|
+
expect(componentInstance.month).toMatch("11");
|
756
|
+
expect(componentInstance.year).toMatch("2001");
|
757
|
+
});
|
758
|
+
it("should set inputs to null if date is null", async () => {
|
759
|
+
const { componentInstance } = await createDateInputEnv();
|
760
|
+
componentInstance.setDate(null);
|
761
|
+
expect(componentInstance.day).toBeNull();
|
762
|
+
expect(componentInstance.month).toBeNull();
|
763
|
+
expect(componentInstance.year).toBeNull();
|
764
|
+
});
|
765
|
+
});
|
766
|
+
describe("autocompleteInput", () => {
|
767
|
+
it("should call autocompleteYear method if input is the year", async () => {
|
768
|
+
const { componentInstance, yearInput } = await createDateInputEnv();
|
769
|
+
const spyAutocompleteYear = jest.spyOn(componentInstance, "autocompleteYear");
|
770
|
+
yearInput.value = "2000";
|
771
|
+
componentInstance.autocompleteInput(yearInput);
|
772
|
+
expect(spyAutocompleteYear).toBeCalled();
|
773
|
+
});
|
774
|
+
it("should set day to 01 if 0 has been entered as an input value", async () => {
|
775
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
776
|
+
dayInput.value = "0";
|
777
|
+
componentInstance.autocompleteInput(dayInput);
|
778
|
+
expect(dayInput.value).toBe("01");
|
779
|
+
});
|
780
|
+
it("should set day to 05 if 5 has been entered as an input value", async () => {
|
781
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
782
|
+
dayInput.value = "5";
|
783
|
+
componentInstance.autocompleteInput(dayInput);
|
784
|
+
expect(dayInput.value).toBe("05");
|
785
|
+
});
|
786
|
+
it("should set month to 01 if 0 has been entered as an input value", async () => {
|
787
|
+
const { componentInstance, monthInput } = await createDateInputEnv();
|
788
|
+
monthInput.value = "0";
|
789
|
+
componentInstance.autocompleteInput(monthInput);
|
790
|
+
expect(monthInput.value).toBe("01");
|
791
|
+
});
|
792
|
+
it("should set month to 05 if 5 has been entered as an input value", async () => {
|
793
|
+
const { componentInstance, monthInput } = await createDateInputEnv();
|
794
|
+
monthInput.value = "5";
|
795
|
+
componentInstance.autocompleteInput(monthInput);
|
796
|
+
expect(monthInput.value).toBe("05");
|
797
|
+
});
|
798
|
+
it("should call setInputValue method", async () => {
|
799
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
800
|
+
const spySetInputValue = jest.spyOn(componentInstance, "setInputValue");
|
801
|
+
dayInput.value = "0";
|
802
|
+
componentInstance.autocompleteInput(dayInput);
|
803
|
+
expect(spySetInputValue).toBeCalled();
|
804
|
+
});
|
805
|
+
});
|
806
|
+
describe("autocompleteYear", () => {
|
807
|
+
it("should set the year input value to 2001 if 1 is inputted as year value", async () => {
|
808
|
+
const { componentInstance, yearInput } = await createDateInputEnv();
|
809
|
+
yearInput.value = "1";
|
810
|
+
componentInstance.autocompleteYear();
|
811
|
+
expect(yearInput.value).toBe("2001");
|
812
|
+
});
|
813
|
+
it("should set the year input value to 2010", async () => {
|
814
|
+
const { componentInstance, yearInput } = await createDateInputEnv();
|
815
|
+
yearInput.value = "10";
|
816
|
+
componentInstance.autocompleteYear();
|
817
|
+
expect(yearInput.value).toBe("2010");
|
818
|
+
});
|
819
|
+
it("should set the year input value to 2100", async () => {
|
820
|
+
const { componentInstance, yearInput } = await createDateInputEnv();
|
821
|
+
yearInput.value = "100";
|
822
|
+
componentInstance.autocompleteYear();
|
823
|
+
expect(yearInput.value).toBe("2100");
|
824
|
+
});
|
825
|
+
it("should not call setInputValue method if no year has been set", async () => {
|
826
|
+
const { componentInstance } = await createDateInputEnv();
|
827
|
+
const spySetInputValue = jest.spyOn(componentInstance, "setInputValue");
|
828
|
+
componentInstance.autocompleteYear();
|
829
|
+
expect(spySetInputValue).not.toBeCalled();
|
830
|
+
});
|
831
|
+
});
|
832
|
+
describe("handleFormReset", () => {
|
833
|
+
it("should call the setDate, setValidationMessage & handleDateChange event handlers", async () => {
|
834
|
+
const { componentInstance } = await createDateInputEnv();
|
835
|
+
const spySetDate = jest.spyOn(componentInstance, "setDate");
|
836
|
+
const spySetValidationMessage = jest.spyOn(componentInstance, "setValidationMessage");
|
837
|
+
const spyHandleDateChange = jest.spyOn(componentInstance, "handleDateChange");
|
838
|
+
componentInstance.handleFormReset();
|
839
|
+
expect(spySetDate).toHaveBeenCalled();
|
840
|
+
expect(spySetValidationMessage).toHaveBeenCalled();
|
841
|
+
expect(spyHandleDateChange).toHaveBeenCalled();
|
842
|
+
});
|
843
|
+
});
|
844
|
+
describe("convertToDate", () => {
|
845
|
+
it("should return null if either the year, month or day strings are empty", async () => {
|
846
|
+
const { componentInstance } = await createDateInputEnv();
|
847
|
+
expect(componentInstance.convertToDate("", "03", "09")).toBeNull();
|
848
|
+
expect(componentInstance.convertToDate("1970", "", "09")).toBeNull();
|
849
|
+
expect(componentInstance.convertToDate("2000", "12", "")).toBeNull();
|
850
|
+
});
|
851
|
+
it("should return the Date format of a date string", async () => {
|
852
|
+
const { componentInstance } = await createDateInputEnv();
|
853
|
+
expect(componentInstance.convertToDate("2000", "01", "01")).toEqual(new Date(+"2000", +"01" - 1, +"01"));
|
854
|
+
});
|
855
|
+
});
|
856
|
+
describe("preventInput", () => {
|
857
|
+
// eslint-disable-next-line sonarjs/no-duplicate-string
|
858
|
+
it("should return undefined if isInputPrevented is false", async () => {
|
859
|
+
const { componentInstance } = await createDateInputEnv();
|
860
|
+
const getSelectedTextMock = jest.fn().mockReturnValue(false);
|
861
|
+
window.getSelection = jest
|
862
|
+
.fn()
|
863
|
+
.mockReturnValue({ toString: getSelectedTextMock });
|
864
|
+
let keyboardEvent = {
|
865
|
+
key: "e",
|
866
|
+
preventDefault: jest.fn(),
|
867
|
+
};
|
868
|
+
componentInstance.preventInput(keyboardEvent, true);
|
869
|
+
expect(keyboardEvent.preventDefault).toHaveBeenCalled();
|
870
|
+
keyboardEvent = {
|
871
|
+
key: ".",
|
872
|
+
preventDefault: jest.fn(),
|
873
|
+
};
|
874
|
+
componentInstance.preventInput(keyboardEvent, true);
|
875
|
+
expect(keyboardEvent.preventDefault).toHaveBeenCalled();
|
876
|
+
keyboardEvent = {
|
877
|
+
key: HYPHEN,
|
878
|
+
preventDefault: jest.fn(),
|
879
|
+
};
|
880
|
+
componentInstance.preventInput(keyboardEvent, true);
|
881
|
+
expect(keyboardEvent.preventDefault).toHaveBeenCalled();
|
882
|
+
});
|
883
|
+
it('should return undefined if isInputPrevented is false or if a key other than "e", "." or "-" is pressed', async () => {
|
884
|
+
const { componentInstance, component } = await createDateInputEnv();
|
885
|
+
const getSelectedTextMock = jest.fn().mockReturnValue(false);
|
886
|
+
window.getSelection = jest
|
887
|
+
.fn()
|
888
|
+
.mockReturnValue({ toString: getSelectedTextMock });
|
889
|
+
let event = new KeyboardEvent("keydown", { key: HYPHEN });
|
890
|
+
component === null || component === void 0 ? void 0 : component.dispatchEvent(event);
|
891
|
+
expect(componentInstance.preventInput(event, false)).toBeUndefined();
|
892
|
+
event = new KeyboardEvent("keydown", { key: "a" });
|
893
|
+
component === null || component === void 0 ? void 0 : component.dispatchEvent(event);
|
894
|
+
expect(componentInstance.preventInput(event, true)).toBeUndefined();
|
895
|
+
});
|
896
|
+
});
|
897
|
+
describe("handleHostBlur", () => {
|
898
|
+
// eslint-disable-next-line sonarjs/no-duplicate-string
|
899
|
+
it("should return undefined if isInputPrevented is false", async () => {
|
900
|
+
const { componentInstance, component } = await createDateInputEnv();
|
901
|
+
const eventSpy = jest.fn();
|
902
|
+
component === null || component === void 0 ? void 0 : component.addEventListener("icBlur", eventSpy);
|
903
|
+
const value = new Date(500000000000);
|
904
|
+
componentInstance.handleHostBlur();
|
905
|
+
expect(eventSpy).toHaveBeenCalledWith(expect.objectContaining({ detail: expect.objectContaining(value) }));
|
906
|
+
});
|
907
|
+
});
|
908
|
+
describe("handleHostFocus", () => {
|
909
|
+
// eslint-disable-next-line sonarjs/no-duplicate-string
|
910
|
+
it("should return undefined if isInputPrevented is false", async () => {
|
911
|
+
const { componentInstance, component } = await createDateInputEnv();
|
912
|
+
const eventSpy = jest.fn();
|
913
|
+
component === null || component === void 0 ? void 0 : component.addEventListener("icFocus", eventSpy);
|
914
|
+
const value = new Date(500000000000);
|
915
|
+
componentInstance.handleHostFocus();
|
916
|
+
expect(eventSpy).toHaveBeenCalledWith(expect.objectContaining({ detail: expect.objectContaining(value) }));
|
917
|
+
});
|
918
|
+
});
|
919
|
+
describe("handleClear", () => {
|
920
|
+
it("should clear the inputs", async () => {
|
921
|
+
const { componentInstance } = await createDateInputEnv();
|
922
|
+
componentInstance.day = "1";
|
923
|
+
componentInstance.month = "1";
|
924
|
+
componentInstance.year = "2000";
|
925
|
+
componentInstance.handleClear();
|
926
|
+
expect(componentInstance.day).toMatch("");
|
927
|
+
expect(componentInstance.month).toMatch("");
|
928
|
+
expect(componentInstance.year).toMatch("");
|
929
|
+
});
|
930
|
+
});
|
931
|
+
describe("handleCalendarOpen", () => {
|
932
|
+
it("should emit calendarButtonClicked with 1st January 2000 as Date object if calendar button is clicked", async () => {
|
933
|
+
const { component, componentInstance } = await createDateInputEnv();
|
934
|
+
const eventSpy = jest.fn();
|
935
|
+
componentInstance.day = "01";
|
936
|
+
componentInstance.month = "01";
|
937
|
+
componentInstance.year = "2000";
|
938
|
+
const date = new Date(+componentInstance.year, +componentInstance.month - 1, +componentInstance.day);
|
939
|
+
componentInstance.selectedDate = date;
|
940
|
+
component === null || component === void 0 ? void 0 : component.addEventListener("calendarButtonClicked", eventSpy);
|
941
|
+
componentInstance.handleCalendarOpen({
|
942
|
+
stopImmediatePropagation: jest.fn(),
|
943
|
+
});
|
944
|
+
expect(eventSpy).toBeCalledWith(expect.objectContaining({
|
945
|
+
detail: expect.objectContaining({
|
946
|
+
value: date,
|
947
|
+
}),
|
948
|
+
}));
|
949
|
+
});
|
950
|
+
});
|
951
|
+
describe("notifyScreenReader", () => {
|
952
|
+
it("should call notifyScreenReaderArrowKeys if event isKeyboardOrEvent is true", async () => {
|
953
|
+
const { dayInput, componentInstance } = await createDateInputEnv();
|
954
|
+
const spyNotifyScreenReaderArrowKeys = jest.spyOn(componentInstance, "notifyScreenReaderArrowKeys");
|
955
|
+
componentInstance.isKeyboardOrEvent = jest
|
956
|
+
.fn()
|
957
|
+
.mockReturnValueOnce(() => true);
|
958
|
+
componentInstance.notifyScreenReader(dayInput, keyboardEvent("ArrowUp"));
|
959
|
+
expect(spyNotifyScreenReaderArrowKeys).toBeCalled();
|
960
|
+
});
|
961
|
+
});
|
962
|
+
describe("componentWillLoad", () => {
|
963
|
+
it("should set helperText to default value if not set", async () => {
|
964
|
+
const { componentInstance } = await createDateInputEnv();
|
965
|
+
componentInstance.helperText = "";
|
966
|
+
componentInstance.componentWillLoad();
|
967
|
+
expect(componentInstance.helperText).toBe("Use format " + componentInstance.dateFormat);
|
968
|
+
});
|
969
|
+
it("should call setDate when value is set", async () => {
|
970
|
+
const { componentInstance } = await createDateInputEnv();
|
971
|
+
const spySetDate = jest.spyOn(componentInstance, "setDate");
|
972
|
+
componentInstance.value = DATE_2000;
|
973
|
+
componentInstance.componentWillLoad();
|
974
|
+
expect(spySetDate).toBeCalled();
|
975
|
+
});
|
976
|
+
});
|
977
|
+
describe("componentWillUpdate", () => {
|
978
|
+
it("should call setDate if isDateSetFromKeyboardEvent is set to false", async () => {
|
979
|
+
const { componentInstance } = await createDateInputEnv();
|
980
|
+
componentInstance.isDateSetFromKeyboardEvent = false;
|
981
|
+
const spySetDate = jest.spyOn(componentInstance, "setDate");
|
982
|
+
componentInstance.componentWillUpdate();
|
983
|
+
expect(spySetDate).toBeCalled();
|
984
|
+
});
|
985
|
+
it("should call setValidationMessage and handleDateChange", async () => {
|
986
|
+
const { componentInstance } = await createDateInputEnv();
|
987
|
+
componentInstance.isDateSetFromKeyboardEvent = false;
|
988
|
+
const spySetValidationMessage = jest.spyOn(componentInstance, "setValidationMessage");
|
989
|
+
const spyHandleDateChange = jest.spyOn(componentInstance, "handleDateChange");
|
990
|
+
componentInstance.componentWillUpdate();
|
991
|
+
expect(spySetValidationMessage).toBeCalled();
|
992
|
+
expect(spyHandleDateChange).toBeCalled();
|
993
|
+
});
|
994
|
+
it("should set isDateSetFromKeyboardEvent to false", async () => {
|
995
|
+
const { componentInstance } = await createDateInputEnv();
|
996
|
+
componentInstance.isDateSetFromKeyboardEvent = true;
|
997
|
+
componentInstance.componentWillUpdate();
|
998
|
+
expect(componentInstance.isDateSetFromKeyboardEvent).toBeFalsy();
|
999
|
+
});
|
1000
|
+
});
|
1001
|
+
describe("getArialLabel", () => {
|
1002
|
+
it("should get aria-label day from input", async () => {
|
1003
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
1004
|
+
const ariaLabel = componentInstance.getAriaLabel(dayInput);
|
1005
|
+
expect(ariaLabel).toBe("day");
|
1006
|
+
});
|
1007
|
+
});
|
1008
|
+
describe("setAriaInvalid", () => {
|
1009
|
+
it("should set aria-invalid on day input if validDay is invalid", async () => {
|
1010
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
1011
|
+
const validDay = false;
|
1012
|
+
const validMonth = true;
|
1013
|
+
const validDate = true;
|
1014
|
+
const disanbledDate = false;
|
1015
|
+
componentInstance.setAriaInvalid(validDay, validMonth, validDate, disanbledDate);
|
1016
|
+
expect(dayInput).toHaveAttribute(ARIA_INVALID);
|
1017
|
+
expect(dayInput.getAttribute(ARIA_INVALID)).toBe("true");
|
1018
|
+
});
|
1019
|
+
it("should set aria-invalid on month input if validMonth is invalid", async () => {
|
1020
|
+
const { componentInstance, monthInput } = await createDateInputEnv();
|
1021
|
+
const validDay = true;
|
1022
|
+
const validMonth = false;
|
1023
|
+
const validDate = true;
|
1024
|
+
const disanbledDate = false;
|
1025
|
+
componentInstance.setAriaInvalid(validDay, validMonth, validDate, disanbledDate);
|
1026
|
+
expect(monthInput).toHaveAttribute(ARIA_INVALID);
|
1027
|
+
expect(monthInput.getAttribute(ARIA_INVALID)).toBe("true");
|
1028
|
+
});
|
1029
|
+
});
|
1030
|
+
describe("getDate()", () => {
|
1031
|
+
it("should return null from getDate if no value is entered", async () => {
|
1032
|
+
const { componentInstance } = await createDateInputEnv();
|
1033
|
+
componentInstance.selectedDate = null;
|
1034
|
+
const dateValue = await componentInstance.getDate();
|
1035
|
+
expect(dateValue).toBeNull();
|
1036
|
+
});
|
1037
|
+
it("should return partial date due to date object if incomplete date", async () => {
|
1038
|
+
const { componentInstance } = await createDateInputEnv();
|
1039
|
+
const date = new Date("37/01");
|
1040
|
+
componentInstance.selectedDate = date;
|
1041
|
+
const dateValue = await componentInstance.getDate();
|
1042
|
+
expect(dateValue).toBe(date);
|
1043
|
+
});
|
1044
|
+
it("should return invalid date if invalid date", async () => {
|
1045
|
+
const { componentInstance } = await createDateInputEnv();
|
1046
|
+
const date = new Date("37/99/99");
|
1047
|
+
componentInstance.selectedDate = date;
|
1048
|
+
const dateValue = await componentInstance.getDate();
|
1049
|
+
expect(dateValue).toBeInstanceOf(Date);
|
1050
|
+
expect(dateValue.toString()).toBe("Invalid Date");
|
1051
|
+
});
|
1052
|
+
it("should return valid date", async () => {
|
1053
|
+
const { componentInstance } = await createDateInputEnv();
|
1054
|
+
const date = new Date("01/01/2001");
|
1055
|
+
componentInstance.selectedDate = date;
|
1056
|
+
const dateValue = await componentInstance.getDate();
|
1057
|
+
expect(dateValue).toBe(date);
|
1058
|
+
});
|
1059
|
+
});
|
1060
|
+
describe("checkSingleCopiedValueIsValid", () => {
|
1061
|
+
it("should return true if dayInput pasted value is 1", async () => {
|
1062
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
1063
|
+
const isValid = componentInstance.checkSingleCopiedValueIsValid(dayInput, "1");
|
1064
|
+
expect(isValid).toBeTruthy();
|
1065
|
+
});
|
1066
|
+
it("should return true if dayInput pasted value is 31", async () => {
|
1067
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
1068
|
+
const isValid = componentInstance.checkSingleCopiedValueIsValid(dayInput, "31");
|
1069
|
+
expect(isValid).toBeTruthy();
|
1070
|
+
});
|
1071
|
+
it("should return true if dayInput pasted value is 24", async () => {
|
1072
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
1073
|
+
const isValid = componentInstance.checkSingleCopiedValueIsValid(dayInput, "24");
|
1074
|
+
expect(isValid).toBeTruthy();
|
1075
|
+
});
|
1076
|
+
it("should return false if dayInput pasted value is 0", async () => {
|
1077
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
1078
|
+
const isValid = componentInstance.checkSingleCopiedValueIsValid(dayInput, "0");
|
1079
|
+
expect(isValid).toBeFalsy();
|
1080
|
+
});
|
1081
|
+
it("should return false if dayInput pasted value is above 31", async () => {
|
1082
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
1083
|
+
const isValid = componentInstance.checkSingleCopiedValueIsValid(dayInput, "32");
|
1084
|
+
expect(isValid).toBeFalsy();
|
1085
|
+
});
|
1086
|
+
it("should return false if monthInput pasted value is 0", async () => {
|
1087
|
+
const { componentInstance, monthInput } = await createDateInputEnv();
|
1088
|
+
const isValid = componentInstance.checkSingleCopiedValueIsValid(monthInput, "0");
|
1089
|
+
expect(isValid).toBeFalsy();
|
1090
|
+
});
|
1091
|
+
it("should return true if monthInput pasted value is 1", async () => {
|
1092
|
+
const { componentInstance, monthInput } = await createDateInputEnv();
|
1093
|
+
const isValid = componentInstance.checkSingleCopiedValueIsValid(monthInput, "1");
|
1094
|
+
expect(isValid).toBeTruthy();
|
1095
|
+
});
|
1096
|
+
it("should return true if monthInput pasted value is 12", async () => {
|
1097
|
+
const { componentInstance, monthInput } = await createDateInputEnv();
|
1098
|
+
const isValid = componentInstance.checkSingleCopiedValueIsValid(monthInput, "12");
|
1099
|
+
expect(isValid).toBeTruthy();
|
1100
|
+
});
|
1101
|
+
it("should return false if monthInput pasted value is 13", async () => {
|
1102
|
+
const { componentInstance, monthInput } = await createDateInputEnv();
|
1103
|
+
const isValid = componentInstance.checkSingleCopiedValueIsValid(monthInput, "13");
|
1104
|
+
expect(isValid).toBeFalsy();
|
1105
|
+
});
|
1106
|
+
it("should return true if yearMonth pasted value passed in", async () => {
|
1107
|
+
const { componentInstance, yearInput } = await createDateInputEnv();
|
1108
|
+
const isValid = componentInstance.checkSingleCopiedValueIsValid(yearInput, "11");
|
1109
|
+
expect(isValid).toBeTruthy();
|
1110
|
+
});
|
1111
|
+
it("should return false if undefined input with pasted value passed in", async () => {
|
1112
|
+
const { componentInstance } = await createDateInputEnv();
|
1113
|
+
const isValid = componentInstance.checkSingleCopiedValueIsValid(undefined, "11");
|
1114
|
+
expect(isValid).toBeFalsy();
|
1115
|
+
});
|
1116
|
+
});
|
1117
|
+
describe("setInputPasteValue", () => {
|
1118
|
+
it("should set CSS class and paste value into input", async () => {
|
1119
|
+
const { componentInstance, dayInput } = await createDateInputEnv();
|
1120
|
+
const VALUE = "11";
|
1121
|
+
componentInstance.setInputPasteValue(dayInput, VALUE);
|
1122
|
+
expect(dayInput.value).toBe(VALUE);
|
1123
|
+
expect(dayInput).toHaveClass("fit-to-value");
|
1124
|
+
});
|
1125
|
+
});
|
1126
|
+
describe("isPastedStringDateValid", () => {
|
1127
|
+
it("should return true if 1/1/2001 is value", async () => {
|
1128
|
+
const { componentInstance } = await createDateInputEnv();
|
1129
|
+
expect(componentInstance.isPastedStringDateValid("1/1/2001")).toBeTruthy();
|
1130
|
+
});
|
1131
|
+
it("should return true if 1-1-2001 is value", async () => {
|
1132
|
+
const { componentInstance } = await createDateInputEnv();
|
1133
|
+
expect(componentInstance.isPastedStringDateValid("1-1-2001")).toBeTruthy();
|
1134
|
+
});
|
1135
|
+
it("should return true if 1.1.2001 is value", async () => {
|
1136
|
+
const { componentInstance } = await createDateInputEnv();
|
1137
|
+
expect(componentInstance.isPastedStringDateValid("1.1.2001")).toBeTruthy();
|
1138
|
+
});
|
1139
|
+
it("should return true if abc is value", async () => {
|
1140
|
+
const { componentInstance } = await createDateInputEnv();
|
1141
|
+
expect(componentInstance.isPastedStringDateValid("abc")).toBeFalsy();
|
1142
|
+
});
|
1143
|
+
it("should return true if 123456789 is value", async () => {
|
1144
|
+
const { componentInstance } = await createDateInputEnv();
|
1145
|
+
expect(componentInstance.isPastedStringDateValid("123456789")).toBeFalsy();
|
1146
|
+
});
|
1147
|
+
});
|
1148
|
+
describe("setDisableDays", () => {
|
1149
|
+
it("should test setting disableDays ", async () => {
|
1150
|
+
const { component, componentInstance } = await createDateInputEnv();
|
1151
|
+
await component.setDisableDays([0, 1]);
|
1152
|
+
expect(componentInstance.disableDays).toEqual([0, 1]);
|
1153
|
+
});
|
1154
|
+
});
|
1155
|
+
});
|
1156
|
+
//# sourceMappingURL=ic-date-input.spec.js.map
|