@kirbydesign/designsystem 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/karma.conf.js +34 -0
- package/ng-package.json +32 -0
- package/ngcc.config.js +3 -0
- package/package.json +27 -0
- package/src/index.ts +1 -0
- package/src/lib/animation/kirby-animation.ts +12 -0
- package/src/lib/components/accordion/accordion-item.component.html +25 -0
- package/src/lib/components/accordion/accordion-item.component.scss +64 -0
- package/src/lib/components/accordion/accordion-item.component.spec.ts +52 -0
- package/src/lib/components/accordion/accordion-item.component.ts +27 -0
- package/src/lib/components/accordion/accordion.directive.ts +7 -0
- package/src/lib/components/accordion/index.ts +2 -0
- package/src/lib/components/angular-component-lib/utils.ts +43 -0
- package/src/lib/components/app/app.component.html +3 -0
- package/src/lib/components/app/app.component.scss +10 -0
- package/src/lib/components/app/app.component.spec.ts +52 -0
- package/src/lib/components/app/app.component.ts +50 -0
- package/src/lib/components/app/app.module.ts +12 -0
- package/src/lib/components/app/index.ts +2 -0
- package/src/lib/components/avatar/avatar.component.html +6 -0
- package/src/lib/components/avatar/avatar.component.scss +153 -0
- package/src/lib/components/avatar/avatar.component.spec.ts +207 -0
- package/src/lib/components/avatar/avatar.component.ts +32 -0
- package/src/lib/components/badge/badge.component.spec.ts +78 -0
- package/src/lib/components/button/button.component.html +1 -0
- package/src/lib/components/button/button.component.integration.spec.ts +576 -0
- package/src/lib/components/button/button.component.scss +286 -0
- package/src/lib/components/button/button.component.spec.ts +404 -0
- package/src/lib/components/button/button.component.ts +96 -0
- package/src/lib/components/calendar/calendar.component.html +49 -0
- package/src/lib/components/calendar/calendar.component.initialization.spec.ts +93 -0
- package/src/lib/components/calendar/calendar.component.scss +132 -0
- package/src/lib/components/calendar/calendar.component.spec.ts +470 -0
- package/src/lib/components/calendar/calendar.component.ts +513 -0
- package/src/lib/components/calendar/helpers/calendar-cell.model.ts +7 -0
- package/src/lib/components/calendar/helpers/calendar-options.model.ts +10 -0
- package/src/lib/components/calendar/helpers/calendar.helper.ts +108 -0
- package/src/lib/components/calendar/index.ts +2 -0
- package/src/lib/components/calendar/options/calendar-year-navigator-config.ts +4 -0
- package/src/lib/components/card/card-footer/card-footer.component.html +3 -0
- package/src/lib/components/card/card-footer/card-footer.component.scss +19 -0
- package/src/lib/components/card/card-footer/card-footer.component.ts +13 -0
- package/src/lib/components/card/card-header/card-header.component.html +5 -0
- package/src/lib/components/card/card-header/card-header.component.scss +63 -0
- package/src/lib/components/card/card-header/card-header.component.ts +20 -0
- package/src/lib/components/card/card.component.html +5 -0
- package/src/lib/components/card/card.component.scss +56 -0
- package/src/lib/components/card/card.component.spec.ts +81 -0
- package/src/lib/components/card/card.component.ts +95 -0
- package/src/lib/components/card/index.ts +3 -0
- package/src/lib/components/chart/chart-js/chart-js.service.integration.spec.ts +320 -0
- package/src/lib/components/chart/chart-js/chart-js.service.spec.ts +1004 -0
- package/src/lib/components/chart/chart-js/chart-js.service.ts +445 -0
- package/src/lib/components/chart/chart-js/chartjs-plugin-marker/chartjs-plugin-marker.ts +254 -0
- package/src/lib/components/chart/chart-js/configured-chart-js.ts +39 -0
- package/src/lib/components/chart/chart-js/test-utils.ts +171 -0
- package/src/lib/components/chart/chart.component.html +7 -0
- package/src/lib/components/chart/chart.component.scss +6 -0
- package/src/lib/components/chart/chart.component.spec.ts +188 -0
- package/src/lib/components/chart/chart.component.ts +148 -0
- package/src/lib/components/chart/chart.module.ts +11 -0
- package/src/lib/components/chart/chart.types.ts +34 -0
- package/src/lib/components/chart/configs/annotations.config.ts +36 -0
- package/src/lib/components/chart/configs/chart-config.service.spec.ts +21 -0
- package/src/lib/components/chart/configs/chart-config.service.ts +34 -0
- package/src/lib/components/chart/configs/global-defaults.config.ts +50 -0
- package/src/lib/components/chart/configs/interaction-functions-extensions.config.ts +19 -0
- package/src/lib/components/chart/configs/shared.utils.ts +28 -0
- package/src/lib/components/chart/configs/type.config.ts +214 -0
- package/src/lib/components/chart/index.ts +5 -0
- package/src/lib/components/chart-deprecated/chart-deprecated-helper.ts +25 -0
- package/src/lib/components/chart-deprecated/chart-deprecated-type.ts +10 -0
- package/src/lib/components/chart-deprecated/chart-deprecated.component.scss +3 -0
- package/src/lib/components/chart-deprecated/chart-deprecated.component.spec.ts +271 -0
- package/src/lib/components/chart-deprecated/chart-deprecated.component.ts +233 -0
- package/src/lib/components/chart-deprecated/index.ts +2 -0
- package/src/lib/components/chart-deprecated/options/activitygauge.ts +87 -0
- package/src/lib/components/chart-deprecated/options/areaspline.ts +95 -0
- package/src/lib/components/chart-deprecated/options/bar.ts +93 -0
- package/src/lib/components/chart-deprecated/options/column.ts +101 -0
- package/src/lib/components/chart-deprecated/options/donut.ts +118 -0
- package/src/lib/components/chart-deprecated/options/timeseries.ts +96 -0
- package/src/lib/components/checkbox/checkbox.component.html +10 -0
- package/src/lib/components/checkbox/checkbox.component.integration.spec.ts +59 -0
- package/src/lib/components/checkbox/checkbox.component.scss +130 -0
- package/src/lib/components/checkbox/checkbox.component.spec.ts +205 -0
- package/src/lib/components/checkbox/checkbox.component.ts +56 -0
- package/src/lib/components/chip/chip.component.html +1 -0
- package/src/lib/components/chip/chip.component.integration.spec.ts +111 -0
- package/src/lib/components/chip/chip.component.scss +49 -0
- package/src/lib/components/chip/chip.component.spec.ts +84 -0
- package/src/lib/components/chip/chip.component.ts +16 -0
- package/src/lib/components/divider/divider.component.html +1 -0
- package/src/lib/components/divider/divider.component.scss +22 -0
- package/src/lib/components/divider/divider.component.spec.ts +24 -0
- package/src/lib/components/divider/divider.component.ts +12 -0
- package/src/lib/components/dropdown/dropdown-popover.component.integration.spec.ts +177 -0
- package/src/lib/components/dropdown/dropdown-popover.component.spec.ts +1154 -0
- package/src/lib/components/dropdown/dropdown.component.html +42 -0
- package/src/lib/components/dropdown/dropdown.component.scss +142 -0
- package/src/lib/components/dropdown/dropdown.component.spec.ts +1215 -0
- package/src/lib/components/dropdown/dropdown.component.ts +538 -0
- package/src/lib/components/dropdown/dropdown.types.ts +10 -0
- package/src/lib/components/dropdown/keyboard-handler.service.ts +38 -0
- package/src/lib/components/empty-state/empty-state.component.html +10 -0
- package/src/lib/components/empty-state/empty-state.component.integration.spec.ts +110 -0
- package/src/lib/components/empty-state/empty-state.component.scss +50 -0
- package/src/lib/components/empty-state/empty-state.component.spec.ts +40 -0
- package/src/lib/components/empty-state/empty-state.component.ts +50 -0
- package/src/lib/components/fab-sheet/fab-sheet.component.html +13 -0
- package/src/lib/components/fab-sheet/fab-sheet.component.scss +67 -0
- package/src/lib/components/fab-sheet/fab-sheet.component.spec.ts +29 -0
- package/src/lib/components/fab-sheet/fab-sheet.component.ts +100 -0
- package/src/lib/components/flag/flag.component.scss +40 -0
- package/src/lib/components/flag/flag.component.spec.ts +152 -0
- package/src/lib/components/flag/flag.component.ts +18 -0
- package/src/lib/components/form-field/_form-field-inputs.shared.scss +62 -0
- package/src/lib/components/form-field/directives/date/date-input.directive.spec.ts +127 -0
- package/src/lib/components/form-field/directives/date/date-input.directive.ts +94 -0
- package/src/lib/components/form-field/directives/decimal-mask/decimal-mask.directive.spec.ts +231 -0
- package/src/lib/components/form-field/directives/decimal-mask/decimal-mask.directive.ts +113 -0
- package/src/lib/components/form-field/form-field-message/form-field-message.component.html +1 -0
- package/src/lib/components/form-field/form-field-message/form-field-message.component.scss +11 -0
- package/src/lib/components/form-field/form-field-message/form-field-message.component.ts +12 -0
- package/src/lib/components/form-field/form-field.component.html +39 -0
- package/src/lib/components/form-field/form-field.component.scss +43 -0
- package/src/lib/components/form-field/form-field.component.spec.ts +521 -0
- package/src/lib/components/form-field/form-field.component.ts +141 -0
- package/src/lib/components/form-field/index.ts +7 -0
- package/src/lib/components/form-field/input/input.component.integration.spec.ts +83 -0
- package/src/lib/components/form-field/input/input.component.scss +54 -0
- package/src/lib/components/form-field/input/input.component.spec.ts +159 -0
- package/src/lib/components/form-field/input/input.component.ts +91 -0
- package/src/lib/components/form-field/input-counter/input-counter.component.html +1 -0
- package/src/lib/components/form-field/input-counter/input-counter.component.spec.ts +184 -0
- package/src/lib/components/form-field/input-counter/input-counter.component.ts +41 -0
- package/src/lib/components/form-field/textarea/textarea.component.html +2 -0
- package/src/lib/components/form-field/textarea/textarea.component.scss +11 -0
- package/src/lib/components/form-field/textarea/textarea.component.spec.ts +100 -0
- package/src/lib/components/form-field/textarea/textarea.component.ts +64 -0
- package/src/lib/components/grid/breakpoint-helper.service.ts +27 -0
- package/src/lib/components/grid/grid-card-configuration.ts +7 -0
- package/src/lib/components/grid/grid.component.html +6 -0
- package/src/lib/components/grid/grid.component.scss +26 -0
- package/src/lib/components/grid/grid.component.ts +106 -0
- package/src/lib/components/icon/icon-registry.service.spec.ts +107 -0
- package/src/lib/components/icon/icon-registry.service.ts +39 -0
- package/src/lib/components/icon/icon-settings.ts +8 -0
- package/src/lib/components/icon/icon.component.html +1 -0
- package/src/lib/components/icon/icon.component.scss +47 -0
- package/src/lib/components/icon/icon.component.spec.ts +254 -0
- package/src/lib/components/icon/icon.component.ts +89 -0
- package/src/lib/components/icon/icon.module.ts +11 -0
- package/src/lib/components/icon/index.ts +5 -0
- package/src/lib/components/icon/kirby-icon-settings.ts +65 -0
- package/src/lib/components/icon/readme.md +16 -0
- package/src/lib/components/icon/selection.json +1776 -0
- package/src/lib/components/index.ts +67 -0
- package/src/lib/components/item/_item.utils.scss +36 -0
- package/src/lib/components/item/index.ts +3 -0
- package/src/lib/components/item/item.component.html +16 -0
- package/src/lib/components/item/item.component.integration.spec.ts +64 -0
- package/src/lib/components/item/item.component.scss +156 -0
- package/src/lib/components/item/item.component.spec.ts +85 -0
- package/src/lib/components/item/item.component.ts +37 -0
- package/src/lib/components/item/item.module.ts +14 -0
- package/src/lib/components/item/label/label.component.html +3 -0
- package/src/lib/components/item/label/label.component.scss +36 -0
- package/src/lib/components/item/label/label.component.spec.ts +23 -0
- package/src/lib/components/item/label/label.component.ts +16 -0
- package/src/lib/components/item-group/item-group.component.html +1 -0
- package/src/lib/components/item-group/item-group.component.scss +3 -0
- package/src/lib/components/item-group/item-group.component.spec.ts +42 -0
- package/src/lib/components/item-group/item-group.component.ts +10 -0
- package/src/lib/components/item-sliding/index.ts +2 -0
- package/src/lib/components/item-sliding/item-sliding.component.html +20 -0
- package/src/lib/components/item-sliding/item-sliding.component.scss +9 -0
- package/src/lib/components/item-sliding/item-sliding.component.spec.ts +174 -0
- package/src/lib/components/item-sliding/item-sliding.component.ts +23 -0
- package/src/lib/components/item-sliding/item-sliding.shared.scss +18 -0
- package/src/lib/components/item-sliding/item-sliding.types.ts +13 -0
- package/src/lib/components/list/directives/infinite-scroll.directive.spec.ts +131 -0
- package/src/lib/components/list/directives/infinite-scroll.directive.ts +137 -0
- package/src/lib/components/list/directives/list-item-color.directive.ts +27 -0
- package/src/lib/components/list/directives/scroll.model.ts +5 -0
- package/src/lib/components/list/helpers/list-helper.spec.ts +109 -0
- package/src/lib/components/list/helpers/list-helper.ts +19 -0
- package/src/lib/components/list/index.ts +21 -0
- package/src/lib/components/list/list-experimental/list-experimental.component.html +4 -0
- package/src/lib/components/list/list-experimental/list-experimental.component.scss +6 -0
- package/src/lib/components/list/list-experimental/list-experimental.component.spec.ts +112 -0
- package/src/lib/components/list/list-experimental/list-experimental.component.ts +21 -0
- package/src/lib/components/list/list-header/list-header.component.html +1 -0
- package/src/lib/components/list/list-header/list-header.component.scss +10 -0
- package/src/lib/components/list/list-header/list-header.component.spec.ts +24 -0
- package/src/lib/components/list/list-header/list-header.component.ts +11 -0
- package/src/lib/components/list/list-item/list-item.component.html +39 -0
- package/src/lib/components/list/list-item/list-item.component.scss +13 -0
- package/src/lib/components/list/list-item/list-item.component.ts +144 -0
- package/src/lib/components/list/list-section-header/list-section-header.component.html +3 -0
- package/src/lib/components/list/list-section-header/list-section-header.component.spec.ts +24 -0
- package/src/lib/components/list/list-section-header/list-section-header.component.ts +13 -0
- package/src/lib/components/list/list-swipe-action.ts +2 -0
- package/src/lib/components/list/list-swipe-action.type.ts +23 -0
- package/src/lib/components/list/list.component.html +65 -0
- package/src/lib/components/list/list.component.integration.spec.ts +177 -0
- package/src/lib/components/list/list.component.scss +243 -0
- package/src/lib/components/list/list.component.spec.ts +219 -0
- package/src/lib/components/list/list.component.ts +213 -0
- package/src/lib/components/list/list.directive.ts +21 -0
- package/src/lib/components/list/list.event.ts +8 -0
- package/src/lib/components/list/list.module.ts +47 -0
- package/src/lib/components/list/pipes/group-by.pipe.spec.ts +71 -0
- package/src/lib/components/list/pipes/group-by.pipe.ts +34 -0
- package/src/lib/components/loading-overlay/index.ts +2 -0
- package/src/lib/components/loading-overlay/loading-overlay.component.html +8 -0
- package/src/lib/components/loading-overlay/loading-overlay.component.scss +37 -0
- package/src/lib/components/loading-overlay/loading-overlay.component.ts +12 -0
- package/src/lib/components/loading-overlay/loading-overlay.service.ts +44 -0
- package/src/lib/components/modal/action-sheet/action-sheet.component.html +24 -0
- package/src/lib/components/modal/action-sheet/action-sheet.component.scss +47 -0
- package/src/lib/components/modal/action-sheet/action-sheet.component.spec.ts +153 -0
- package/src/lib/components/modal/action-sheet/action-sheet.component.ts +27 -0
- package/src/lib/components/modal/action-sheet/config/action-sheet-config.ts +8 -0
- package/src/lib/components/modal/action-sheet/config/action-sheet-item.ts +4 -0
- package/src/lib/components/modal/alert/alert.component.html +29 -0
- package/src/lib/components/modal/alert/alert.component.scss +21 -0
- package/src/lib/components/modal/alert/alert.component.spec.ts +104 -0
- package/src/lib/components/modal/alert/alert.component.ts +67 -0
- package/src/lib/components/modal/alert/config/alert-config.ts +19 -0
- package/src/lib/components/modal/footer/modal-footer.component.html +3 -0
- package/src/lib/components/modal/footer/modal-footer.component.scss +57 -0
- package/src/lib/components/modal/footer/modal-footer.component.spec.ts +209 -0
- package/src/lib/components/modal/footer/modal-footer.component.ts +17 -0
- package/src/lib/components/modal/index.ts +9 -0
- package/src/lib/components/modal/modal-wrapper/compact/modal-compact-wrapper.component.html +3 -0
- package/src/lib/components/modal/modal-wrapper/compact/modal-compact-wrapper.component.scss +8 -0
- package/src/lib/components/modal/modal-wrapper/compact/modal-compact-wrapper.component.ts +79 -0
- package/src/lib/components/modal/modal-wrapper/config/drawer-supplementary-action.ts +4 -0
- package/src/lib/components/modal/modal-wrapper/config/modal-config.helper.ts +3 -0
- package/src/lib/components/modal/modal-wrapper/config/modal-config.ts +22 -0
- package/src/lib/components/modal/modal-wrapper/modal-wrapper.component.html +43 -0
- package/src/lib/components/modal/modal-wrapper/modal-wrapper.component.scss +159 -0
- package/src/lib/components/modal/modal-wrapper/modal-wrapper.component.spec.ts +942 -0
- package/src/lib/components/modal/modal-wrapper/modal-wrapper.component.ts +587 -0
- package/src/lib/components/modal/modal-wrapper/modal-wrapper.testbuilder.ts +155 -0
- package/src/lib/components/modal/services/action-sheet.helper.spec.ts +86 -0
- package/src/lib/components/modal/services/action-sheet.helper.ts +47 -0
- package/src/lib/components/modal/services/alert.helper.spec.ts +89 -0
- package/src/lib/components/modal/services/alert.helper.ts +57 -0
- package/src/lib/components/modal/services/modal-animation-builder.service.ts +276 -0
- package/src/lib/components/modal/services/modal-navigation.service.spec.ts +543 -0
- package/src/lib/components/modal/services/modal-navigation.service.ts +331 -0
- package/src/lib/components/modal/services/modal.controller.spec.ts +212 -0
- package/src/lib/components/modal/services/modal.controller.ts +194 -0
- package/src/lib/components/modal/services/modal.helper.spec.ts +828 -0
- package/src/lib/components/modal/services/modal.helper.ts +128 -0
- package/src/lib/components/modal/services/modal.interfaces.ts +28 -0
- package/src/lib/components/page/index.ts +13 -0
- package/src/lib/components/page/page-footer/page-footer.component.html +3 -0
- package/src/lib/components/page/page-footer/page-footer.component.scss +23 -0
- package/src/lib/components/page/page-footer/page-footer.component.spec.ts +52 -0
- package/src/lib/components/page/page-footer/page-footer.component.ts +46 -0
- package/src/lib/components/page/page.component.html +101 -0
- package/src/lib/components/page/page.component.scss +141 -0
- package/src/lib/components/page/page.component.spec.ts +224 -0
- package/src/lib/components/page/page.component.ts +415 -0
- package/src/lib/components/page/page.module.ts +52 -0
- package/src/lib/components/popover/popover.component.scss +26 -0
- package/src/lib/components/popover/popover.component.spec.ts +0 -0
- package/src/lib/components/popover/popover.component.ts +221 -0
- package/src/lib/components/progress-circle/progress-circle-ring.component.scss +22 -0
- package/src/lib/components/progress-circle/progress-circle-ring.component.spec.ts +143 -0
- package/src/lib/components/progress-circle/progress-circle-ring.component.svg +23 -0
- package/src/lib/components/progress-circle/progress-circle-ring.component.ts +42 -0
- package/src/lib/components/progress-circle/progress-circle.component.html +11 -0
- package/src/lib/components/progress-circle/progress-circle.component.scss +28 -0
- package/src/lib/components/progress-circle/progress-circle.component.spec.ts +339 -0
- package/src/lib/components/progress-circle/progress-circle.component.ts +96 -0
- package/src/lib/components/radio/index.ts +2 -0
- package/src/lib/components/radio/radio-group/radio-group.component.html +24 -0
- package/src/lib/components/radio/radio-group/radio-group.component.spec.ts +1328 -0
- package/src/lib/components/radio/radio-group/radio-group.component.ts +272 -0
- package/src/lib/components/radio/radio.component.html +9 -0
- package/src/lib/components/radio/radio.component.integration.spec.ts +93 -0
- package/src/lib/components/radio/radio.component.scss +133 -0
- package/src/lib/components/radio/radio.component.spec.ts +244 -0
- package/src/lib/components/radio/radio.component.ts +50 -0
- package/src/lib/components/range/range.component.html +16 -0
- package/src/lib/components/range/range.component.scss +81 -0
- package/src/lib/components/range/range.component.ts +105 -0
- package/src/lib/components/reorder-list/index.ts +3 -0
- package/src/lib/components/reorder-list/reorder-event.ts +17 -0
- package/src/lib/components/reorder-list/reorder-list.component.html +30 -0
- package/src/lib/components/reorder-list/reorder-list.component.scss +90 -0
- package/src/lib/components/reorder-list/reorder-list.component.spec.ts +123 -0
- package/src/lib/components/reorder-list/reorder-list.component.ts +86 -0
- package/src/lib/components/router-outlet/index.ts +5 -0
- package/src/lib/components/router-outlet/router-outlet.component.html +6 -0
- package/src/lib/components/router-outlet/router-outlet.component.scss +13 -0
- package/src/lib/components/router-outlet/router-outlet.component.spec.ts +28 -0
- package/src/lib/components/router-outlet/router-outlet.component.ts +11 -0
- package/src/lib/components/router-outlet/router-outlet.module.ts +12 -0
- package/src/lib/components/section-header/_section-header.utils.scss +34 -0
- package/src/lib/components/section-header/section-header.component.html +3 -0
- package/src/lib/components/section-header/section-header.component.scss +15 -0
- package/src/lib/components/section-header/section-header.component.spec.ts +59 -0
- package/src/lib/components/section-header/section-header.component.ts +9 -0
- package/src/lib/components/section-header/section-header.integration.spec.ts +67 -0
- package/src/lib/components/segmented-control/segment-item.ts +18 -0
- package/src/lib/components/segmented-control/segmented-control.component.html +39 -0
- package/src/lib/components/segmented-control/segmented-control.component.scss +84 -0
- package/src/lib/components/segmented-control/segmented-control.component.spec.ts +247 -0
- package/src/lib/components/segmented-control/segmented-control.component.ts +96 -0
- package/src/lib/components/shared/component-configuration.ts +6 -0
- package/src/lib/components/shared/component-loader.directive.ts +42 -0
- package/src/lib/components/shared/dynamic-component.ts +3 -0
- package/src/lib/components/shared/index.ts +9 -0
- package/src/lib/components/shared/resize-observer/resize-observer.factory.ts +20 -0
- package/src/lib/components/shared/resize-observer/resize-observer.service.ts +65 -0
- package/src/lib/components/shared/resize-observer/types/resize-observer-callback.ts +7 -0
- package/src/lib/components/shared/resize-observer/types/resize-observer-entry.ts +14 -0
- package/src/lib/components/shared/resize-observer/types/resize-observer.ts +17 -0
- package/src/lib/components/slide-button/slide-button.component.html +14 -0
- package/src/lib/components/slide-button/slide-button.component.scss +81 -0
- package/src/lib/components/slide-button/slide-button.component.shared.scss +12 -0
- package/src/lib/components/slide-button/slide-button.component.spec.ts +75 -0
- package/src/lib/components/slide-button/slide-button.component.ts +81 -0
- package/src/lib/components/slides/slides.component.spec.ts +76 -0
- package/src/lib/components/slides/slides.component.ts +57 -0
- package/src/lib/components/spinner/index.ts +2 -0
- package/src/lib/components/spinner/spinner.component.html +4 -0
- package/src/lib/components/spinner/spinner.component.scss +37 -0
- package/src/lib/components/spinner/spinner.component.ts +13 -0
- package/src/lib/components/spinner/spinner.module.ts +12 -0
- package/src/lib/components/stock-chart-deprecated/index.ts +2 -0
- package/src/lib/components/stock-chart-deprecated/options/stock-chart-deprecated-options.ts +220 -0
- package/src/lib/components/stock-chart-deprecated/stock-chart-deprecated.component.scss +3 -0
- package/src/lib/components/stock-chart-deprecated/stock-chart-deprecated.component.spec.ts +32 -0
- package/src/lib/components/stock-chart-deprecated/stock-chart-deprecated.component.ts +92 -0
- package/src/lib/components/tabs/index.ts +5 -0
- package/src/lib/components/tabs/tab-button/tab-button.component.html +13 -0
- package/src/lib/components/tabs/tab-button/tab-button.component.scss +48 -0
- package/src/lib/components/tabs/tab-button/tab-button.component.spec.ts +24 -0
- package/src/lib/components/tabs/tab-button/tab-button.component.ts +47 -0
- package/src/lib/components/tabs/tab-button/tab-button.events.ts +1 -0
- package/src/lib/components/tabs/tabs.component.html +5 -0
- package/src/lib/components/tabs/tabs.component.scss +52 -0
- package/src/lib/components/tabs/tabs.component.spec.ts +125 -0
- package/src/lib/components/tabs/tabs.component.ts +21 -0
- package/src/lib/components/tabs/tabs.module.ts +16 -0
- package/src/lib/components/tabs/tabs.service.ts +17 -0
- package/src/lib/components/toast/config/toast-config.ts +8 -0
- package/src/lib/components/toast/index.ts +2 -0
- package/src/lib/components/toast/services/toast.controller.ts +18 -0
- package/src/lib/components/toast/services/toast.helper.spec.ts +89 -0
- package/src/lib/components/toast/services/toast.helper.ts +39 -0
- package/src/lib/components/toggle/toggle.component.html +5 -0
- package/src/lib/components/toggle/toggle.component.scss +5 -0
- package/src/lib/components/toggle/toggle.component.spec.ts +62 -0
- package/src/lib/components/toggle/toggle.component.ts +17 -0
- package/src/lib/components/toggle-button/index.ts +2 -0
- package/src/lib/components/toggle-button/toggle-button.component.html +6 -0
- package/src/lib/components/toggle-button/toggle-button.component.spec.ts +23 -0
- package/src/lib/components/toggle-button/toggle-button.component.ts +24 -0
- package/src/lib/components/toggle-button/toggle-button.module.ts +13 -0
- package/src/lib/components/web-component-proxies.component.ts +25 -0
- package/src/lib/custom-elements-initializer.ts +19 -0
- package/src/lib/directives/element-as-button/element-as-button.directive.spec.ts +31 -0
- package/src/lib/directives/element-as-button/element-as-button.directive.ts +26 -0
- package/src/lib/directives/fit-heading/fit-heading.directive.ts +131 -0
- package/src/lib/directives/fit-heading/fit-heading.module.ts +9 -0
- package/src/lib/directives/index.ts +9 -0
- package/src/lib/directives/key-handler/key-handler.directive.ts +20 -0
- package/src/lib/directives/modal-router-link/modal-router-link.directive.ts +24 -0
- package/src/lib/directives/theme-color/theme-color.directive.ts +117 -0
- package/src/lib/helpers/color-helper.styles.ts +193 -0
- package/src/lib/helpers/color-helper.ts +1 -0
- package/src/lib/helpers/deep-copy.ts +13 -0
- package/src/lib/helpers/design-token-helper.styles.ts +78 -0
- package/src/lib/helpers/design-token-helper.ts +6 -0
- package/src/lib/helpers/element-has-ancestor.ts +28 -0
- package/src/lib/helpers/index.ts +8 -0
- package/src/lib/helpers/line-clamp-helper.ts +28 -0
- package/src/lib/helpers/merge-deep.spec.ts +11 -0
- package/src/lib/helpers/merge-deep.ts +41 -0
- package/src/lib/helpers/platform.service.ts +22 -0
- package/src/lib/helpers/string-helper.ts +6 -0
- package/src/lib/helpers/theme-color.type.ts +1 -0
- package/src/lib/helpers/unique-id-generator.helper.spec.ts +58 -0
- package/src/lib/helpers/unique-id-generator.helper.ts +19 -0
- package/src/lib/icons/svg/QR.svg +7 -0
- package/src/lib/icons/svg/accounts-outline.svg +9 -0
- package/src/lib/icons/svg/accounts.svg +9 -0
- package/src/lib/icons/svg/add.svg +7 -0
- package/src/lib/icons/svg/arrow-back.svg +7 -0
- package/src/lib/icons/svg/arrow-down.svg +7 -0
- package/src/lib/icons/svg/arrow-more.svg +7 -0
- package/src/lib/icons/svg/arrow-up.svg +7 -0
- package/src/lib/icons/svg/attach.svg +7 -0
- package/src/lib/icons/svg/backspace.svg +9 -0
- package/src/lib/icons/svg/calendar.svg +7 -0
- package/src/lib/icons/svg/camera.svg +9 -0
- package/src/lib/icons/svg/checkbox-outline.svg +7 -0
- package/src/lib/icons/svg/checkbox.svg +7 -0
- package/src/lib/icons/svg/checkmark-selected.svg +3 -0
- package/src/lib/icons/svg/clock.svg +7 -0
- package/src/lib/icons/svg/close.svg +7 -0
- package/src/lib/icons/svg/cog.svg +7 -0
- package/src/lib/icons/svg/copy.svg +9 -0
- package/src/lib/icons/svg/edit.svg +7 -0
- package/src/lib/icons/svg/filter.svg +7 -0
- package/src/lib/icons/svg/flag.svg +9 -0
- package/src/lib/icons/svg/flash-off.svg +7 -0
- package/src/lib/icons/svg/flash.svg +7 -0
- package/src/lib/icons/svg/foreign-payment.svg +7 -0
- package/src/lib/icons/svg/help.svg +7 -0
- package/src/lib/icons/svg/home.svg +5 -0
- package/src/lib/icons/svg/inbox-outline.svg +9 -0
- package/src/lib/icons/svg/inbox.svg +9 -0
- package/src/lib/icons/svg/information.svg +9 -0
- package/src/lib/icons/svg/investment.svg +5 -0
- package/src/lib/icons/svg/kirby.svg +3 -0
- package/src/lib/icons/svg/link.svg +7 -0
- package/src/lib/icons/svg/log-out.svg +7 -0
- package/src/lib/icons/svg/menu-outline.svg +9 -0
- package/src/lib/icons/svg/menu.svg +9 -0
- package/src/lib/icons/svg/misc.svg +5 -0
- package/src/lib/icons/svg/moneybag.svg +7 -0
- package/src/lib/icons/svg/more.svg +5 -0
- package/src/lib/icons/svg/move.svg +7 -0
- package/src/lib/icons/svg/payment-card.svg +6 -0
- package/src/lib/icons/svg/pension.svg +7 -0
- package/src/lib/icons/svg/person-outline.svg +9 -0
- package/src/lib/icons/svg/person.svg +9 -0
- package/src/lib/icons/svg/remove.svg +6 -0
- package/src/lib/icons/svg/reorder.svg +9 -0
- package/src/lib/icons/svg/search.svg +7 -0
- package/src/lib/icons/svg/share.svg +7 -0
- package/src/lib/icons/svg/sort.svg +7 -0
- package/src/lib/icons/svg/support.svg +9 -0
- package/src/lib/icons/svg/swap.svg +7 -0
- package/src/lib/icons/svg/trash.svg +7 -0
- package/src/lib/icons/svg/unsubscribe.svg +7 -0
- package/src/lib/icons/svg/verify.svg +7 -0
- package/src/lib/icons/svg/warning.svg +7 -0
- package/src/lib/icons/svg/write-message.svg +7 -0
- package/src/lib/index.ts +8 -0
- package/src/lib/kirby.module.spec.ts +20 -0
- package/src/lib/kirby.module.ts +219 -0
- package/src/lib/polyfills/intersection-observer-polyfill-loader.js +14 -0
- package/src/lib/polyfills/intersection-observer-polyfill-loader.min.js +1 -0
- package/src/lib/polyfills/intersection-observer-polyfill.js +2 -0
- package/src/lib/polyfills/intersection-observer-polyfill.min.js +1 -0
- package/src/lib/polyfills/resize-observer-polyfill-loader.js +14 -0
- package/src/lib/polyfills/resize-observer-polyfill-loader.min.js +1 -0
- package/src/lib/polyfills/resize-observer-polyfill.js +2 -0
- package/src/lib/polyfills/resize-observer-polyfill.min.js +1 -0
- package/src/lib/scss/link.spec.ts +47 -0
- package/src/lib/scss/scss-helper.ts +8 -0
- package/src/lib/scss/typography.spec.ts +241 -0
- package/src/lib/testing/element-css-custom-matchers.d.ts +7 -0
- package/src/lib/testing/element-css-custom-matchers.ts +139 -0
- package/src/lib/testing/styles.scss +13 -0
- package/src/lib/testing/test-helper.ts +158 -0
- package/src/lib/types/index.ts +1 -0
- package/src/lib/types/window-ref.ts +10 -0
- package/src/test.ts +34 -0
- package/src/typings.test.d.ts +1 -0
- package/testing-base/ng-package.json +3 -0
- package/testing-base/src/lib/components/index.ts +66 -0
- package/testing-base/src/lib/components/mock.accordion-item.component.ts +21 -0
- package/testing-base/src/lib/components/mock.action-sheet.component.ts +27 -0
- package/testing-base/src/lib/components/mock.app.component.ts +18 -0
- package/testing-base/src/lib/components/mock.avatar.component.ts +38 -0
- package/testing-base/src/lib/components/mock.badge.component.ts +20 -0
- package/testing-base/src/lib/components/mock.button.component.ts +26 -0
- package/testing-base/src/lib/components/mock.calendar.component.ts +36 -0
- package/testing-base/src/lib/components/mock.card-footer.component.ts +18 -0
- package/testing-base/src/lib/components/mock.card-header.component.ts +23 -0
- package/testing-base/src/lib/components/mock.card.component.ts +25 -0
- package/testing-base/src/lib/components/mock.chart-deprecated.component.ts +28 -0
- package/testing-base/src/lib/components/mock.chart.component.ts +36 -0
- package/testing-base/src/lib/components/mock.checkbox.component.ts +26 -0
- package/testing-base/src/lib/components/mock.chip.component.ts +21 -0
- package/testing-base/src/lib/components/mock.divider.component.ts +20 -0
- package/testing-base/src/lib/components/mock.dropdown.component.ts +32 -0
- package/testing-base/src/lib/components/mock.empty-state.component.ts +23 -0
- package/testing-base/src/lib/components/mock.fab-sheet.component.ts +21 -0
- package/testing-base/src/lib/components/mock.flag.component.ts +21 -0
- package/testing-base/src/lib/components/mock.form-field-message.component.ts +21 -0
- package/testing-base/src/lib/components/mock.form-field.component.ts +23 -0
- package/testing-base/src/lib/components/mock.grid.component.ts +21 -0
- package/testing-base/src/lib/components/mock.icon.component.ts +22 -0
- package/testing-base/src/lib/components/mock.input-counter.component.ts +24 -0
- package/testing-base/src/lib/components/mock.input.component.ts +29 -0
- package/testing-base/src/lib/components/mock.item-group.component.ts +18 -0
- package/testing-base/src/lib/components/mock.item-sliding.component.ts +21 -0
- package/testing-base/src/lib/components/mock.item.component.ts +24 -0
- package/testing-base/src/lib/components/mock.label.component.ts +20 -0
- package/testing-base/src/lib/components/mock.list-experimental.component.ts +18 -0
- package/testing-base/src/lib/components/mock.list-header.component.ts +18 -0
- package/testing-base/src/lib/components/mock.list-item.component.ts +33 -0
- package/testing-base/src/lib/components/mock.list-section-header.component.ts +20 -0
- package/testing-base/src/lib/components/mock.list.component.ts +39 -0
- package/testing-base/src/lib/components/mock.loading-overlay.component.ts +21 -0
- package/testing-base/src/lib/components/mock.modal-footer.component.ts +21 -0
- package/testing-base/src/lib/components/mock.page-footer.component.ts +20 -0
- package/testing-base/src/lib/components/mock.page.component.ts +152 -0
- package/testing-base/src/lib/components/mock.popover.component.ts +22 -0
- package/testing-base/src/lib/components/mock.progress-circle.component.ts +22 -0
- package/testing-base/src/lib/components/mock.radio-group.component.ts +27 -0
- package/testing-base/src/lib/components/mock.radio.component.ts +23 -0
- package/testing-base/src/lib/components/mock.range.component.ts +35 -0
- package/testing-base/src/lib/components/mock.reorder-list.component.ts +25 -0
- package/testing-base/src/lib/components/mock.router-outlet.component.ts +20 -0
- package/testing-base/src/lib/components/mock.section-header.component.ts +18 -0
- package/testing-base/src/lib/components/mock.segmented-control.component.ts +29 -0
- package/testing-base/src/lib/components/mock.slide-button.component.ts +23 -0
- package/testing-base/src/lib/components/mock.slides.component.ts +29 -0
- package/testing-base/src/lib/components/mock.spinner.component.ts +18 -0
- package/testing-base/src/lib/components/mock.tab-button.component.ts +21 -0
- package/testing-base/src/lib/components/mock.tabs.component.ts +18 -0
- package/testing-base/src/lib/components/mock.textarea.component.ts +26 -0
- package/testing-base/src/lib/components/mock.toggle-button.component.ts +21 -0
- package/testing-base/src/lib/components/mock.toggle.component.ts +22 -0
- package/testing-base/src/lib/components/mock.web-component-proxies.component.ts +32 -0
- package/testing-base/src/lib/directives/index.ts +3 -0
- package/testing-base/src/lib/directives/mock.accordion.directive.ts +15 -0
- package/testing-base/src/lib/directives/mock.fit-heading.directive.ts +19 -0
- package/testing-base/src/lib/directives/mock.theme-color.directive.ts +19 -0
- package/testing-base/src/lib/index.ts +4 -0
- package/testing-base/src/lib/kirby-testing-base.module.ts +10 -0
- package/testing-base/src/lib/mock-components.ts +133 -0
- package/testing-base/src/lib/mock-directives.ts +9 -0
- package/testing-base/src/public_api.ts +1 -0
- package/testing-base/src/tsconfig.json +9 -0
- package/testing-jasmine/ng-package.json +3 -0
- package/testing-jasmine/src/lib/kirby-testing.module.ts +14 -0
- package/testing-jasmine/src/lib/mock-providers.ts +68 -0
- package/testing-jasmine/src/public_api.ts +1 -0
- package/testing-jasmine/src/tsconfig.json +10 -0
- package/testing-jest/ng-package.json +3 -0
- package/testing-jest/src/lib/kirby-testing.module.ts +14 -0
- package/testing-jest/src/lib/mock-providers.ts +76 -0
- package/testing-jest/src/public_api.ts +1 -0
- package/testing-jest/src/tsconfig.json +10 -0
- package/tsconfig.json +17 -0
- package/tsconfig.lib.json +23 -0
- package/tsconfig.spec.json +9 -0
- package/tslint.json +10 -0
|
@@ -0,0 +1,1215 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { fakeAsync, tick } from '@angular/core/testing';
|
|
3
|
+
import { IonItem } from '@ionic/angular';
|
|
4
|
+
import { createHostFactory, Spectator, SpectatorHost } from '@ngneat/spectator';
|
|
5
|
+
import { MockComponents } from 'ng-mocks';
|
|
6
|
+
|
|
7
|
+
import { DesignTokenHelper } from '@kirbydesign/core';
|
|
8
|
+
|
|
9
|
+
import { ButtonComponent, CardComponent, IconComponent, ItemComponent } from '..';
|
|
10
|
+
import { TestHelper } from '../../testing/test-helper';
|
|
11
|
+
import { ListItemTemplateDirective } from '../list';
|
|
12
|
+
import { HorizontalDirection, PopoverComponent } from '../popover/popover.component';
|
|
13
|
+
|
|
14
|
+
import { DropdownComponent } from './dropdown.component';
|
|
15
|
+
import { OpenState } from './dropdown.types';
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
template: '<ng-content></ng-content>',
|
|
19
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
20
|
+
})
|
|
21
|
+
class OnPushHostComponent {}
|
|
22
|
+
|
|
23
|
+
describe('DropdownComponent', () => {
|
|
24
|
+
const items = [
|
|
25
|
+
{ text: 'Item 1', value: 1 },
|
|
26
|
+
{ text: 'Item 2', value: 2 },
|
|
27
|
+
{ text: 'Item 3', value: 3 },
|
|
28
|
+
{ text: 'Item 4', value: 4 },
|
|
29
|
+
{ text: 'Item 5', value: 5 },
|
|
30
|
+
];
|
|
31
|
+
const openDelayInMs = DropdownComponent.OPEN_DELAY_IN_MS;
|
|
32
|
+
|
|
33
|
+
describe('by default', () => {
|
|
34
|
+
const createHost = createHostFactory({
|
|
35
|
+
component: DropdownComponent,
|
|
36
|
+
declarations: [
|
|
37
|
+
ItemComponent,
|
|
38
|
+
MockComponents(ButtonComponent, CardComponent, IconComponent, IonItem, PopoverComponent),
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
let spectator: Spectator<DropdownComponent>;
|
|
43
|
+
let buttonElement: HTMLButtonElement;
|
|
44
|
+
|
|
45
|
+
beforeEach(() => {
|
|
46
|
+
spectator = createHost(`<kirby-dropdown></kirby-dropdown>`, {
|
|
47
|
+
props: {
|
|
48
|
+
items: items,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
buttonElement = spectator.query('button[kirby-button]');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should create', () => {
|
|
55
|
+
expect(spectator.component).toBeTruthy();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should have popover disabled', () => {
|
|
59
|
+
expect(spectator.component.usePopover).toBeFalse();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should be closed', () => {
|
|
63
|
+
expect(spectator.component.isOpen).toBeFalsy();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should not have value', () => {
|
|
67
|
+
expect(spectator.component.value).toBeNull();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should not have selected text', () => {
|
|
71
|
+
expect(spectator.component.selectedText).toBeNull();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('should have selected index = -1', () => {
|
|
75
|
+
expect(spectator.component.selectedIndex).toEqual(-1);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should have default placeholder text', () => {
|
|
79
|
+
expect(buttonElement).toHaveText(spectator.component.placeholder, true);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should have default popout set', () => {
|
|
83
|
+
expect(spectator.component.popout).toEqual(HorizontalDirection.right);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should render as inline block', () => {
|
|
87
|
+
expect(spectator.element).toHaveComputedStyle({ display: 'inline-block' });
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('should render button with default attentionLevel', () => {
|
|
91
|
+
const button = spectator.query(ButtonComponent);
|
|
92
|
+
expect(button.attentionLevel).toEqual('3');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('should not render disabled attribute', () => {
|
|
96
|
+
expect(spectator.element.attributes['disabled']).toBeUndefined();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('should render no-blur attribute', () => {
|
|
100
|
+
expect(spectator.element.attributes['no-blur']).toBeDefined();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('should not render button as disabled ', () => {
|
|
104
|
+
expect(buttonElement.disabled).toBeFalsy();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should not render disabled attribute on button', () => {
|
|
108
|
+
expect(buttonElement.attributes['disabled']).toBeUndefined();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('should have correct item size', () => {
|
|
112
|
+
const itemElements = spectator.queryAll<HTMLElement>('kirby-item');
|
|
113
|
+
expect(itemElements).toHaveLength(items.length);
|
|
114
|
+
itemElements.forEach((item) => {
|
|
115
|
+
expect(item.querySelector('ion-item')).toHaveComputedStyle({
|
|
116
|
+
'--min-height': DesignTokenHelper.dropdownItemHeight(),
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should receive focus', () => {
|
|
122
|
+
spectator.element.focus();
|
|
123
|
+
expect(spectator.element).toBeFocused();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('should receive focus on button click', () => {
|
|
127
|
+
spectator.click('button');
|
|
128
|
+
expect(spectator.element).toBeFocused();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// Fixes https://github.com/kirbydesign/designsystem/issues/1987
|
|
132
|
+
it('should have type="button" attribute', () => {
|
|
133
|
+
expect(buttonElement).toHaveAttribute('type', 'button');
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe('when setting selected index', () => {
|
|
137
|
+
let onChangeSpy: jasmine.Spy;
|
|
138
|
+
const newSelectedIndex = 2;
|
|
139
|
+
const expectedItem = items[newSelectedIndex];
|
|
140
|
+
const expectedText = expectedItem.text;
|
|
141
|
+
|
|
142
|
+
beforeEach(() => {
|
|
143
|
+
onChangeSpy = spyOn(spectator.component.change, 'emit');
|
|
144
|
+
spectator.setInput('selectedIndex', newSelectedIndex);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('should have correct selected item', () => {
|
|
148
|
+
expect(spectator.component.value).toEqual(expectedItem);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('should have selected text from new selected item', () => {
|
|
152
|
+
expect(spectator.component.selectedText).toEqual(expectedText);
|
|
153
|
+
expect(buttonElement).toHaveText(expectedText, true);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('should not emit change event', () => {
|
|
157
|
+
expect(onChangeSpy).not.toHaveBeenCalled();
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
describe('onItemSelect', () => {
|
|
162
|
+
describe('when no selected index', () => {
|
|
163
|
+
let onChangeSpy: jasmine.Spy;
|
|
164
|
+
const newSelectedIndex = 2;
|
|
165
|
+
const expectedItem = items[newSelectedIndex];
|
|
166
|
+
const expectedText = expectedItem.text;
|
|
167
|
+
|
|
168
|
+
beforeEach(() => {
|
|
169
|
+
onChangeSpy = spyOn(spectator.component.change, 'emit');
|
|
170
|
+
spectator.component.onItemSelect(newSelectedIndex);
|
|
171
|
+
spectator.detectChanges();
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('should have correct new selected index', () => {
|
|
175
|
+
expect(spectator.component.selectedIndex).toEqual(newSelectedIndex);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('should have correct new selected item', () => {
|
|
179
|
+
expect(spectator.component.value).toEqual(expectedItem);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('should have selected text from new selected item', () => {
|
|
183
|
+
expect(spectator.component.selectedText).toEqual(expectedText);
|
|
184
|
+
expect(buttonElement).toHaveText(expectedText, true);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('should emit change event with new selected item', () => {
|
|
188
|
+
expect(onChangeSpy).toHaveBeenCalledTimes(1);
|
|
189
|
+
expect(onChangeSpy).toHaveBeenCalledWith(expectedItem);
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
describe('when having selected index', () => {
|
|
194
|
+
let onChangeSpy: jasmine.Spy;
|
|
195
|
+
|
|
196
|
+
beforeEach(() => {
|
|
197
|
+
spectator.setInput('selectedIndex', 2);
|
|
198
|
+
onChangeSpy = spyOn(spectator.component.change, 'emit');
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
describe('and called with a selected index >= 0', () => {
|
|
202
|
+
const newSelectedIndex = 4;
|
|
203
|
+
const expectedItem = items[newSelectedIndex];
|
|
204
|
+
const expectedText = expectedItem.text;
|
|
205
|
+
|
|
206
|
+
beforeEach(() => {
|
|
207
|
+
spectator.component.onItemSelect(newSelectedIndex);
|
|
208
|
+
spectator.detectChanges();
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it('should have correct new selected index', () => {
|
|
212
|
+
expect(spectator.component.selectedIndex).toEqual(newSelectedIndex);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('should have correct new selected item', () => {
|
|
216
|
+
expect(spectator.component.value).toEqual(expectedItem);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('should have selected text from new selected item', () => {
|
|
220
|
+
expect(spectator.component.selectedText).toEqual(expectedText);
|
|
221
|
+
expect(buttonElement).toHaveText(expectedText, true);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('should emit change event with new selected item', () => {
|
|
225
|
+
expect(onChangeSpy).toHaveBeenCalledTimes(1);
|
|
226
|
+
expect(onChangeSpy).toHaveBeenCalledWith(expectedItem);
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe('and called with selected index = -1', () => {
|
|
231
|
+
const newSelectedIndex = -1;
|
|
232
|
+
|
|
233
|
+
beforeEach(() => {
|
|
234
|
+
spectator.component.onItemSelect(newSelectedIndex);
|
|
235
|
+
spectator.detectChanges();
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it('should have correct new selected index', () => {
|
|
239
|
+
expect(spectator.component.selectedIndex).toEqual(newSelectedIndex);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('should not have a selected item', () => {
|
|
243
|
+
expect(spectator.component.value).toBeNull();
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('should not have selected text', () => {
|
|
247
|
+
expect(spectator.component.selectedText).toBeNull();
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it('should have default placeholder text', () => {
|
|
251
|
+
expect(buttonElement).toHaveText(spectator.component.placeholder, true);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it('should emit change event with no selected item', () => {
|
|
255
|
+
expect(onChangeSpy).toHaveBeenCalledTimes(1);
|
|
256
|
+
expect(onChangeSpy).toHaveBeenCalledWith(null);
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
describe('when configured with attentionLevel', () => {
|
|
263
|
+
it('should render button with correct attentionLevel', () => {
|
|
264
|
+
spectator.component.attentionLevel = '1';
|
|
265
|
+
spectator.detectChanges();
|
|
266
|
+
const button = spectator.query(ButtonComponent);
|
|
267
|
+
expect(button.attentionLevel).toEqual('1');
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
describe('when configured with popout direction', () => {
|
|
272
|
+
it('open card to the right when popout=right', () => {
|
|
273
|
+
spectator.component.popout = HorizontalDirection.right;
|
|
274
|
+
spectator.component['state'] = OpenState.open;
|
|
275
|
+
spectator.detectChanges();
|
|
276
|
+
|
|
277
|
+
const buttonRect = buttonElement.getBoundingClientRect();
|
|
278
|
+
const card = spectator.query('kirby-card');
|
|
279
|
+
const cardRect = card.getBoundingClientRect();
|
|
280
|
+
|
|
281
|
+
expect(cardRect.left).toEqual(buttonRect.left);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
it('open card to the left when popout=left', () => {
|
|
285
|
+
spectator.component.popout = HorizontalDirection.left;
|
|
286
|
+
spectator.element.style.cssFloat = 'right';
|
|
287
|
+
spectator.component['state'] = OpenState.open;
|
|
288
|
+
spectator.detectChanges();
|
|
289
|
+
|
|
290
|
+
const card = spectator.query('kirby-card');
|
|
291
|
+
const buttonRect = buttonElement.getBoundingClientRect();
|
|
292
|
+
const cardRect = card.getBoundingClientRect();
|
|
293
|
+
|
|
294
|
+
expect(cardRect.right).toEqual(buttonRect.right);
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
describe('when configured with expand=block', () => {
|
|
299
|
+
beforeEach(() => {
|
|
300
|
+
spectator.component.expand = 'block';
|
|
301
|
+
spectator.detectChanges();
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it('should render as block level', () => {
|
|
305
|
+
expect(spectator.element).toHaveComputedStyle({ display: 'block' });
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it('should render button with full width', () => {
|
|
309
|
+
const componentWidth = spectator.element.clientWidth;
|
|
310
|
+
const buttonWidth = buttonElement.getBoundingClientRect().width;
|
|
311
|
+
expect(buttonWidth).toEqual(componentWidth);
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
it('should render dropdown with full width', () => {
|
|
315
|
+
spectator.component['state'] = OpenState.open;
|
|
316
|
+
spectator.detectChanges();
|
|
317
|
+
const card = spectator.query('kirby-card');
|
|
318
|
+
const componentWidth = spectator.element.clientWidth;
|
|
319
|
+
const cardWidth = card.getBoundingClientRect().width;
|
|
320
|
+
expect(cardWidth).toEqual(componentWidth);
|
|
321
|
+
expect(card).toHaveComputedStyle({ 'min-width': '0px', 'max-width': 'none' });
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
describe('when closed', () => {
|
|
326
|
+
beforeEach(() => {
|
|
327
|
+
spectator.component['state'] = OpenState.closed;
|
|
328
|
+
spectator.detectChanges();
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it('should have correct icon', () => {
|
|
332
|
+
const icon = spectator.query<IconComponent>(IconComponent);
|
|
333
|
+
expect(icon.name).toEqual('arrow-down');
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
describe('and button is clicked', () => {
|
|
337
|
+
it('should open and focus dropdown', fakeAsync(() => {
|
|
338
|
+
spectator.click('button');
|
|
339
|
+
tick(openDelayInMs);
|
|
340
|
+
expect(spectator.component.isOpen).toBeTruthy();
|
|
341
|
+
expect(spectator.element).toBeFocused();
|
|
342
|
+
}));
|
|
343
|
+
|
|
344
|
+
it('should open dropdown within actual delay', async () => {
|
|
345
|
+
spectator.click('button');
|
|
346
|
+
await TestHelper.whenTrue(() => spectator.component.isOpen, openDelayInMs);
|
|
347
|
+
expect(spectator.component.isOpen).toBeTruthy();
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
describe('and Space key is pressed', () => {
|
|
352
|
+
beforeEach(fakeAsync(() => {
|
|
353
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', 'Space');
|
|
354
|
+
tick(openDelayInMs);
|
|
355
|
+
}));
|
|
356
|
+
it('should open dropdown', () => {
|
|
357
|
+
expect(spectator.component.isOpen).toBeTruthy();
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
describe('and Enter key is pressed', () => {
|
|
362
|
+
beforeEach(fakeAsync(() => {
|
|
363
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', 'Enter');
|
|
364
|
+
tick(openDelayInMs);
|
|
365
|
+
}));
|
|
366
|
+
it('should open dropdown', () => {
|
|
367
|
+
expect(spectator.component.isOpen).toBeTruthy();
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
describe('and first item is selected', () => {
|
|
372
|
+
beforeEach(() => {
|
|
373
|
+
spectator.setInput('selectedIndex', 0);
|
|
374
|
+
spectator.detectChanges();
|
|
375
|
+
});
|
|
376
|
+
describe('and ArrowLeft key is pressed', () => {
|
|
377
|
+
it('should not change selected item', () => {
|
|
378
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', 'ArrowLeft');
|
|
379
|
+
expect(spectator.component.selectedIndex).toEqual(0);
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
describe('and ArrowUp key is pressed', () => {
|
|
383
|
+
it('should not change selected item', () => {
|
|
384
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', 'ArrowUp');
|
|
385
|
+
expect(spectator.component.selectedIndex).toEqual(0);
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
describe('and Home key is pressed', () => {
|
|
389
|
+
it('should not change selected item', () => {
|
|
390
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', 'Home');
|
|
391
|
+
expect(spectator.component.selectedIndex).toEqual(0);
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
describe('and last item is selected', () => {
|
|
397
|
+
const lastIndex = 4;
|
|
398
|
+
beforeEach(() => {
|
|
399
|
+
spectator.setInput('selectedIndex', lastIndex);
|
|
400
|
+
spectator.detectChanges();
|
|
401
|
+
});
|
|
402
|
+
describe('and ArrowRight key is pressed', () => {
|
|
403
|
+
it('should not change selected item', () => {
|
|
404
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', 'ArrowRight');
|
|
405
|
+
expect(spectator.component.selectedIndex).toEqual(lastIndex);
|
|
406
|
+
});
|
|
407
|
+
});
|
|
408
|
+
describe('and ArrowDown key is pressed', () => {
|
|
409
|
+
it('should not change selected item', () => {
|
|
410
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', 'ArrowDown');
|
|
411
|
+
expect(spectator.component.selectedIndex).toEqual(lastIndex);
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
describe('and End key is pressed', () => {
|
|
415
|
+
it('should not change selected item', () => {
|
|
416
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', 'End');
|
|
417
|
+
expect(spectator.component.selectedIndex).toEqual(lastIndex);
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
const testMatrix = [
|
|
423
|
+
{
|
|
424
|
+
key: 'ArrowLeft',
|
|
425
|
+
scenario: [
|
|
426
|
+
{
|
|
427
|
+
selectedIndex: 1,
|
|
428
|
+
keypressCount: 1,
|
|
429
|
+
expectedIndex: 0,
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
selectedIndex: 2,
|
|
433
|
+
keypressCount: 1,
|
|
434
|
+
expectedIndex: 1,
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
selectedIndex: 2,
|
|
438
|
+
keypressCount: 2,
|
|
439
|
+
expectedIndex: 0,
|
|
440
|
+
},
|
|
441
|
+
],
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
key: 'ArrowUp',
|
|
445
|
+
scenario: [
|
|
446
|
+
{
|
|
447
|
+
selectedIndex: 1,
|
|
448
|
+
keypressCount: 1,
|
|
449
|
+
expectedIndex: 0,
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
selectedIndex: 2,
|
|
453
|
+
keypressCount: 1,
|
|
454
|
+
expectedIndex: 1,
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
selectedIndex: 2,
|
|
458
|
+
keypressCount: 2,
|
|
459
|
+
expectedIndex: 0,
|
|
460
|
+
},
|
|
461
|
+
],
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
key: 'ArrowRight',
|
|
465
|
+
scenario: [
|
|
466
|
+
{
|
|
467
|
+
selectedIndex: 0,
|
|
468
|
+
keypressCount: 1,
|
|
469
|
+
expectedIndex: 1,
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
selectedIndex: 0,
|
|
473
|
+
keypressCount: 2,
|
|
474
|
+
expectedIndex: 2,
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
selectedIndex: 1,
|
|
478
|
+
keypressCount: 1,
|
|
479
|
+
expectedIndex: 2,
|
|
480
|
+
},
|
|
481
|
+
],
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
key: 'ArrowDown',
|
|
485
|
+
scenario: [
|
|
486
|
+
{
|
|
487
|
+
selectedIndex: 0,
|
|
488
|
+
keypressCount: 1,
|
|
489
|
+
expectedIndex: 1,
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
selectedIndex: 0,
|
|
493
|
+
keypressCount: 2,
|
|
494
|
+
expectedIndex: 2,
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
selectedIndex: 1,
|
|
498
|
+
keypressCount: 1,
|
|
499
|
+
expectedIndex: 2,
|
|
500
|
+
},
|
|
501
|
+
],
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
key: 'Home',
|
|
505
|
+
scenario: [
|
|
506
|
+
{
|
|
507
|
+
selectedIndex: 1,
|
|
508
|
+
keypressCount: 1,
|
|
509
|
+
expectedIndex: 0,
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
selectedIndex: 2,
|
|
513
|
+
keypressCount: 1,
|
|
514
|
+
expectedIndex: 0,
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
selectedIndex: 4,
|
|
518
|
+
keypressCount: 1,
|
|
519
|
+
expectedIndex: 0,
|
|
520
|
+
},
|
|
521
|
+
],
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
key: 'End',
|
|
525
|
+
scenario: [
|
|
526
|
+
{
|
|
527
|
+
selectedIndex: 0,
|
|
528
|
+
keypressCount: 1,
|
|
529
|
+
expectedIndex: 4,
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
selectedIndex: 1,
|
|
533
|
+
keypressCount: 1,
|
|
534
|
+
expectedIndex: 4,
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
selectedIndex: 2,
|
|
538
|
+
keypressCount: 1,
|
|
539
|
+
expectedIndex: 4,
|
|
540
|
+
},
|
|
541
|
+
],
|
|
542
|
+
},
|
|
543
|
+
];
|
|
544
|
+
|
|
545
|
+
testMatrix.forEach((keyEvent) => {
|
|
546
|
+
keyEvent.scenario.forEach((scenario) => {
|
|
547
|
+
describe(`and selected item = ${scenario.selectedIndex} and ${keyEvent.key} key is pressed ${scenario.keypressCount} time(s)`, () => {
|
|
548
|
+
it(`should set selected item = ${scenario.expectedIndex}`, () => {
|
|
549
|
+
spectator.setInput('selectedIndex', scenario.selectedIndex);
|
|
550
|
+
for (let counter = 0; counter < scenario.keypressCount; counter++) {
|
|
551
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', keyEvent.key);
|
|
552
|
+
}
|
|
553
|
+
expect(spectator.component.selectedIndex).toEqual(scenario.expectedIndex);
|
|
554
|
+
expect(spectator.component.value).toEqual(items[scenario.expectedIndex]);
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
});
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
describe('when open', () => {
|
|
562
|
+
beforeEach(() => {
|
|
563
|
+
spectator.component['state'] = OpenState.open;
|
|
564
|
+
spectator.detectChanges();
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
it('should have correct icon', () => {
|
|
568
|
+
const icon = spectator.query<IconComponent>(IconComponent);
|
|
569
|
+
expect(icon.name).toEqual('arrow-up');
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
describe('and button is clicked', () => {
|
|
573
|
+
beforeEach(() => {
|
|
574
|
+
spectator.click('button');
|
|
575
|
+
spectator.detectChanges();
|
|
576
|
+
});
|
|
577
|
+
it('should close dropdown', () => {
|
|
578
|
+
expect(spectator.component.isOpen).toBeFalsy();
|
|
579
|
+
});
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
describe('and Space key is pressed', () => {
|
|
583
|
+
it('should not close dropdown', () => {
|
|
584
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', 'Space');
|
|
585
|
+
expect(spectator.component.isOpen).toBeTruthy();
|
|
586
|
+
});
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
describe('and Enter key is pressed', () => {
|
|
590
|
+
it('should close dropdown', () => {
|
|
591
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', 'Enter');
|
|
592
|
+
expect(spectator.component.isOpen).toBeFalsy();
|
|
593
|
+
});
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
describe('and Escape key is pressed', () => {
|
|
597
|
+
it('should close dropdown', () => {
|
|
598
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', 'Escape');
|
|
599
|
+
expect(spectator.component.isOpen).toBeFalsy();
|
|
600
|
+
});
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
describe('and Tab key is pressed', () => {
|
|
604
|
+
it('should close dropdown', () => {
|
|
605
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', 'Tab');
|
|
606
|
+
expect(spectator.component.isOpen).toBeFalsy();
|
|
607
|
+
});
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
describe('and looses focus', () => {
|
|
611
|
+
it('should close dropdown', () => {
|
|
612
|
+
spectator.dispatchFakeEvent(spectator.element, 'blur');
|
|
613
|
+
expect(spectator.component.isOpen).toBeFalsy();
|
|
614
|
+
});
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
describe('and ArrowLeft key is pressed', () => {
|
|
618
|
+
it('should not change selected item', () => {
|
|
619
|
+
spectator.setInput('selectedIndex', 2);
|
|
620
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', 'ArrowLeft');
|
|
621
|
+
expect(spectator.component.selectedIndex).toEqual(2);
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
describe('and ArrowRight key is pressed', () => {
|
|
625
|
+
it('should not change selected item', () => {
|
|
626
|
+
spectator.setInput('selectedIndex', 2);
|
|
627
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', 'ArrowRight');
|
|
628
|
+
expect(spectator.component.selectedIndex).toEqual(2);
|
|
629
|
+
});
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
describe('and first item is selected', () => {
|
|
633
|
+
beforeEach(() => {
|
|
634
|
+
spectator.setInput('selectedIndex', 0);
|
|
635
|
+
spectator.detectChanges();
|
|
636
|
+
});
|
|
637
|
+
describe('and ArrowLeft key is pressed', () => {
|
|
638
|
+
it('should not change selected item', () => {
|
|
639
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', 'ArrowLeft');
|
|
640
|
+
expect(spectator.component.selectedIndex).toEqual(0);
|
|
641
|
+
});
|
|
642
|
+
});
|
|
643
|
+
describe('and Home key is pressed', () => {
|
|
644
|
+
it('should not change selected item', () => {
|
|
645
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', 'Home');
|
|
646
|
+
expect(spectator.component.selectedIndex).toEqual(0);
|
|
647
|
+
});
|
|
648
|
+
});
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
const testMatrix = [
|
|
652
|
+
{
|
|
653
|
+
key: 'ArrowUp',
|
|
654
|
+
scenario: [
|
|
655
|
+
{
|
|
656
|
+
selectedIndex: 1,
|
|
657
|
+
keypressCount: 1,
|
|
658
|
+
expectedIndex: 0,
|
|
659
|
+
},
|
|
660
|
+
{
|
|
661
|
+
selectedIndex: 2,
|
|
662
|
+
keypressCount: 1,
|
|
663
|
+
expectedIndex: 1,
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
selectedIndex: 2,
|
|
667
|
+
keypressCount: 2,
|
|
668
|
+
expectedIndex: 0,
|
|
669
|
+
},
|
|
670
|
+
],
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
key: 'ArrowDown',
|
|
674
|
+
scenario: [
|
|
675
|
+
{
|
|
676
|
+
selectedIndex: 0,
|
|
677
|
+
keypressCount: 1,
|
|
678
|
+
expectedIndex: 1,
|
|
679
|
+
},
|
|
680
|
+
{
|
|
681
|
+
selectedIndex: 0,
|
|
682
|
+
keypressCount: 2,
|
|
683
|
+
expectedIndex: 2,
|
|
684
|
+
},
|
|
685
|
+
{
|
|
686
|
+
selectedIndex: 1,
|
|
687
|
+
keypressCount: 1,
|
|
688
|
+
expectedIndex: 2,
|
|
689
|
+
},
|
|
690
|
+
],
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
key: 'Home',
|
|
694
|
+
scenario: [
|
|
695
|
+
{
|
|
696
|
+
selectedIndex: 1,
|
|
697
|
+
keypressCount: 1,
|
|
698
|
+
expectedIndex: 0,
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
selectedIndex: 2,
|
|
702
|
+
keypressCount: 1,
|
|
703
|
+
expectedIndex: 0,
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
selectedIndex: 4,
|
|
707
|
+
keypressCount: 1,
|
|
708
|
+
expectedIndex: 0,
|
|
709
|
+
},
|
|
710
|
+
],
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
key: 'End',
|
|
714
|
+
scenario: [
|
|
715
|
+
{
|
|
716
|
+
selectedIndex: 0,
|
|
717
|
+
keypressCount: 1,
|
|
718
|
+
expectedIndex: 4,
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
selectedIndex: 1,
|
|
722
|
+
keypressCount: 1,
|
|
723
|
+
expectedIndex: 4,
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
selectedIndex: 2,
|
|
727
|
+
keypressCount: 1,
|
|
728
|
+
expectedIndex: 4,
|
|
729
|
+
},
|
|
730
|
+
],
|
|
731
|
+
},
|
|
732
|
+
];
|
|
733
|
+
|
|
734
|
+
testMatrix.forEach((keyEvent) => {
|
|
735
|
+
keyEvent.scenario.forEach((scenario) => {
|
|
736
|
+
describe(`and selected item = ${scenario.selectedIndex} and ${keyEvent.key} key is pressed ${scenario.keypressCount} time(s)`, () => {
|
|
737
|
+
it(`should set selected item = ${scenario.expectedIndex}`, () => {
|
|
738
|
+
spectator.setInput('selectedIndex', scenario.selectedIndex);
|
|
739
|
+
for (let counter = 0; counter < scenario.keypressCount; counter++) {
|
|
740
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', keyEvent.key);
|
|
741
|
+
}
|
|
742
|
+
expect(spectator.component.selectedIndex).toEqual(scenario.expectedIndex);
|
|
743
|
+
expect(spectator.component.value).toEqual(items[scenario.expectedIndex]);
|
|
744
|
+
});
|
|
745
|
+
});
|
|
746
|
+
});
|
|
747
|
+
});
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
describe('when aligned to right side of viewport', () => {
|
|
751
|
+
it('should align the dropdown to the right side of button and component container ', (done) => {
|
|
752
|
+
spectator.element.style.cssFloat = 'right';
|
|
753
|
+
spectator.component.open();
|
|
754
|
+
spectator.detectChanges();
|
|
755
|
+
setTimeout(() => {
|
|
756
|
+
spectator.detectChanges();
|
|
757
|
+
const card = spectator.query('kirby-card');
|
|
758
|
+
expect(card).toHaveComputedStyle({ right: '0px' });
|
|
759
|
+
done();
|
|
760
|
+
}, openDelayInMs);
|
|
761
|
+
});
|
|
762
|
+
});
|
|
763
|
+
|
|
764
|
+
describe('when disabled', () => {
|
|
765
|
+
beforeEach(() => {
|
|
766
|
+
spectator.component.disabled = true;
|
|
767
|
+
spectator.detectChanges();
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
it('should render disabled attribute', () => {
|
|
771
|
+
expect(spectator.element.attributes['disabled']).toBeDefined();
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
it('should render button as disabled ', () => {
|
|
775
|
+
expect(buttonElement.disabled).toBeTruthy();
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
it('should render disabled attribute on button', () => {
|
|
779
|
+
expect(buttonElement.attributes['disabled']).toBeDefined();
|
|
780
|
+
});
|
|
781
|
+
|
|
782
|
+
it('should not open', fakeAsync(() => {
|
|
783
|
+
spectator.component.open();
|
|
784
|
+
tick(openDelayInMs);
|
|
785
|
+
expect(spectator.component.isOpen).toBeFalsy();
|
|
786
|
+
}));
|
|
787
|
+
|
|
788
|
+
it('should not toggle', fakeAsync(() => {
|
|
789
|
+
spectator.component.toggle();
|
|
790
|
+
tick(openDelayInMs);
|
|
791
|
+
expect(spectator.component.isOpen).toBeFalsy();
|
|
792
|
+
}));
|
|
793
|
+
|
|
794
|
+
it('should not recieve focus on button click', () => {
|
|
795
|
+
spectator.click('button');
|
|
796
|
+
spectator.detectChanges();
|
|
797
|
+
expect(spectator.element).not.toBeFocused();
|
|
798
|
+
});
|
|
799
|
+
|
|
800
|
+
describe('on keypress', () => {
|
|
801
|
+
const selectedIndex = 2;
|
|
802
|
+
const expectedItem = items[selectedIndex];
|
|
803
|
+
let onChangeSpy: jasmine.Spy;
|
|
804
|
+
const keys = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Home', 'End'];
|
|
805
|
+
|
|
806
|
+
beforeEach(() => {
|
|
807
|
+
onChangeSpy = spyOn(spectator.component.change, 'emit');
|
|
808
|
+
spectator.setInput('selectedIndex', selectedIndex);
|
|
809
|
+
spectator.detectChanges();
|
|
810
|
+
});
|
|
811
|
+
|
|
812
|
+
it('should not open dropdown when Space key is pressed', fakeAsync(() => {
|
|
813
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', 'Space');
|
|
814
|
+
tick(openDelayInMs);
|
|
815
|
+
expect(spectator.component.isOpen).toBeFalsy();
|
|
816
|
+
}));
|
|
817
|
+
|
|
818
|
+
it('should not open dropdown when Enter key is pressed', fakeAsync(() => {
|
|
819
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', 'Enter');
|
|
820
|
+
tick(openDelayInMs);
|
|
821
|
+
expect(spectator.component.isOpen).toBeFalsy();
|
|
822
|
+
}));
|
|
823
|
+
|
|
824
|
+
keys.forEach((key) => {
|
|
825
|
+
it(`should not change selected item when ${key} key is pressed`, () => {
|
|
826
|
+
spectator.dispatchKeyboardEvent(spectator.element, 'keydown', key);
|
|
827
|
+
expect(spectator.component.selectedIndex).toEqual(selectedIndex);
|
|
828
|
+
expect(spectator.component.value).toEqual(expectedItem);
|
|
829
|
+
expect(onChangeSpy).not.toHaveBeenCalled();
|
|
830
|
+
});
|
|
831
|
+
});
|
|
832
|
+
});
|
|
833
|
+
});
|
|
834
|
+
|
|
835
|
+
describe('implementing ControlValueAccessor interface', () => {
|
|
836
|
+
describe('when writeValue() function is invoked', () => {
|
|
837
|
+
it('should select the item', () => {
|
|
838
|
+
const selectedIndex = 2;
|
|
839
|
+
const expectedItem = items[selectedIndex];
|
|
840
|
+
spectator.component.writeValue(expectedItem);
|
|
841
|
+
expect(spectator.component.selectedIndex).toEqual(selectedIndex);
|
|
842
|
+
expect(spectator.component.value).toEqual(expectedItem);
|
|
843
|
+
});
|
|
844
|
+
|
|
845
|
+
it('should not emit change event', () => {
|
|
846
|
+
const onChangeSpy = spyOn(spectator.component.change, 'emit');
|
|
847
|
+
spectator.component.writeValue(items[2]);
|
|
848
|
+
expect(onChangeSpy).not.toHaveBeenCalled();
|
|
849
|
+
});
|
|
850
|
+
});
|
|
851
|
+
|
|
852
|
+
it('should invoke callback from registerOnChange() function on change', () => {
|
|
853
|
+
const selectedIndex = 2;
|
|
854
|
+
const expectedItem = items[selectedIndex];
|
|
855
|
+
const onChangeSpy = jasmine.createSpy('_onChange');
|
|
856
|
+
spectator.component.registerOnChange(onChangeSpy);
|
|
857
|
+
spectator.component.onItemSelect(selectedIndex);
|
|
858
|
+
expect(onChangeSpy).toHaveBeenCalledWith(expectedItem);
|
|
859
|
+
});
|
|
860
|
+
|
|
861
|
+
it('should invoke callback from registerOnTouched() function on blur', () => {
|
|
862
|
+
const onTouchedSpy = jasmine.createSpy('_onTouched');
|
|
863
|
+
spectator.component.registerOnTouched(onTouchedSpy);
|
|
864
|
+
spectator.blur();
|
|
865
|
+
spectator.detectChanges();
|
|
866
|
+
expect(onTouchedSpy).toHaveBeenCalled();
|
|
867
|
+
});
|
|
868
|
+
|
|
869
|
+
describe('when setDisabledState() function is invoked', () => {
|
|
870
|
+
it('should set disabled = false when invoked with false', () => {
|
|
871
|
+
spectator.component.disabled = true;
|
|
872
|
+
spectator.component.setDisabledState(false);
|
|
873
|
+
expect(spectator.component.disabled).toBeFalsy();
|
|
874
|
+
});
|
|
875
|
+
|
|
876
|
+
it('should set disabled = true when invoked with true', () => {
|
|
877
|
+
spectator.component.disabled = false;
|
|
878
|
+
spectator.component.setDisabledState(true);
|
|
879
|
+
expect(spectator.component.disabled).toBeTruthy();
|
|
880
|
+
});
|
|
881
|
+
});
|
|
882
|
+
});
|
|
883
|
+
});
|
|
884
|
+
|
|
885
|
+
describe('when configured with size', () => {
|
|
886
|
+
let spectator: SpectatorHost<DropdownComponent>;
|
|
887
|
+
|
|
888
|
+
const createHost = createHostFactory({
|
|
889
|
+
component: DropdownComponent,
|
|
890
|
+
declarations: [
|
|
891
|
+
MockComponents(
|
|
892
|
+
ButtonComponent,
|
|
893
|
+
CardComponent,
|
|
894
|
+
ItemComponent,
|
|
895
|
+
IconComponent,
|
|
896
|
+
PopoverComponent
|
|
897
|
+
),
|
|
898
|
+
],
|
|
899
|
+
});
|
|
900
|
+
|
|
901
|
+
describe('through template one-time string initialization', () => {
|
|
902
|
+
function getSpectatorWithStringSize(size: string) {
|
|
903
|
+
return createHost(`<kirby-dropdown size="${size}"></kirby-dropdown>`, {
|
|
904
|
+
props: { items: items },
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
it('should have small size on button', () => {
|
|
909
|
+
const size = 'sm';
|
|
910
|
+
spectator = getSpectatorWithStringSize(size);
|
|
911
|
+
const button: ButtonComponent = spectator.query(ButtonComponent);
|
|
912
|
+
|
|
913
|
+
expect(button.size).toBe(size);
|
|
914
|
+
});
|
|
915
|
+
|
|
916
|
+
it('should have medium size on button', () => {
|
|
917
|
+
const size = 'md';
|
|
918
|
+
spectator = getSpectatorWithStringSize(size);
|
|
919
|
+
const button: ButtonComponent = spectator.query(ButtonComponent);
|
|
920
|
+
|
|
921
|
+
expect(button.size).toBe(size);
|
|
922
|
+
});
|
|
923
|
+
});
|
|
924
|
+
|
|
925
|
+
describe('through template property binding', () => {
|
|
926
|
+
function getSpectatorWithStringSize(size: string) {
|
|
927
|
+
return createHost(`<kirby-dropdown [size]="'${size}'"></kirby-dropdown>`, {
|
|
928
|
+
props: { items: items },
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
it('should have small size on button', () => {
|
|
933
|
+
const size = 'sm';
|
|
934
|
+
spectator = getSpectatorWithStringSize(size);
|
|
935
|
+
const button: ButtonComponent = spectator.query(ButtonComponent);
|
|
936
|
+
|
|
937
|
+
expect(button.size).toBe(size);
|
|
938
|
+
});
|
|
939
|
+
|
|
940
|
+
it('should have medium size on button', () => {
|
|
941
|
+
const size = 'md';
|
|
942
|
+
spectator = getSpectatorWithStringSize(size);
|
|
943
|
+
const button: ButtonComponent = spectator.query(ButtonComponent);
|
|
944
|
+
|
|
945
|
+
expect(button.size).toBe(size);
|
|
946
|
+
});
|
|
947
|
+
});
|
|
948
|
+
|
|
949
|
+
describe('through input properties', () => {
|
|
950
|
+
function getSpectatorWithSize(size: 'sm' | 'md') {
|
|
951
|
+
return createHost(`<kirby-dropdown></kirby-dropdown>`, {
|
|
952
|
+
props: { items: items, size: size },
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
it('should have small size on button', () => {
|
|
957
|
+
const size = 'sm';
|
|
958
|
+
spectator = getSpectatorWithSize(size);
|
|
959
|
+
const button: ButtonComponent = spectator.query(ButtonComponent);
|
|
960
|
+
|
|
961
|
+
expect(button.size).toBe(size);
|
|
962
|
+
});
|
|
963
|
+
|
|
964
|
+
it('should have medium size on button', () => {
|
|
965
|
+
const size = 'md';
|
|
966
|
+
spectator = getSpectatorWithSize(size);
|
|
967
|
+
const button: ButtonComponent = spectator.query(ButtonComponent);
|
|
968
|
+
|
|
969
|
+
expect(button.size).toBe(size);
|
|
970
|
+
});
|
|
971
|
+
|
|
972
|
+
describe('when changing size', () => {
|
|
973
|
+
it('should have correct size', () => {
|
|
974
|
+
const newSize = 'sm';
|
|
975
|
+
spectator = getSpectatorWithSize('md');
|
|
976
|
+
spectator.setInput('size', newSize);
|
|
977
|
+
const button: ButtonComponent = spectator.query(ButtonComponent);
|
|
978
|
+
|
|
979
|
+
expect(button.size).toBe(newSize);
|
|
980
|
+
});
|
|
981
|
+
});
|
|
982
|
+
});
|
|
983
|
+
});
|
|
984
|
+
|
|
985
|
+
describe('when configured with selected index', () => {
|
|
986
|
+
let spectator: SpectatorHost<DropdownComponent>;
|
|
987
|
+
let buttonElement: HTMLButtonElement;
|
|
988
|
+
|
|
989
|
+
const createHost = createHostFactory({
|
|
990
|
+
component: DropdownComponent,
|
|
991
|
+
declarations: [
|
|
992
|
+
MockComponents(
|
|
993
|
+
ButtonComponent,
|
|
994
|
+
CardComponent,
|
|
995
|
+
ItemComponent,
|
|
996
|
+
IconComponent,
|
|
997
|
+
PopoverComponent
|
|
998
|
+
),
|
|
999
|
+
],
|
|
1000
|
+
});
|
|
1001
|
+
|
|
1002
|
+
const defaultSelectedIndex = 2;
|
|
1003
|
+
const expectedItem = items[defaultSelectedIndex];
|
|
1004
|
+
const expectedText = expectedItem.text;
|
|
1005
|
+
|
|
1006
|
+
describe('through template one-time string initialization', () => {
|
|
1007
|
+
beforeEach(() => {
|
|
1008
|
+
spectator = createHost(
|
|
1009
|
+
`<kirby-dropdown selectedIndex="${defaultSelectedIndex}"></kirby-dropdown>`,
|
|
1010
|
+
{
|
|
1011
|
+
props: {
|
|
1012
|
+
items: items,
|
|
1013
|
+
},
|
|
1014
|
+
}
|
|
1015
|
+
);
|
|
1016
|
+
buttonElement = spectator.query('button[kirby-button]');
|
|
1017
|
+
});
|
|
1018
|
+
|
|
1019
|
+
it('should have selected item', () => {
|
|
1020
|
+
expect(spectator.component.value).toEqual(expectedItem);
|
|
1021
|
+
});
|
|
1022
|
+
|
|
1023
|
+
it('should have selected text from selected item', () => {
|
|
1024
|
+
expect(spectator.component.selectedText).toEqual(expectedText);
|
|
1025
|
+
expect(buttonElement).toHaveText(expectedText, true);
|
|
1026
|
+
});
|
|
1027
|
+
});
|
|
1028
|
+
|
|
1029
|
+
describe('through template property binding', () => {
|
|
1030
|
+
beforeEach(() => {
|
|
1031
|
+
spectator = createHost(
|
|
1032
|
+
`<kirby-dropdown [selectedIndex]="${defaultSelectedIndex}"></kirby-dropdown>`,
|
|
1033
|
+
{
|
|
1034
|
+
props: {
|
|
1035
|
+
items: items,
|
|
1036
|
+
},
|
|
1037
|
+
}
|
|
1038
|
+
);
|
|
1039
|
+
buttonElement = spectator.query('button[kirby-button]');
|
|
1040
|
+
});
|
|
1041
|
+
|
|
1042
|
+
it('should have selected item', () => {
|
|
1043
|
+
expect(spectator.component.value).toEqual(expectedItem);
|
|
1044
|
+
});
|
|
1045
|
+
|
|
1046
|
+
it('should have selected text from selected item', () => {
|
|
1047
|
+
expect(spectator.component.selectedText).toEqual(expectedText);
|
|
1048
|
+
expect(buttonElement).toHaveText(expectedText, true);
|
|
1049
|
+
});
|
|
1050
|
+
});
|
|
1051
|
+
|
|
1052
|
+
describe('through input properties', () => {
|
|
1053
|
+
beforeEach(() => {
|
|
1054
|
+
spectator = createHost(`<kirby-dropdown></kirby-dropdown>`, {
|
|
1055
|
+
props: {
|
|
1056
|
+
items: items,
|
|
1057
|
+
selectedIndex: defaultSelectedIndex,
|
|
1058
|
+
},
|
|
1059
|
+
});
|
|
1060
|
+
buttonElement = spectator.query('button[kirby-button]');
|
|
1061
|
+
});
|
|
1062
|
+
|
|
1063
|
+
it('should have selected item', () => {
|
|
1064
|
+
expect(spectator.component.value).toEqual(expectedItem);
|
|
1065
|
+
});
|
|
1066
|
+
|
|
1067
|
+
it('should have selected text from selected item', () => {
|
|
1068
|
+
expect(spectator.component.selectedText).toEqual(expectedText);
|
|
1069
|
+
expect(buttonElement).toHaveText(expectedText, true);
|
|
1070
|
+
});
|
|
1071
|
+
|
|
1072
|
+
describe('when changing selected index', () => {
|
|
1073
|
+
it('should have correct new selected item', () => {
|
|
1074
|
+
const newSelectedIndex = 0;
|
|
1075
|
+
const expectedItem = items[newSelectedIndex];
|
|
1076
|
+
spectator.setInput('selectedIndex', newSelectedIndex);
|
|
1077
|
+
spectator.detectChanges();
|
|
1078
|
+
expect(spectator.component.value).toEqual(expectedItem);
|
|
1079
|
+
});
|
|
1080
|
+
|
|
1081
|
+
it('should have selected text from new selected item', () => {
|
|
1082
|
+
const newSelectedIndex = 0;
|
|
1083
|
+
const expectedText = items[newSelectedIndex].text;
|
|
1084
|
+
spectator.setInput('selectedIndex', newSelectedIndex);
|
|
1085
|
+
spectator.detectChanges();
|
|
1086
|
+
expect(spectator.component.selectedText).toEqual(expectedText);
|
|
1087
|
+
expect(buttonElement).toHaveText(expectedText, true);
|
|
1088
|
+
});
|
|
1089
|
+
|
|
1090
|
+
it('should not emit change event', () => {
|
|
1091
|
+
const newSelectedIndex = 0;
|
|
1092
|
+
const onChangeSpy = spyOn(spectator.component.change, 'emit');
|
|
1093
|
+
spectator.setInput('selectedIndex', newSelectedIndex);
|
|
1094
|
+
spectator.detectChanges();
|
|
1095
|
+
expect(onChangeSpy).not.toHaveBeenCalled();
|
|
1096
|
+
});
|
|
1097
|
+
});
|
|
1098
|
+
});
|
|
1099
|
+
});
|
|
1100
|
+
|
|
1101
|
+
describe('when inside host component with ChangeDetectionStrategy.OnPush', () => {
|
|
1102
|
+
let spectator: SpectatorHost<DropdownComponent>;
|
|
1103
|
+
let cardElement: HTMLElement;
|
|
1104
|
+
|
|
1105
|
+
const createHost = createHostFactory({
|
|
1106
|
+
component: DropdownComponent,
|
|
1107
|
+
declarations: [
|
|
1108
|
+
MockComponents(
|
|
1109
|
+
ButtonComponent,
|
|
1110
|
+
CardComponent,
|
|
1111
|
+
ItemComponent,
|
|
1112
|
+
IconComponent,
|
|
1113
|
+
PopoverComponent
|
|
1114
|
+
),
|
|
1115
|
+
],
|
|
1116
|
+
host: OnPushHostComponent,
|
|
1117
|
+
});
|
|
1118
|
+
|
|
1119
|
+
beforeEach(() => {
|
|
1120
|
+
spectator = createHost(`<kirby-dropdown></kirby-dropdown>`, {
|
|
1121
|
+
props: {
|
|
1122
|
+
items: items,
|
|
1123
|
+
},
|
|
1124
|
+
});
|
|
1125
|
+
});
|
|
1126
|
+
|
|
1127
|
+
beforeEach(fakeAsync(() => {
|
|
1128
|
+
cardElement = spectator.query('kirby-card');
|
|
1129
|
+
// Assert that card is initially hidden:
|
|
1130
|
+
expect(cardElement).toBeHidden();
|
|
1131
|
+
expect(cardElement).toHaveComputedStyle({ opacity: '0' });
|
|
1132
|
+
// Act:
|
|
1133
|
+
spectator.click('button');
|
|
1134
|
+
tick(openDelayInMs);
|
|
1135
|
+
spectator.detectChanges();
|
|
1136
|
+
}));
|
|
1137
|
+
|
|
1138
|
+
it('should open dropdown', () => {
|
|
1139
|
+
expect(spectator.component.isOpen).toBeTruthy();
|
|
1140
|
+
});
|
|
1141
|
+
|
|
1142
|
+
it(`should have '.is-open' css class`, () => {
|
|
1143
|
+
expect(spectator.element).toHaveClass('is-open');
|
|
1144
|
+
});
|
|
1145
|
+
|
|
1146
|
+
it('options should be visible', () => {
|
|
1147
|
+
expect(cardElement).toBeVisible();
|
|
1148
|
+
expect(cardElement).toHaveComputedStyle({ opacity: '1' });
|
|
1149
|
+
});
|
|
1150
|
+
});
|
|
1151
|
+
|
|
1152
|
+
describe('when configured with custom item template', () => {
|
|
1153
|
+
let spectator: SpectatorHost<DropdownComponent>;
|
|
1154
|
+
|
|
1155
|
+
const createHost = createHostFactory({
|
|
1156
|
+
component: DropdownComponent,
|
|
1157
|
+
declarations: [
|
|
1158
|
+
ItemComponent,
|
|
1159
|
+
ListItemTemplateDirective,
|
|
1160
|
+
MockComponents(ButtonComponent, CardComponent, IconComponent, IonItem, PopoverComponent),
|
|
1161
|
+
],
|
|
1162
|
+
});
|
|
1163
|
+
|
|
1164
|
+
beforeEach(() => {
|
|
1165
|
+
spectator = createHost(
|
|
1166
|
+
`<kirby-dropdown>
|
|
1167
|
+
<kirby-item
|
|
1168
|
+
*kirbyListItemTemplate="let item; let selected = selected"
|
|
1169
|
+
selectable="true"
|
|
1170
|
+
[selected]="selected">
|
|
1171
|
+
<kirby-icon *ngIf="selected" name="checkmark-selected" slot="start"></kirby-icon>
|
|
1172
|
+
<h3>{{ item.title }}</h3>
|
|
1173
|
+
</kirby-item>
|
|
1174
|
+
</kirby-dropdown>`,
|
|
1175
|
+
{
|
|
1176
|
+
props: {
|
|
1177
|
+
items: items,
|
|
1178
|
+
},
|
|
1179
|
+
}
|
|
1180
|
+
);
|
|
1181
|
+
});
|
|
1182
|
+
|
|
1183
|
+
it('should have correct item size', () => {
|
|
1184
|
+
const itemElements = spectator.queryAll<HTMLElement>('kirby-item');
|
|
1185
|
+
expect(itemElements).toHaveLength(items.length);
|
|
1186
|
+
itemElements.forEach((item) => {
|
|
1187
|
+
expect(item.querySelector('ion-item')).toHaveComputedStyle({
|
|
1188
|
+
'--min-height': DesignTokenHelper.dropdownItemHeight(),
|
|
1189
|
+
});
|
|
1190
|
+
});
|
|
1191
|
+
});
|
|
1192
|
+
|
|
1193
|
+
it('should set up click listernes for slotted items', () => {
|
|
1194
|
+
spectator.detectChanges();
|
|
1195
|
+
const clickListeners = spectator.component['itemClickUnlisten'];
|
|
1196
|
+
expect(clickListeners).toHaveLength(items.length);
|
|
1197
|
+
});
|
|
1198
|
+
|
|
1199
|
+
describe('ngOnDestroy', () => {
|
|
1200
|
+
it('should call each item click unlisten function for slotted items', () => {
|
|
1201
|
+
const unlistenMockArray = [
|
|
1202
|
+
() => unlistenCounter++,
|
|
1203
|
+
() => unlistenCounter++,
|
|
1204
|
+
() => unlistenCounter++,
|
|
1205
|
+
];
|
|
1206
|
+
const unlistenMockArrayLength = unlistenMockArray.length;
|
|
1207
|
+
let unlistenCounter = 0;
|
|
1208
|
+
spectator.component['itemClickUnlisten'] = unlistenMockArray;
|
|
1209
|
+
spectator.component.ngOnDestroy();
|
|
1210
|
+
expect(spectator.component['itemClickUnlisten']).toHaveLength(0);
|
|
1211
|
+
expect(unlistenCounter).toEqual(unlistenMockArrayLength);
|
|
1212
|
+
});
|
|
1213
|
+
});
|
|
1214
|
+
});
|
|
1215
|
+
});
|