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