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