primekit 1.0.11 → 1.0.12
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/esm2022/lib/lib/atomix-alert/atomix-alert.component.mjs +76 -0
- package/esm2022/lib/lib/atomix-autocomplete/atomix-autocomplete.component.mjs +108 -0
- package/esm2022/lib/lib/atomix-button/atomix-button.component.mjs +49 -0
- package/esm2022/lib/lib/atomix-button/atomix-button.models.mjs +2 -0
- package/esm2022/lib/lib/atomix-calendar/atomix-calendar.component.mjs +90 -0
- package/esm2022/lib/lib/atomix-card/atomix-card.component.mjs +24 -0
- package/esm2022/lib/lib/atomix-confirmation-dialog/atomix-confirmation-dialog.component.mjs +28 -0
- package/esm2022/lib/lib/atomix-daterange-calendar/atomix-daterange-calendar.component.mjs +674 -0
- package/esm2022/lib/lib/atomix-divider/atomix-divider.component.mjs +27 -0
- package/esm2022/lib/lib/atomix-dropdown/atomix-dropdown.component.mjs +105 -0
- package/esm2022/lib/lib/atomix-dynamic-dialog/atomix-dynamic-dialog.component.mjs +38 -0
- package/esm2022/lib/lib/atomix-dynamic-dialog/atomix-dynamic-dialog.models.mjs +2 -0
- package/esm2022/lib/lib/atomix-form/atomix-form-autocomplete/atomix-form-autocomplete.component.mjs +67 -0
- package/esm2022/lib/lib/atomix-form/atomix-form-calendar/atomix-form-calendar.component.mjs +59 -0
- package/esm2022/lib/lib/atomix-form/atomix-form-checkbox/atomix-form-checkbox.component.mjs +48 -0
- package/esm2022/lib/lib/atomix-form/atomix-form-chips/atomix-form-chips.component.mjs +54 -0
- package/esm2022/lib/lib/atomix-form/atomix-form-chips/form.chips.models.mjs +2 -0
- package/esm2022/lib/lib/atomix-form/atomix-form-dropdown/atomix-form-dropdown.component.mjs +70 -0
- package/esm2022/lib/lib/atomix-form/atomix-form-input-component/atomix-form-input-component.component.mjs +80 -0
- package/esm2022/lib/lib/atomix-form/atomix-form-inputmask-component/atomix-form-inputmask-component.component.mjs +48 -0
- package/esm2022/lib/lib/atomix-form/atomix-form-password-component/atomix-form-password-component.component.mjs +48 -0
- package/esm2022/lib/lib/atomix-form/atomix-form-radio-button/atomix-radio-button.component.mjs +46 -0
- package/esm2022/lib/lib/atomix-form/atomix-form-textarea/atomix-form-textarea.component.mjs +46 -0
- package/esm2022/lib/lib/atomix-input/atomix-input.component.mjs +94 -0
- package/esm2022/lib/lib/atomix-input-switch/atomix-input-switch.component.mjs +85 -0
- package/esm2022/lib/lib/atomix-loading-overlay/atomix-loading-overlay.component.mjs +44 -0
- package/esm2022/lib/lib/atomix-messages/messages.component.mjs +33 -0
- package/esm2022/lib/lib/atomix-pagination/atomix-pagination.component.mjs +48 -0
- package/esm2022/lib/lib/atomix-radio-button/atomix-radio-button.component.mjs +50 -0
- package/esm2022/lib/lib/atomix-search-dropdown/atomix-search-dropdown.component.mjs +149 -0
- package/esm2022/lib/lib/atomix-select-button/atomix-select-button-models.mjs +2 -0
- package/esm2022/lib/lib/atomix-select-button/atomix-select-button.component.mjs +25 -0
- package/esm2022/lib/lib/atomix-snackbar/atomix-snackbar.component.mjs +29 -0
- package/esm2022/lib/lib/atomix-spinner/atomix-spinner.component.mjs +24 -0
- package/esm2022/lib/lib/atomix-steps/atomix-steps.component.mjs +41 -0
- package/esm2022/lib/lib/atomix-tabMenu/atomix-tabMenu.component.mjs +51 -0
- package/esm2022/lib/lib/atomix-table/atomix-table.component.mjs +454 -0
- package/esm2022/lib/lib/atomix-table/atomix-table.models.mjs +2 -0
- package/esm2022/lib/lib/atomix-tag/atomix-tag.component.mjs +24 -0
- package/esm2022/lib/lib/utils/prime-icons.util.mjs +10 -0
- package/esm2022/lib/primekit.component.mjs +11 -0
- package/esm2022/lib/primekit.module.mjs +322 -0
- package/esm2022/lib/primekit.service.mjs +14 -0
- package/esm2022/primekit.mjs +5 -0
- package/esm2022/public-api.mjs +44 -0
- package/fesm2022/primekit.mjs +3115 -0
- package/fesm2022/primekit.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/lib/atomix-alert/atomix-alert.component.d.ts +22 -0
- package/lib/lib/atomix-autocomplete/atomix-autocomplete.component.d.ts +34 -0
- package/lib/lib/atomix-button/atomix-button.component.d.ts +19 -0
- package/{src/lib/lib/atomix-button/atomix-button.models.ts → lib/lib/atomix-button/atomix-button.models.d.ts} +2 -2
- package/lib/lib/atomix-calendar/atomix-calendar.component.d.ts +27 -0
- package/lib/lib/atomix-card/atomix-card.component.d.ts +9 -0
- package/lib/lib/atomix-confirmation-dialog/atomix-confirmation-dialog.component.d.ts +12 -0
- package/lib/lib/atomix-daterange-calendar/atomix-daterange-calendar.component.d.ts +72 -0
- package/lib/lib/atomix-divider/atomix-divider.component.d.ts +12 -0
- package/lib/lib/atomix-dropdown/atomix-dropdown.component.d.ts +50 -0
- package/lib/lib/atomix-dynamic-dialog/atomix-dynamic-dialog.component.d.ts +15 -0
- package/lib/lib/atomix-dynamic-dialog/atomix-dynamic-dialog.models.d.ts +11 -0
- package/lib/lib/atomix-form/atomix-form-autocomplete/atomix-form-autocomplete.component.d.ts +25 -0
- package/lib/lib/atomix-form/atomix-form-calendar/atomix-form-calendar.component.d.ts +23 -0
- package/lib/lib/atomix-form/atomix-form-checkbox/atomix-form-checkbox.component.d.ts +18 -0
- package/lib/lib/atomix-form/atomix-form-chips/atomix-form-chips.component.d.ts +19 -0
- package/lib/lib/atomix-form/atomix-form-chips/form.chips.models.d.ts +5 -0
- package/lib/lib/atomix-form/atomix-form-dropdown/atomix-form-dropdown.component.d.ts +25 -0
- package/lib/lib/atomix-form/atomix-form-input-component/atomix-form-input-component.component.d.ts +28 -0
- package/lib/lib/atomix-form/atomix-form-inputmask-component/atomix-form-inputmask-component.component.d.ts +17 -0
- package/lib/lib/atomix-form/atomix-form-password-component/atomix-form-password-component.component.d.ts +17 -0
- package/lib/lib/atomix-form/atomix-form-radio-button/atomix-radio-button.component.d.ts +19 -0
- package/lib/lib/atomix-form/atomix-form-textarea/atomix-form-textarea.component.d.ts +17 -0
- package/lib/lib/atomix-input/atomix-input.component.d.ts +29 -0
- package/lib/lib/atomix-input-switch/atomix-input-switch.component.d.ts +30 -0
- package/lib/lib/atomix-loading-overlay/atomix-loading-overlay.component.d.ts +16 -0
- package/lib/lib/atomix-messages/messages.component.d.ts +13 -0
- package/lib/lib/atomix-pagination/atomix-pagination.component.d.ts +19 -0
- package/lib/lib/atomix-radio-button/atomix-radio-button.component.d.ts +15 -0
- package/lib/lib/atomix-search-dropdown/atomix-search-dropdown.component.d.ts +60 -0
- package/{src/lib/lib/atomix-select-button/atomix-select-button-models.ts → lib/lib/atomix-select-button/atomix-select-button-models.d.ts} +4 -4
- package/lib/lib/atomix-select-button/atomix-select-button.component.d.ts +12 -0
- package/lib/lib/atomix-snackbar/atomix-snackbar.component.d.ts +12 -0
- package/lib/lib/atomix-spinner/atomix-spinner.component.d.ts +9 -0
- package/lib/lib/atomix-steps/atomix-steps.component.d.ts +19 -0
- package/lib/lib/atomix-tabMenu/atomix-tabMenu.component.d.ts +19 -0
- package/lib/lib/atomix-table/atomix-table.component.d.ts +119 -0
- package/lib/lib/atomix-table/atomix-table.models.d.ts +43 -0
- package/lib/lib/atomix-tag/atomix-tag.component.d.ts +9 -0
- package/lib/lib/utils/prime-icons.util.d.ts +3 -0
- package/lib/primekit.component.d.ts +5 -0
- package/lib/primekit.module.d.ts +72 -0
- package/lib/primekit.service.d.ts +6 -0
- package/package.json +28 -15
- package/{src/public-api.ts → public-api.d.ts} +38 -47
- package/ng-package.json +0 -8
- package/src/lib/lib/atomix-alert/atomix-alert.component.css +0 -67
- package/src/lib/lib/atomix-alert/atomix-alert.component.html +0 -7
- package/src/lib/lib/atomix-alert/atomix-alert.component.spec.ts +0 -154
- package/src/lib/lib/atomix-alert/atomix-alert.component.ts +0 -75
- package/src/lib/lib/atomix-autocomplete/atomix-autocomplete.component.html +0 -35
- package/src/lib/lib/atomix-autocomplete/atomix-autocomplete.component.scss +0 -72
- package/src/lib/lib/atomix-autocomplete/atomix-autocomplete.component.spec.ts +0 -210
- package/src/lib/lib/atomix-autocomplete/atomix-autocomplete.component.ts +0 -70
- package/src/lib/lib/atomix-button/atomix-button.component.css +0 -70
- package/src/lib/lib/atomix-button/atomix-button.component.html +0 -20
- package/src/lib/lib/atomix-button/atomix-button.component.spec.ts +0 -135
- package/src/lib/lib/atomix-button/atomix-button.component.ts +0 -28
- package/src/lib/lib/atomix-calendar/atomix-calendar.component.css +0 -5
- package/src/lib/lib/atomix-calendar/atomix-calendar.component.html +0 -20
- package/src/lib/lib/atomix-calendar/atomix-calendar.component.spec.ts +0 -145
- package/src/lib/lib/atomix-calendar/atomix-calendar.component.ts +0 -71
- package/src/lib/lib/atomix-card/atomix-card.component.css +0 -4
- package/src/lib/lib/atomix-card/atomix-card.component.html +0 -3
- package/src/lib/lib/atomix-card/atomix-card.component.spec.ts +0 -63
- package/src/lib/lib/atomix-card/atomix-card.component.ts +0 -13
- package/src/lib/lib/atomix-confirmation-dialog/atomix-confirmation-dialog.component.css +0 -12
- package/src/lib/lib/atomix-confirmation-dialog/atomix-confirmation-dialog.component.html +0 -9
- package/src/lib/lib/atomix-confirmation-dialog/atomix-confirmation-dialog.component.spec.ts +0 -63
- package/src/lib/lib/atomix-confirmation-dialog/atomix-confirmation-dialog.component.ts +0 -22
- package/src/lib/lib/atomix-daterange-calendar/atomix-daterange-calendar.component.html +0 -233
- package/src/lib/lib/atomix-daterange-calendar/atomix-daterange-calendar.component.scss +0 -266
- package/src/lib/lib/atomix-daterange-calendar/atomix-daterange-calendar.component.spec.ts +0 -1465
- package/src/lib/lib/atomix-daterange-calendar/atomix-daterange-calendar.component.ts +0 -717
- package/src/lib/lib/atomix-divider/atomix-divider.component.css +0 -0
- package/src/lib/lib/atomix-divider/atomix-divider.component.html +0 -7
- package/src/lib/lib/atomix-divider/atomix-divider.component.spec.ts +0 -91
- package/src/lib/lib/atomix-divider/atomix-divider.component.ts +0 -17
- package/src/lib/lib/atomix-dropdown/atomix-dropdown.component.css +0 -25
- package/src/lib/lib/atomix-dropdown/atomix-dropdown.component.html +0 -37
- package/src/lib/lib/atomix-dropdown/atomix-dropdown.component.spec.ts +0 -178
- package/src/lib/lib/atomix-dropdown/atomix-dropdown.component.ts +0 -89
- package/src/lib/lib/atomix-dynamic-dialog/atomix-dynamic-dialog.component.css +0 -0
- package/src/lib/lib/atomix-dynamic-dialog/atomix-dynamic-dialog.component.html +0 -0
- package/src/lib/lib/atomix-dynamic-dialog/atomix-dynamic-dialog.component.spec.ts +0 -128
- package/src/lib/lib/atomix-dynamic-dialog/atomix-dynamic-dialog.component.ts +0 -42
- package/src/lib/lib/atomix-dynamic-dialog/atomix-dynamic-dialog.models.ts +0 -12
- package/src/lib/lib/atomix-form/atomix-form-autocomplete/atomix-form-autocomplete.component.html +0 -20
- package/src/lib/lib/atomix-form/atomix-form-autocomplete/atomix-form-autocomplete.component.scss +0 -7
- package/src/lib/lib/atomix-form/atomix-form-autocomplete/atomix-form-autocomplete.component.spec.ts +0 -169
- package/src/lib/lib/atomix-form/atomix-form-autocomplete/atomix-form-autocomplete.component.ts +0 -41
- package/src/lib/lib/atomix-form/atomix-form-calendar/atomix-form-calendar.component.html +0 -21
- package/src/lib/lib/atomix-form/atomix-form-calendar/atomix-form-calendar.component.scss +0 -7
- package/src/lib/lib/atomix-form/atomix-form-calendar/atomix-form-calendar.component.spec.ts +0 -142
- package/src/lib/lib/atomix-form/atomix-form-calendar/atomix-form-calendar.component.ts +0 -32
- package/src/lib/lib/atomix-form/atomix-form-checkbox/atomix-form-checkbox.component.html +0 -13
- package/src/lib/lib/atomix-form/atomix-form-checkbox/atomix-form-checkbox.component.scss +0 -14
- package/src/lib/lib/atomix-form/atomix-form-checkbox/atomix-form-checkbox.component.spec.ts +0 -112
- package/src/lib/lib/atomix-form/atomix-form-checkbox/atomix-form-checkbox.component.ts +0 -28
- package/src/lib/lib/atomix-form/atomix-form-chips/atomix-form-chips.component.html +0 -20
- package/src/lib/lib/atomix-form/atomix-form-chips/atomix-form-chips.component.scss +0 -3
- package/src/lib/lib/atomix-form/atomix-form-chips/atomix-form-chips.component.spec.ts +0 -153
- package/src/lib/lib/atomix-form/atomix-form-chips/atomix-form-chips.component.ts +0 -28
- package/src/lib/lib/atomix-form/atomix-form-chips/form.chips.models.ts +0 -5
- package/src/lib/lib/atomix-form/atomix-form-dropdown/atomix-form-dropdown.component.html +0 -24
- package/src/lib/lib/atomix-form/atomix-form-dropdown/atomix-form-dropdown.component.scss +0 -15
- package/src/lib/lib/atomix-form/atomix-form-dropdown/atomix-form-dropdown.component.spec.ts +0 -156
- package/src/lib/lib/atomix-form/atomix-form-dropdown/atomix-form-dropdown.component.ts +0 -36
- package/src/lib/lib/atomix-form/atomix-form-input-component/atomix-form-input-component.component.html +0 -33
- package/src/lib/lib/atomix-form/atomix-form-input-component/atomix-form-input-component.component.scss +0 -32
- package/src/lib/lib/atomix-form/atomix-form-input-component/atomix-form-input-component.component.spec.ts +0 -156
- package/src/lib/lib/atomix-form/atomix-form-input-component/atomix-form-input-component.component.ts +0 -42
- package/src/lib/lib/atomix-form/atomix-form-inputmask-component/atomix-form-inputmask-component.component.html +0 -14
- package/src/lib/lib/atomix-form/atomix-form-inputmask-component/atomix-form-inputmask-component.component.scss +0 -0
- package/src/lib/lib/atomix-form/atomix-form-inputmask-component/atomix-form-inputmask-component.component.spec.ts +0 -104
- package/src/lib/lib/atomix-form/atomix-form-inputmask-component/atomix-form-inputmask-component.component.ts +0 -24
- package/src/lib/lib/atomix-form/atomix-form-password-component/atomix-form-password-component.component.html +0 -16
- package/src/lib/lib/atomix-form/atomix-form-password-component/atomix-form-password-component.component.scss +0 -0
- package/src/lib/lib/atomix-form/atomix-form-password-component/atomix-form-password-component.component.spec.ts +0 -92
- package/src/lib/lib/atomix-form/atomix-form-password-component/atomix-form-password-component.component.ts +0 -24
- package/src/lib/lib/atomix-form/atomix-form-radio-button/atomix-radio-button.component.html +0 -23
- package/src/lib/lib/atomix-form/atomix-form-radio-button/atomix-radio-button.component.scss +0 -3
- package/src/lib/lib/atomix-form/atomix-form-radio-button/atomix-radio-button.component.spec.ts +0 -126
- package/src/lib/lib/atomix-form/atomix-form-radio-button/atomix-radio-button.component.ts +0 -26
- package/src/lib/lib/atomix-form/atomix-form-textarea/atomix-form-textarea.component.html +0 -17
- package/src/lib/lib/atomix-form/atomix-form-textarea/atomix-form-textarea.component.scss +0 -6
- package/src/lib/lib/atomix-form/atomix-form-textarea/atomix-form-textarea.component.spec.ts +0 -120
- package/src/lib/lib/atomix-form/atomix-form-textarea/atomix-form-textarea.component.ts +0 -24
- package/src/lib/lib/atomix-input/atomix-input.component.css +0 -52
- package/src/lib/lib/atomix-input/atomix-input.component.html +0 -45
- package/src/lib/lib/atomix-input/atomix-input.component.spec.ts +0 -229
- package/src/lib/lib/atomix-input/atomix-input.component.ts +0 -64
- package/src/lib/lib/atomix-input-switch/atomix-input-switch.component.css +0 -12
- package/src/lib/lib/atomix-input-switch/atomix-input-switch.component.html +0 -17
- package/src/lib/lib/atomix-input-switch/atomix-input-switch.component.spec.ts +0 -173
- package/src/lib/lib/atomix-input-switch/atomix-input-switch.component.ts +0 -62
- package/src/lib/lib/atomix-loading-overlay/atomix-loading-overlay.component.html +0 -47
- package/src/lib/lib/atomix-loading-overlay/atomix-loading-overlay.component.scss +0 -14
- package/src/lib/lib/atomix-loading-overlay/atomix-loading-overlay.component.spec.ts +0 -21
- package/src/lib/lib/atomix-loading-overlay/atomix-loading-overlay.component.ts +0 -25
- package/src/lib/lib/atomix-messages/messages.component.css +0 -0
- package/src/lib/lib/atomix-messages/messages.component.html +0 -9
- package/src/lib/lib/atomix-messages/messages.component.spec.ts +0 -115
- package/src/lib/lib/atomix-messages/messages.component.ts +0 -17
- package/src/lib/lib/atomix-pagination/atomix-pagination.component.css +0 -19
- package/src/lib/lib/atomix-pagination/atomix-pagination.component.html +0 -24
- package/src/lib/lib/atomix-pagination/atomix-pagination.component.spec.ts +0 -98
- package/src/lib/lib/atomix-pagination/atomix-pagination.component.ts +0 -36
- package/src/lib/lib/atomix-radio-button/atomix-radio-button.component.css +0 -0
- package/src/lib/lib/atomix-radio-button/atomix-radio-button.component.html +0 -7
- package/src/lib/lib/atomix-radio-button/atomix-radio-button.component.spec.ts +0 -116
- package/src/lib/lib/atomix-radio-button/atomix-radio-button.component.ts +0 -37
- package/src/lib/lib/atomix-search-dropdown/atomix-search-dropdown.component.css +0 -49
- package/src/lib/lib/atomix-search-dropdown/atomix-search-dropdown.component.html +0 -68
- package/src/lib/lib/atomix-search-dropdown/atomix-search-dropdown.component.spec.ts +0 -282
- package/src/lib/lib/atomix-search-dropdown/atomix-search-dropdown.component.ts +0 -119
- package/src/lib/lib/atomix-select-button/atomix-select-button.component.css +0 -5
- package/src/lib/lib/atomix-select-button/atomix-select-button.component.html +0 -7
- package/src/lib/lib/atomix-select-button/atomix-select-button.component.spec.ts +0 -73
- package/src/lib/lib/atomix-select-button/atomix-select-button.component.ts +0 -19
- package/src/lib/lib/atomix-snackbar/atomix-snackbar.component.css +0 -30
- package/src/lib/lib/atomix-snackbar/atomix-snackbar.component.html +0 -4
- package/src/lib/lib/atomix-snackbar/atomix-snackbar.component.spec.ts +0 -60
- package/src/lib/lib/atomix-snackbar/atomix-snackbar.component.ts +0 -27
- package/src/lib/lib/atomix-spinner/atomix-spinner.component.css +0 -0
- package/src/lib/lib/atomix-spinner/atomix-spinner.component.html +0 -7
- package/src/lib/lib/atomix-spinner/atomix-spinner.component.spec.ts +0 -70
- package/src/lib/lib/atomix-spinner/atomix-spinner.component.ts +0 -13
- package/src/lib/lib/atomix-steps/atomix-steps.component.html +0 -9
- package/src/lib/lib/atomix-steps/atomix-steps.component.scss +0 -0
- package/src/lib/lib/atomix-steps/atomix-steps.component.spec.ts +0 -120
- package/src/lib/lib/atomix-steps/atomix-steps.component.ts +0 -32
- package/src/lib/lib/atomix-tabMenu/atomix-tabMenu.component.css +0 -0
- package/src/lib/lib/atomix-tabMenu/atomix-tabMenu.component.html +0 -26
- package/src/lib/lib/atomix-tabMenu/atomix-tabMenu.component.spec.ts +0 -106
- package/src/lib/lib/atomix-tabMenu/atomix-tabMenu.component.ts +0 -36
- package/src/lib/lib/atomix-table/atomix-table.component.css +0 -152
- package/src/lib/lib/atomix-table/atomix-table.component.html +0 -647
- package/src/lib/lib/atomix-table/atomix-table.component.spec.ts +0 -1648
- package/src/lib/lib/atomix-table/atomix-table.component.ts +0 -422
- package/src/lib/lib/atomix-table/atomix-table.models.ts +0 -39
- package/src/lib/lib/atomix-tag/atomix-tag.component.css +0 -0
- package/src/lib/lib/atomix-tag/atomix-tag.component.html +0 -6
- package/src/lib/lib/atomix-tag/atomix-tag.component.spec.ts +0 -47
- package/src/lib/lib/atomix-tag/atomix-tag.component.ts +0 -13
- package/src/lib/lib/utils/prime-icons.util.spec.ts +0 -21
- package/src/lib/lib/utils/prime-icons.util.ts +0 -11
- package/src/lib/primekit.component.spec.ts +0 -19
- package/src/lib/primekit.component.ts +0 -10
- package/src/lib/primekit.module.spec.ts +0 -155
- package/src/lib/primekit.module.ts +0 -183
- package/src/lib/primekit.service.spec.ts +0 -17
- package/src/lib/primekit.service.ts +0 -8
- package/tsconfig.lib.json +0 -13
- package/tsconfig.lib.prod.json +0 -11
- package/tsconfig.spec.json +0 -10
|
@@ -1,1465 +0,0 @@
|
|
|
1
|
-
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
|
2
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
3
|
-
import { DatePipe } from '@angular/common';
|
|
4
|
-
import { Renderer2 } from '@angular/core';
|
|
5
|
-
import { AtomixDaterangeCalendarComponent } from './atomix-daterange-calendar.component';
|
|
6
|
-
|
|
7
|
-
describe('AtomixDaterangeCalendarComponent', () => {
|
|
8
|
-
let component: AtomixDaterangeCalendarComponent;
|
|
9
|
-
let fixture: ComponentFixture<AtomixDaterangeCalendarComponent>;
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
TestBed.configureTestingModule({
|
|
13
|
-
declarations: [AtomixDaterangeCalendarComponent],
|
|
14
|
-
providers: [DatePipe, Renderer2],
|
|
15
|
-
schemas: [NO_ERRORS_SCHEMA],
|
|
16
|
-
});
|
|
17
|
-
fixture = TestBed.createComponent(AtomixDaterangeCalendarComponent);
|
|
18
|
-
component = fixture.componentInstance;
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('should create', () => {
|
|
22
|
-
expect(component).toBeTruthy();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('input property defaults', () => {
|
|
26
|
-
it('should have default placeholder as empty string', () => {
|
|
27
|
-
expect(component.placeholder).toBe('');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('should have default styleClass as empty string', () => {
|
|
31
|
-
expect(component.styleClass).toBe('');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('should have default selectionMode as range', () => {
|
|
35
|
-
expect(component.selectionMode).toBe('range');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should have default inputStyleClass as empty string', () => {
|
|
39
|
-
expect(component.inputStyleClass).toBe('');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should have default inline as false', () => {
|
|
43
|
-
expect(component.inline).toBe(false);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('should have default disabled as false', () => {
|
|
47
|
-
expect(component.disabled).toBe(false);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('should have default selectedDate as null', () => {
|
|
51
|
-
expect(component.selectedDate).toBeNull();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('should have default defaultPreset as null', () => {
|
|
55
|
-
expect(component.defaultPreset).toBeNull();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('should have default preservePreset as false', () => {
|
|
59
|
-
expect(component.preservePreset).toBe(false);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('should have default customRangeMode as false', () => {
|
|
63
|
-
expect(component.customRangeMode).toBe(false);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('should have default selectedPreset as null', () => {
|
|
67
|
-
expect(component.selectedPreset).toBeNull();
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
describe('input property binding', () => {
|
|
72
|
-
it('should accept placeholder input', () => {
|
|
73
|
-
component.placeholder = 'Select date range';
|
|
74
|
-
fixture.detectChanges();
|
|
75
|
-
expect(component.placeholder).toBe('Select date range');
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('should accept styleClass input', () => {
|
|
79
|
-
component.styleClass = 'custom-style';
|
|
80
|
-
fixture.detectChanges();
|
|
81
|
-
expect(component.styleClass).toBe('custom-style');
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('should accept disabled input', () => {
|
|
85
|
-
component.disabled = true;
|
|
86
|
-
fixture.detectChanges();
|
|
87
|
-
expect(component.disabled).toBe(true);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('should accept inline input', () => {
|
|
91
|
-
component.inline = true;
|
|
92
|
-
fixture.detectChanges();
|
|
93
|
-
expect(component.inline).toBe(true);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('should accept maxDate input', () => {
|
|
97
|
-
const maxDate = new Date(2025, 11, 31);
|
|
98
|
-
component.maxDate = maxDate;
|
|
99
|
-
fixture.detectChanges();
|
|
100
|
-
expect(component.maxDate).toBe(maxDate);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('should accept minDate input', () => {
|
|
104
|
-
const minDate = new Date(2020, 0, 1);
|
|
105
|
-
component.minDate = minDate;
|
|
106
|
-
fixture.detectChanges();
|
|
107
|
-
expect(component.minDate).toBe(minDate);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
describe('date range selection', () => {
|
|
112
|
-
it('should emit dateRangeChange when a complete range is selected via onModelChange', () => {
|
|
113
|
-
const emitSpy = jest.fn();
|
|
114
|
-
component.dateRangeChange.subscribe(emitSpy);
|
|
115
|
-
|
|
116
|
-
const start = new Date(2024, 0, 10);
|
|
117
|
-
const end = new Date(2024, 0, 20);
|
|
118
|
-
component.onModelChange([start, end]);
|
|
119
|
-
|
|
120
|
-
expect(emitSpy).toHaveBeenCalledWith([start, end]);
|
|
121
|
-
expect(component.selectedDate).toEqual([start, end]);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('should not emit dateRangeChange when only start date is selected (partial range)', () => {
|
|
125
|
-
const emitSpy = jest.fn();
|
|
126
|
-
component.dateRangeChange.subscribe(emitSpy);
|
|
127
|
-
|
|
128
|
-
const start = new Date(2024, 0, 10);
|
|
129
|
-
component.onModelChange([start]);
|
|
130
|
-
|
|
131
|
-
expect(emitSpy).not.toHaveBeenCalled();
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it('should emit dateRangeChange with null when selection is cleared via onModelChange', () => {
|
|
135
|
-
const emitSpy = jest.fn();
|
|
136
|
-
component.dateRangeChange.subscribe(emitSpy);
|
|
137
|
-
|
|
138
|
-
component.onModelChange(null);
|
|
139
|
-
|
|
140
|
-
expect(emitSpy).toHaveBeenCalledWith(null);
|
|
141
|
-
expect(component.selectedDate).toBeNull();
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('should update selectedPreset when range matches a known preset', () => {
|
|
145
|
-
const today = new Date();
|
|
146
|
-
const normalizedToday = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
147
|
-
component.onModelChange([normalizedToday, normalizedToday]);
|
|
148
|
-
|
|
149
|
-
expect(component.selectedPreset).toBe('today');
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it('should set selectedPreset to null for a custom range', () => {
|
|
153
|
-
const start = new Date(2024, 3, 5);
|
|
154
|
-
const end = new Date(2024, 3, 15);
|
|
155
|
-
component.onModelChange([start, end]);
|
|
156
|
-
|
|
157
|
-
expect(component.selectedPreset).toBeNull();
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
describe('preset application', () => {
|
|
162
|
-
it('should apply today preset correctly', () => {
|
|
163
|
-
const emitSpy = jest.fn();
|
|
164
|
-
component.dateRangeChange.subscribe(emitSpy);
|
|
165
|
-
|
|
166
|
-
component.applyPreset('today');
|
|
167
|
-
|
|
168
|
-
const today = new Date();
|
|
169
|
-
const expected = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
170
|
-
expect(component.selectedDate[0]).toEqual(expected);
|
|
171
|
-
expect(component.selectedDate[1]).toEqual(expected);
|
|
172
|
-
expect(component.selectedPreset).toBe('today');
|
|
173
|
-
expect(emitSpy).toHaveBeenCalled();
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it('should apply yesterday preset correctly', () => {
|
|
177
|
-
const emitSpy = jest.fn();
|
|
178
|
-
component.dateRangeChange.subscribe(emitSpy);
|
|
179
|
-
|
|
180
|
-
component.applyPreset('yesterday');
|
|
181
|
-
|
|
182
|
-
const today = new Date();
|
|
183
|
-
const yesterday = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
184
|
-
yesterday.setDate(yesterday.getDate() - 1);
|
|
185
|
-
expect(component.selectedDate[0]).toEqual(yesterday);
|
|
186
|
-
expect(component.selectedDate[1]).toEqual(yesterday);
|
|
187
|
-
expect(component.selectedPreset).toBe('yesterday');
|
|
188
|
-
expect(emitSpy).toHaveBeenCalled();
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it('should apply last7days preset correctly', () => {
|
|
192
|
-
const emitSpy = jest.fn();
|
|
193
|
-
component.dateRangeChange.subscribe(emitSpy);
|
|
194
|
-
|
|
195
|
-
component.applyPreset('last7days');
|
|
196
|
-
|
|
197
|
-
const today = new Date();
|
|
198
|
-
const end = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
199
|
-
const start = new Date(end);
|
|
200
|
-
start.setDate(end.getDate() - 6);
|
|
201
|
-
expect(component.selectedDate[0]).toEqual(start);
|
|
202
|
-
expect(component.selectedDate[1]).toEqual(end);
|
|
203
|
-
expect(component.selectedPreset).toBe('last7days');
|
|
204
|
-
expect(emitSpy).toHaveBeenCalled();
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
it('should apply last30days preset correctly', () => {
|
|
208
|
-
component.applyPreset('last30days');
|
|
209
|
-
|
|
210
|
-
const today = new Date();
|
|
211
|
-
const end = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
212
|
-
const start = new Date(end);
|
|
213
|
-
start.setDate(end.getDate() - 29);
|
|
214
|
-
expect(component.selectedDate[0]).toEqual(start);
|
|
215
|
-
expect(component.selectedDate[1]).toEqual(end);
|
|
216
|
-
expect(component.selectedPreset).toBe('last30days');
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it('should include preset metadata when preservePreset is true', () => {
|
|
220
|
-
component.preservePreset = true;
|
|
221
|
-
component.applyPreset('last7days');
|
|
222
|
-
|
|
223
|
-
expect(component.selectedDate.length).toBe(3);
|
|
224
|
-
expect(component.selectedDate[2]).toEqual({ presets: 'last7days' });
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
describe('clearDateRange', () => {
|
|
229
|
-
it('should clear selectedDate and emit null', () => {
|
|
230
|
-
const emitSpy = jest.fn();
|
|
231
|
-
component.dateRangeChange.subscribe(emitSpy);
|
|
232
|
-
|
|
233
|
-
component.selectedDate = [new Date(2024, 0, 1), new Date(2024, 0, 31)];
|
|
234
|
-
component.selectedPreset = 'custom';
|
|
235
|
-
component.customRangeMode = true;
|
|
236
|
-
|
|
237
|
-
component.clearDateRange();
|
|
238
|
-
|
|
239
|
-
expect(component.selectedDate).toBeNull();
|
|
240
|
-
expect(component.selectedPreset).toBeNull();
|
|
241
|
-
expect(component.customRangeMode).toBe(false);
|
|
242
|
-
expect(component.modelDate).toBeNull();
|
|
243
|
-
expect(emitSpy).toHaveBeenCalledWith(null);
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
describe('toggleCustomRange', () => {
|
|
248
|
-
it('should toggle customRangeMode to true and set preset to custom', () => {
|
|
249
|
-
component.customRangeMode = false;
|
|
250
|
-
component.toggleCustomRange();
|
|
251
|
-
|
|
252
|
-
expect(component.customRangeMode).toBe(true);
|
|
253
|
-
expect(component.selectedPreset).toBe('custom');
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
it('should toggle customRangeMode back to false', () => {
|
|
257
|
-
component.customRangeMode = true;
|
|
258
|
-
component.toggleCustomRange();
|
|
259
|
-
|
|
260
|
-
expect(component.customRangeMode).toBe(false);
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
describe('hasSelection', () => {
|
|
265
|
-
it('should return false when selectedDate is null', () => {
|
|
266
|
-
component.selectedDate = null;
|
|
267
|
-
expect(component.hasSelection).toBe(false);
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
it('should return false when selectedDate has only one date', () => {
|
|
271
|
-
component.selectedDate = [new Date(2024, 0, 1)];
|
|
272
|
-
expect(component.hasSelection).toBe(false);
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
it('should return true when selectedDate has two valid dates', () => {
|
|
276
|
-
component.selectedDate = [new Date(2024, 0, 1), new Date(2024, 0, 31)];
|
|
277
|
-
expect(component.hasSelection).toBe(true);
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
it('should return false when second date is null', () => {
|
|
281
|
-
component.selectedDate = [new Date(2024, 0, 1), null];
|
|
282
|
-
expect(component.hasSelection).toBe(false);
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
describe('getDateRangeLabel', () => {
|
|
287
|
-
it('should return empty string when no dates are selected', () => {
|
|
288
|
-
component.modelDate = null;
|
|
289
|
-
component.selectedDate = null;
|
|
290
|
-
expect(component.getDateRangeLabel()).toBe('');
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
it('should return start date with arrow when only start date is selected', () => {
|
|
294
|
-
const start = new Date(2024, 0, 15);
|
|
295
|
-
component.modelDate = [start, null] as any;
|
|
296
|
-
component.selectedDate = null;
|
|
297
|
-
|
|
298
|
-
const label = component.getDateRangeLabel();
|
|
299
|
-
expect(label).toContain('01/15/2024');
|
|
300
|
-
expect(label).toContain('\u2794');
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
it('should return full range label when both dates are selected', () => {
|
|
304
|
-
const start = new Date(2024, 0, 15);
|
|
305
|
-
const end = new Date(2024, 1, 20);
|
|
306
|
-
component.modelDate = [start, end];
|
|
307
|
-
|
|
308
|
-
const label = component.getDateRangeLabel();
|
|
309
|
-
expect(label).toContain('01/15/2024');
|
|
310
|
-
expect(label).toContain('02/20/2024');
|
|
311
|
-
expect(label).toContain('\u2794');
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
it('should return empty string when dateArray has no valid start or end', () => {
|
|
315
|
-
component.modelDate = [null, null] as any;
|
|
316
|
-
component.selectedDate = null;
|
|
317
|
-
expect(component.getDateRangeLabel()).toBe('');
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
it('should use selectedDate when modelDate is null', () => {
|
|
321
|
-
component.modelDate = null;
|
|
322
|
-
const start = new Date(2024, 5, 1);
|
|
323
|
-
const end = new Date(2024, 5, 30);
|
|
324
|
-
component.selectedDate = [start, end];
|
|
325
|
-
|
|
326
|
-
const label = component.getDateRangeLabel();
|
|
327
|
-
expect(label).toContain('06/01/2024');
|
|
328
|
-
expect(label).toContain('06/30/2024');
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
describe('ngOnChanges', () => {
|
|
333
|
-
it('should update selectedPreset when selectedDate changes to a known preset range', () => {
|
|
334
|
-
const today = new Date();
|
|
335
|
-
const normalizedToday = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
336
|
-
|
|
337
|
-
component.ngOnChanges({
|
|
338
|
-
selectedDate: {
|
|
339
|
-
currentValue: [normalizedToday, normalizedToday],
|
|
340
|
-
previousValue: null,
|
|
341
|
-
firstChange: true,
|
|
342
|
-
isFirstChange: () => true,
|
|
343
|
-
},
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
expect(component.selectedPreset).toBe('today');
|
|
347
|
-
expect(component.modelDate).toEqual([normalizedToday, normalizedToday]);
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
it('should set selectedPreset to custom for non-preset range', () => {
|
|
351
|
-
const start = new Date(2024, 3, 5);
|
|
352
|
-
const end = new Date(2024, 3, 15);
|
|
353
|
-
|
|
354
|
-
component.ngOnChanges({
|
|
355
|
-
selectedDate: {
|
|
356
|
-
currentValue: [start, end],
|
|
357
|
-
previousValue: null,
|
|
358
|
-
firstChange: true,
|
|
359
|
-
isFirstChange: () => true,
|
|
360
|
-
},
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
expect(component.selectedPreset).toBe('custom');
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
it('should reset selectedPreset when selectedDate is set to null', () => {
|
|
367
|
-
component.selectedPreset = 'today';
|
|
368
|
-
|
|
369
|
-
component.ngOnChanges({
|
|
370
|
-
selectedDate: {
|
|
371
|
-
currentValue: null,
|
|
372
|
-
previousValue: [new Date(), new Date()],
|
|
373
|
-
firstChange: false,
|
|
374
|
-
isFirstChange: () => false,
|
|
375
|
-
},
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
expect(component.selectedPreset).toBeNull();
|
|
379
|
-
expect(component.modelDate).toBeNull();
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
describe('onDateRangeChange', () => {
|
|
384
|
-
it('should emit dateRangeChange and detect preset', () => {
|
|
385
|
-
const emitSpy = jest.fn();
|
|
386
|
-
component.dateRangeChange.subscribe(emitSpy);
|
|
387
|
-
|
|
388
|
-
const today = new Date();
|
|
389
|
-
const normalizedToday = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
390
|
-
component.onDateRangeChange([normalizedToday, normalizedToday]);
|
|
391
|
-
|
|
392
|
-
expect(emitSpy).toHaveBeenCalledWith([normalizedToday, normalizedToday]);
|
|
393
|
-
expect(component.selectedPreset).toBe('today');
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
it('should reset selectedPreset when null is passed', () => {
|
|
397
|
-
component.selectedPreset = 'last7days';
|
|
398
|
-
component.onDateRangeChange(null);
|
|
399
|
-
|
|
400
|
-
expect(component.selectedPreset).toBeNull();
|
|
401
|
-
});
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
describe('detectPreset - partial matches', () => {
|
|
405
|
-
it('should return null when start matches yesterday but end does not', () => {
|
|
406
|
-
const today = new Date();
|
|
407
|
-
const yesterday = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
408
|
-
yesterday.setDate(yesterday.getDate() - 1);
|
|
409
|
-
// start is yesterday, end is today - not a preset
|
|
410
|
-
component.onDateRangeChange([yesterday, new Date(today.getFullYear(), today.getMonth(), today.getDate())]);
|
|
411
|
-
expect(component.selectedPreset).toBeNull();
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
it('should return null when start matches last7days start but end does not', () => {
|
|
415
|
-
const today = new Date();
|
|
416
|
-
const end = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
417
|
-
const start = new Date(end);
|
|
418
|
-
start.setDate(end.getDate() - 6);
|
|
419
|
-
// Use correct start but wrong end
|
|
420
|
-
const wrongEnd = new Date(end);
|
|
421
|
-
wrongEnd.setDate(wrongEnd.getDate() - 1);
|
|
422
|
-
component.onDateRangeChange([start, wrongEnd]);
|
|
423
|
-
expect(component.selectedPreset).toBeNull();
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
it('should return null when start matches last30days start but end does not', () => {
|
|
427
|
-
const today = new Date();
|
|
428
|
-
const end = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
429
|
-
const start = new Date(end);
|
|
430
|
-
start.setDate(end.getDate() - 29);
|
|
431
|
-
const wrongEnd = new Date(end);
|
|
432
|
-
wrongEnd.setDate(wrongEnd.getDate() - 1);
|
|
433
|
-
component.onDateRangeChange([start, wrongEnd]);
|
|
434
|
-
expect(component.selectedPreset).toBeNull();
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
it('should return null when start matches last3months start but end does not', () => {
|
|
438
|
-
const today = new Date();
|
|
439
|
-
const end = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
440
|
-
const start = new Date(end);
|
|
441
|
-
start.setMonth(end.getMonth() - 3);
|
|
442
|
-
const wrongEnd = new Date(end);
|
|
443
|
-
wrongEnd.setDate(wrongEnd.getDate() - 1);
|
|
444
|
-
component.onDateRangeChange([start, wrongEnd]);
|
|
445
|
-
expect(component.selectedPreset).toBeNull();
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
it('should return null when start matches last6months start but end does not', () => {
|
|
449
|
-
const today = new Date();
|
|
450
|
-
const end = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
451
|
-
const start = new Date(end);
|
|
452
|
-
start.setMonth(end.getMonth() - 6);
|
|
453
|
-
const wrongEnd = new Date(end);
|
|
454
|
-
wrongEnd.setDate(wrongEnd.getDate() - 1);
|
|
455
|
-
component.onDateRangeChange([start, wrongEnd]);
|
|
456
|
-
expect(component.selectedPreset).toBeNull();
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
it('should return null when start matches last1year start but end does not', () => {
|
|
460
|
-
const today = new Date();
|
|
461
|
-
const end = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
462
|
-
const start = new Date(end);
|
|
463
|
-
start.setFullYear(end.getFullYear() - 1);
|
|
464
|
-
const wrongEnd = new Date(end);
|
|
465
|
-
wrongEnd.setDate(wrongEnd.getDate() - 1);
|
|
466
|
-
component.onDateRangeChange([start, wrongEnd]);
|
|
467
|
-
expect(component.selectedPreset).toBeNull();
|
|
468
|
-
});
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
describe('enLocale', () => {
|
|
472
|
-
it('should have correct locale structure', () => {
|
|
473
|
-
expect(component.enLocale).toBeDefined();
|
|
474
|
-
expect(component.enLocale.firstDayOfWeek).toBe(0);
|
|
475
|
-
expect(component.enLocale.dayNames).toHaveLength(7);
|
|
476
|
-
expect(component.enLocale.dayNamesShort).toHaveLength(7);
|
|
477
|
-
expect(component.enLocale.dayNamesMin).toHaveLength(7);
|
|
478
|
-
expect(component.enLocale.monthNames).toHaveLength(12);
|
|
479
|
-
expect(component.enLocale.monthNamesShort).toHaveLength(12);
|
|
480
|
-
expect(component.enLocale.today).toBe('Today');
|
|
481
|
-
expect(component.enLocale.clear).toBe('Clear');
|
|
482
|
-
});
|
|
483
|
-
});
|
|
484
|
-
|
|
485
|
-
describe('ngOnInit', () => {
|
|
486
|
-
it('should apply defaultPreset when selectedDate is null and defaultPreset is set', () => {
|
|
487
|
-
component.selectedDate = null;
|
|
488
|
-
component.defaultPreset = 'today';
|
|
489
|
-
const spy = jest.spyOn(component, 'applyPreset');
|
|
490
|
-
|
|
491
|
-
component.ngOnInit();
|
|
492
|
-
|
|
493
|
-
expect(spy).toHaveBeenCalledWith('today');
|
|
494
|
-
});
|
|
495
|
-
|
|
496
|
-
it('should not apply defaultPreset when selectedDate is already set', () => {
|
|
497
|
-
component.selectedDate = [new Date(), new Date()];
|
|
498
|
-
component.defaultPreset = 'today';
|
|
499
|
-
const spy = jest.spyOn(component, 'applyPreset');
|
|
500
|
-
|
|
501
|
-
component.ngOnInit();
|
|
502
|
-
|
|
503
|
-
expect(spy).not.toHaveBeenCalled();
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
it('should not apply defaultPreset when defaultPreset is null', () => {
|
|
507
|
-
component.selectedDate = null;
|
|
508
|
-
component.defaultPreset = null;
|
|
509
|
-
const spy = jest.spyOn(component, 'applyPreset');
|
|
510
|
-
|
|
511
|
-
component.ngOnInit();
|
|
512
|
-
|
|
513
|
-
expect(spy).not.toHaveBeenCalled();
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
it('should initialize modelDate from selectedDate', () => {
|
|
517
|
-
const start = new Date(2024, 0, 1);
|
|
518
|
-
const end = new Date(2024, 0, 31);
|
|
519
|
-
component.selectedDate = [start, end];
|
|
520
|
-
|
|
521
|
-
component.ngOnInit();
|
|
522
|
-
|
|
523
|
-
expect(component.modelDate).toEqual([start, end]);
|
|
524
|
-
});
|
|
525
|
-
|
|
526
|
-
it('should initialize modelDate as null when selectedDate is null', () => {
|
|
527
|
-
component.selectedDate = null;
|
|
528
|
-
|
|
529
|
-
component.ngOnInit();
|
|
530
|
-
|
|
531
|
-
expect(component.modelDate).toBeNull();
|
|
532
|
-
});
|
|
533
|
-
});
|
|
534
|
-
|
|
535
|
-
describe('applyPreset - remaining presets', () => {
|
|
536
|
-
it('should apply last3months preset correctly', () => {
|
|
537
|
-
component.applyPreset('last3months');
|
|
538
|
-
|
|
539
|
-
const today = new Date();
|
|
540
|
-
const end = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
541
|
-
const start = new Date(end);
|
|
542
|
-
start.setMonth(end.getMonth() - 3);
|
|
543
|
-
expect(component.selectedDate[0]).toEqual(start);
|
|
544
|
-
expect(component.selectedDate[1]).toEqual(end);
|
|
545
|
-
expect(component.selectedPreset).toBe('last3months');
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
it('should apply last6months preset correctly', () => {
|
|
549
|
-
component.applyPreset('last6months');
|
|
550
|
-
|
|
551
|
-
const today = new Date();
|
|
552
|
-
const end = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
553
|
-
const start = new Date(end);
|
|
554
|
-
start.setMonth(end.getMonth() - 6);
|
|
555
|
-
expect(component.selectedDate[0]).toEqual(start);
|
|
556
|
-
expect(component.selectedDate[1]).toEqual(end);
|
|
557
|
-
expect(component.selectedPreset).toBe('last6months');
|
|
558
|
-
});
|
|
559
|
-
|
|
560
|
-
it('should apply last1year preset correctly', () => {
|
|
561
|
-
component.applyPreset('last1year');
|
|
562
|
-
|
|
563
|
-
const today = new Date();
|
|
564
|
-
const end = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
565
|
-
const start = new Date(end);
|
|
566
|
-
start.setFullYear(end.getFullYear() - 1);
|
|
567
|
-
expect(component.selectedDate[0]).toEqual(start);
|
|
568
|
-
expect(component.selectedDate[1]).toEqual(end);
|
|
569
|
-
expect(component.selectedPreset).toBe('last1year');
|
|
570
|
-
});
|
|
571
|
-
|
|
572
|
-
it('should set customRangeMode to false after applying preset', () => {
|
|
573
|
-
component.customRangeMode = true;
|
|
574
|
-
component.applyPreset('today');
|
|
575
|
-
expect(component.customRangeMode).toBe(false);
|
|
576
|
-
});
|
|
577
|
-
});
|
|
578
|
-
|
|
579
|
-
describe('onOverlayShow', () => {
|
|
580
|
-
it('should store initial date and preset when overlay opens with selection', () => {
|
|
581
|
-
const start = new Date(2024, 0, 1);
|
|
582
|
-
const end = new Date(2024, 0, 31);
|
|
583
|
-
component.selectedDate = [start, end];
|
|
584
|
-
component.selectedPreset = 'custom';
|
|
585
|
-
|
|
586
|
-
component.onOverlayShow();
|
|
587
|
-
|
|
588
|
-
expect(component.modelDate).toEqual([start, end]);
|
|
589
|
-
});
|
|
590
|
-
|
|
591
|
-
it('should handle null selectedDate when overlay opens', () => {
|
|
592
|
-
component.selectedDate = null;
|
|
593
|
-
|
|
594
|
-
component.onOverlayShow();
|
|
595
|
-
|
|
596
|
-
expect(component.modelDate).toBeNull();
|
|
597
|
-
});
|
|
598
|
-
|
|
599
|
-
it('should detect preset when overlay opens with a preset range', () => {
|
|
600
|
-
const today = new Date();
|
|
601
|
-
const normalizedToday = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
602
|
-
component.selectedDate = [normalizedToday, normalizedToday];
|
|
603
|
-
|
|
604
|
-
component.onOverlayShow();
|
|
605
|
-
|
|
606
|
-
expect(component.selectedPreset).toBe('today');
|
|
607
|
-
});
|
|
608
|
-
|
|
609
|
-
it('should handle selectedDate array with null elements', () => {
|
|
610
|
-
// When selectedDate has a start but no end (length 1), it's not a complete range
|
|
611
|
-
component.selectedDate = [new Date(2024, 0, 1)];
|
|
612
|
-
|
|
613
|
-
component.onOverlayShow();
|
|
614
|
-
|
|
615
|
-
// modelDate is synced from selectedDate
|
|
616
|
-
expect(component.modelDate).toEqual([new Date(2024, 0, 1)]);
|
|
617
|
-
// selectedPreset should be null since the range is incomplete
|
|
618
|
-
expect(component.selectedPreset).toBeNull();
|
|
619
|
-
});
|
|
620
|
-
|
|
621
|
-
it('should set selectedPreset to null when overlay opens with no selection', () => {
|
|
622
|
-
component.selectedDate = null;
|
|
623
|
-
component.selectedPreset = 'today';
|
|
624
|
-
|
|
625
|
-
component.onOverlayShow();
|
|
626
|
-
|
|
627
|
-
expect(component.selectedPreset).toBeNull();
|
|
628
|
-
});
|
|
629
|
-
});
|
|
630
|
-
|
|
631
|
-
describe('onOverlayHide', () => {
|
|
632
|
-
it('should revert to initial selection when model has partial range', () => {
|
|
633
|
-
const start = new Date(2024, 0, 1);
|
|
634
|
-
const end = new Date(2024, 0, 31);
|
|
635
|
-
component.selectedDate = [start, end];
|
|
636
|
-
component.selectedPreset = 'custom';
|
|
637
|
-
|
|
638
|
-
// Simulate overlay open (stores initial state)
|
|
639
|
-
component.onOverlayShow();
|
|
640
|
-
|
|
641
|
-
// Simulate partial selection (user clicked one date but didn't complete range)
|
|
642
|
-
component.modelDate = [new Date(2024, 2, 5), null] as any;
|
|
643
|
-
|
|
644
|
-
component.onOverlayHide();
|
|
645
|
-
|
|
646
|
-
// Should revert to initial selection
|
|
647
|
-
expect(component.selectedDate).toBeTruthy();
|
|
648
|
-
expect(component.customRangeMode).toBe(false);
|
|
649
|
-
});
|
|
650
|
-
|
|
651
|
-
it('should not revert when model has complete range', () => {
|
|
652
|
-
const start = new Date(2024, 0, 1);
|
|
653
|
-
const end = new Date(2024, 0, 31);
|
|
654
|
-
component.selectedDate = [start, end];
|
|
655
|
-
|
|
656
|
-
component.onOverlayShow();
|
|
657
|
-
|
|
658
|
-
// Complete range in model
|
|
659
|
-
component.modelDate = [new Date(2024, 2, 1), new Date(2024, 2, 15)];
|
|
660
|
-
|
|
661
|
-
component.onOverlayHide();
|
|
662
|
-
|
|
663
|
-
expect(component.customRangeMode).toBe(false);
|
|
664
|
-
});
|
|
665
|
-
|
|
666
|
-
it('should reset customRangeMode on hide', () => {
|
|
667
|
-
component.customRangeMode = true;
|
|
668
|
-
component.modelDate = [new Date(2024, 0, 1), new Date(2024, 0, 31)];
|
|
669
|
-
|
|
670
|
-
component.onOverlayHide();
|
|
671
|
-
|
|
672
|
-
expect(component.customRangeMode).toBe(false);
|
|
673
|
-
});
|
|
674
|
-
});
|
|
675
|
-
|
|
676
|
-
describe('onInputKeyDown', () => {
|
|
677
|
-
it('should call overlayPanel.toggle on Enter key', () => {
|
|
678
|
-
const mockOverlayPanel = { toggle: jest.fn() };
|
|
679
|
-
component.overlayPanel = mockOverlayPanel as any;
|
|
680
|
-
|
|
681
|
-
const event = { key: 'Enter', preventDefault: jest.fn() } as any;
|
|
682
|
-
component.onInputKeyDown(event);
|
|
683
|
-
|
|
684
|
-
expect(mockOverlayPanel.toggle).toHaveBeenCalled();
|
|
685
|
-
expect(event.preventDefault).toHaveBeenCalled();
|
|
686
|
-
});
|
|
687
|
-
|
|
688
|
-
it('should call overlayPanel.toggle on Space key', () => {
|
|
689
|
-
const mockOverlayPanel = { toggle: jest.fn() };
|
|
690
|
-
component.overlayPanel = mockOverlayPanel as any;
|
|
691
|
-
|
|
692
|
-
const event = { key: ' ', preventDefault: jest.fn() } as any;
|
|
693
|
-
component.onInputKeyDown(event);
|
|
694
|
-
|
|
695
|
-
expect(mockOverlayPanel.toggle).toHaveBeenCalled();
|
|
696
|
-
expect(event.preventDefault).toHaveBeenCalled();
|
|
697
|
-
});
|
|
698
|
-
|
|
699
|
-
it('should not call overlayPanel.toggle on other keys', () => {
|
|
700
|
-
const mockOverlayPanel = { toggle: jest.fn() };
|
|
701
|
-
component.overlayPanel = mockOverlayPanel as any;
|
|
702
|
-
|
|
703
|
-
const event = { key: 'a', preventDefault: jest.fn() } as any;
|
|
704
|
-
component.onInputKeyDown(event);
|
|
705
|
-
|
|
706
|
-
expect(mockOverlayPanel.toggle).not.toHaveBeenCalled();
|
|
707
|
-
expect(event.preventDefault).not.toHaveBeenCalled();
|
|
708
|
-
});
|
|
709
|
-
});
|
|
710
|
-
|
|
711
|
-
describe('resetAndClose', () => {
|
|
712
|
-
it('should clear date range and hide overlay', () => {
|
|
713
|
-
const mockOverlayPanel = { hide: jest.fn() };
|
|
714
|
-
component.overlayPanel = mockOverlayPanel as any;
|
|
715
|
-
component.selectedDate = [new Date(), new Date()];
|
|
716
|
-
|
|
717
|
-
component.resetAndClose();
|
|
718
|
-
|
|
719
|
-
expect(component.selectedDate).toBeNull();
|
|
720
|
-
expect(mockOverlayPanel.hide).toHaveBeenCalled();
|
|
721
|
-
});
|
|
722
|
-
|
|
723
|
-
it('should work without overlayPanel', () => {
|
|
724
|
-
component.overlayPanel = undefined;
|
|
725
|
-
component.selectedDate = [new Date(), new Date()];
|
|
726
|
-
|
|
727
|
-
expect(() => component.resetAndClose()).not.toThrow();
|
|
728
|
-
expect(component.selectedDate).toBeNull();
|
|
729
|
-
});
|
|
730
|
-
});
|
|
731
|
-
|
|
732
|
-
describe('clearAndStop', () => {
|
|
733
|
-
it('should clear date range, hide overlay, and stop event propagation', () => {
|
|
734
|
-
const mockOverlayPanel = { hide: jest.fn() };
|
|
735
|
-
component.overlayPanel = mockOverlayPanel as any;
|
|
736
|
-
component.selectedDate = [new Date(), new Date()];
|
|
737
|
-
const event = { stopPropagation: jest.fn() } as any;
|
|
738
|
-
|
|
739
|
-
component.clearAndStop(event);
|
|
740
|
-
|
|
741
|
-
expect(component.selectedDate).toBeNull();
|
|
742
|
-
expect(mockOverlayPanel.hide).toHaveBeenCalled();
|
|
743
|
-
expect(event.stopPropagation).toHaveBeenCalled();
|
|
744
|
-
});
|
|
745
|
-
});
|
|
746
|
-
|
|
747
|
-
describe('applyCustomRange', () => {
|
|
748
|
-
it('should sync selectedDate from modelDate and emit', () => {
|
|
749
|
-
const emitSpy = jest.fn();
|
|
750
|
-
component.dateRangeChange.subscribe(emitSpy);
|
|
751
|
-
const start = new Date(2024, 0, 1);
|
|
752
|
-
const end = new Date(2024, 0, 31);
|
|
753
|
-
component.modelDate = [start, end];
|
|
754
|
-
const mockOverlayPanel = { hide: jest.fn() };
|
|
755
|
-
component.overlayPanel = mockOverlayPanel as any;
|
|
756
|
-
|
|
757
|
-
component.applyCustomRange();
|
|
758
|
-
|
|
759
|
-
expect(component.selectedDate).toEqual([start, end]);
|
|
760
|
-
expect(emitSpy).toHaveBeenCalledWith([start, end]);
|
|
761
|
-
expect(component.customRangeMode).toBe(false);
|
|
762
|
-
expect(component.selectedPreset).toBe('custom');
|
|
763
|
-
expect(mockOverlayPanel.hide).toHaveBeenCalled();
|
|
764
|
-
});
|
|
765
|
-
|
|
766
|
-
it('should handle null modelDate', () => {
|
|
767
|
-
const emitSpy = jest.fn();
|
|
768
|
-
component.dateRangeChange.subscribe(emitSpy);
|
|
769
|
-
component.modelDate = null;
|
|
770
|
-
|
|
771
|
-
component.applyCustomRange();
|
|
772
|
-
|
|
773
|
-
expect(component.selectedDate).toBeNull();
|
|
774
|
-
expect(emitSpy).toHaveBeenCalledWith(null);
|
|
775
|
-
});
|
|
776
|
-
});
|
|
777
|
-
|
|
778
|
-
describe('onCalendarViewChanged', () => {
|
|
779
|
-
it('should not throw when called', () => {
|
|
780
|
-
jest.useFakeTimers();
|
|
781
|
-
expect(() => component.onCalendarViewChanged()).not.toThrow();
|
|
782
|
-
jest.runAllTimers();
|
|
783
|
-
jest.useRealTimers();
|
|
784
|
-
});
|
|
785
|
-
});
|
|
786
|
-
|
|
787
|
-
describe('ngOnDestroy', () => {
|
|
788
|
-
it('should not throw when called', () => {
|
|
789
|
-
expect(() => component.ngOnDestroy()).not.toThrow();
|
|
790
|
-
});
|
|
791
|
-
|
|
792
|
-
it('should cancel scheduled updates', () => {
|
|
793
|
-
const cancelSpy = jest.spyOn(window, 'cancelAnimationFrame');
|
|
794
|
-
// Force a scheduled update
|
|
795
|
-
(component as any)._updateRafId = 123;
|
|
796
|
-
component.ngOnDestroy();
|
|
797
|
-
expect(cancelSpy).toHaveBeenCalledWith(123);
|
|
798
|
-
cancelSpy.mockRestore();
|
|
799
|
-
});
|
|
800
|
-
});
|
|
801
|
-
|
|
802
|
-
describe('onModelChange - partial range', () => {
|
|
803
|
-
it('should set selectedPreset to null for partial range (single date)', () => {
|
|
804
|
-
const start = new Date(2024, 0, 10);
|
|
805
|
-
component.onModelChange([start]);
|
|
806
|
-
|
|
807
|
-
expect(component.selectedPreset).toBeNull();
|
|
808
|
-
expect(component.customRangeMode).toBe(false);
|
|
809
|
-
});
|
|
810
|
-
});
|
|
811
|
-
|
|
812
|
-
describe('private _scheduleUpdate', () => {
|
|
813
|
-
it('should schedule a requestAnimationFrame', () => {
|
|
814
|
-
const rafSpy = jest.spyOn(window, 'requestAnimationFrame').mockReturnValue(42);
|
|
815
|
-
(component as any)._scheduleUpdate();
|
|
816
|
-
expect(rafSpy).toHaveBeenCalled();
|
|
817
|
-
expect((component as any)._updateRafId).toBe(42);
|
|
818
|
-
rafSpy.mockRestore();
|
|
819
|
-
});
|
|
820
|
-
|
|
821
|
-
it('should not schedule if already scheduled', () => {
|
|
822
|
-
(component as any)._updateRafId = 99;
|
|
823
|
-
const rafSpy = jest.spyOn(window, 'requestAnimationFrame');
|
|
824
|
-
(component as any)._scheduleUpdate();
|
|
825
|
-
expect(rafSpy).not.toHaveBeenCalled();
|
|
826
|
-
rafSpy.mockRestore();
|
|
827
|
-
});
|
|
828
|
-
});
|
|
829
|
-
|
|
830
|
-
describe('private _cancelScheduledUpdate', () => {
|
|
831
|
-
it('should cancel if updateRafId is set', () => {
|
|
832
|
-
const cancelSpy = jest.spyOn(window, 'cancelAnimationFrame');
|
|
833
|
-
(component as any)._updateRafId = 55;
|
|
834
|
-
(component as any)._cancelScheduledUpdate();
|
|
835
|
-
expect(cancelSpy).toHaveBeenCalledWith(55);
|
|
836
|
-
expect((component as any)._updateRafId).toBeNull();
|
|
837
|
-
cancelSpy.mockRestore();
|
|
838
|
-
});
|
|
839
|
-
|
|
840
|
-
it('should do nothing if updateRafId is null', () => {
|
|
841
|
-
const cancelSpy = jest.spyOn(window, 'cancelAnimationFrame');
|
|
842
|
-
(component as any)._updateRafId = null;
|
|
843
|
-
(component as any)._cancelScheduledUpdate();
|
|
844
|
-
expect(cancelSpy).not.toHaveBeenCalled();
|
|
845
|
-
cancelSpy.mockRestore();
|
|
846
|
-
});
|
|
847
|
-
});
|
|
848
|
-
|
|
849
|
-
describe('private _getCalendarElements', () => {
|
|
850
|
-
it('should return empty array when no calendar elements exist in DOM', () => {
|
|
851
|
-
const result = (component as any)._getCalendarElements();
|
|
852
|
-
expect(result).toEqual([]);
|
|
853
|
-
});
|
|
854
|
-
|
|
855
|
-
it('should find overlay calendar element', () => {
|
|
856
|
-
const container = document.createElement('div');
|
|
857
|
-
container.className = 'atomix-overlay-calendar';
|
|
858
|
-
const datepicker = document.createElement('div');
|
|
859
|
-
datepicker.className = 'p-datepicker';
|
|
860
|
-
container.appendChild(datepicker);
|
|
861
|
-
document.body.appendChild(container);
|
|
862
|
-
|
|
863
|
-
const result = (component as any)._getCalendarElements();
|
|
864
|
-
expect(result.length).toBeGreaterThan(0);
|
|
865
|
-
|
|
866
|
-
document.body.removeChild(container);
|
|
867
|
-
});
|
|
868
|
-
|
|
869
|
-
it('should find inline calendar element', () => {
|
|
870
|
-
const container = document.createElement('div');
|
|
871
|
-
container.className = 'inline-calendar';
|
|
872
|
-
const datepicker = document.createElement('div');
|
|
873
|
-
datepicker.className = 'p-datepicker';
|
|
874
|
-
container.appendChild(datepicker);
|
|
875
|
-
document.body.appendChild(container);
|
|
876
|
-
|
|
877
|
-
const result = (component as any)._getCalendarElements();
|
|
878
|
-
expect(result.length).toBeGreaterThan(0);
|
|
879
|
-
|
|
880
|
-
document.body.removeChild(container);
|
|
881
|
-
});
|
|
882
|
-
|
|
883
|
-
it('should find element from overlayPanel', () => {
|
|
884
|
-
const datepicker = document.createElement('div');
|
|
885
|
-
datepicker.className = 'p-datepicker';
|
|
886
|
-
const nativeEl = document.createElement('div');
|
|
887
|
-
nativeEl.appendChild(datepicker);
|
|
888
|
-
component.overlayPanel = { el: { nativeElement: nativeEl } } as any;
|
|
889
|
-
|
|
890
|
-
const result = (component as any)._getCalendarElements();
|
|
891
|
-
expect(result).toContain(datepicker);
|
|
892
|
-
});
|
|
893
|
-
});
|
|
894
|
-
|
|
895
|
-
describe('private _stopCalendarObservers', () => {
|
|
896
|
-
it('should disconnect all observers and clear arrays', () => {
|
|
897
|
-
const mockObs = { disconnect: jest.fn() };
|
|
898
|
-
(component as any)._calendarObservers = [mockObs];
|
|
899
|
-
(component as any)._parentObservers = [mockObs];
|
|
900
|
-
(component as any)._observedElements = [document.createElement('div')];
|
|
901
|
-
(component as any)._observedParentElements = [document.createElement('div')];
|
|
902
|
-
|
|
903
|
-
(component as any)._stopCalendarObservers();
|
|
904
|
-
|
|
905
|
-
expect(mockObs.disconnect).toHaveBeenCalledTimes(2);
|
|
906
|
-
expect((component as any)._calendarObservers).toEqual([]);
|
|
907
|
-
expect((component as any)._parentObservers).toEqual([]);
|
|
908
|
-
expect((component as any)._observedElements).toEqual([]);
|
|
909
|
-
expect((component as any)._observedParentElements).toEqual([]);
|
|
910
|
-
});
|
|
911
|
-
});
|
|
912
|
-
|
|
913
|
-
describe('private _startCalendarObservers', () => {
|
|
914
|
-
it('should set up mutation observers on calendar elements', () => {
|
|
915
|
-
const container = document.createElement('div');
|
|
916
|
-
container.className = 'atomix-overlay-calendar';
|
|
917
|
-
const datepicker = document.createElement('div');
|
|
918
|
-
datepicker.className = 'p-datepicker';
|
|
919
|
-
const parent = document.createElement('div');
|
|
920
|
-
parent.appendChild(datepicker);
|
|
921
|
-
container.appendChild(parent);
|
|
922
|
-
document.body.appendChild(container);
|
|
923
|
-
|
|
924
|
-
(component as any)._startCalendarObservers();
|
|
925
|
-
|
|
926
|
-
expect((component as any)._calendarObservers.length).toBeGreaterThan(0);
|
|
927
|
-
|
|
928
|
-
(component as any)._stopCalendarObservers();
|
|
929
|
-
document.body.removeChild(container);
|
|
930
|
-
});
|
|
931
|
-
|
|
932
|
-
it('should find datepicker from overlayPanel', () => {
|
|
933
|
-
const datepicker = document.createElement('div');
|
|
934
|
-
datepicker.className = 'p-datepicker';
|
|
935
|
-
const nativeEl = document.createElement('div');
|
|
936
|
-
nativeEl.appendChild(datepicker);
|
|
937
|
-
component.overlayPanel = { el: { nativeElement: nativeEl } } as any;
|
|
938
|
-
|
|
939
|
-
(component as any)._startCalendarObservers();
|
|
940
|
-
|
|
941
|
-
expect((component as any)._calendarObservers.length).toBeGreaterThan(0);
|
|
942
|
-
|
|
943
|
-
(component as any)._stopCalendarObservers();
|
|
944
|
-
});
|
|
945
|
-
|
|
946
|
-
it('should handle overlayPanel without datepicker element', () => {
|
|
947
|
-
const nativeEl = document.createElement('div');
|
|
948
|
-
component.overlayPanel = { el: { nativeElement: nativeEl } } as any;
|
|
949
|
-
|
|
950
|
-
expect(() => (component as any)._startCalendarObservers()).not.toThrow();
|
|
951
|
-
});
|
|
952
|
-
|
|
953
|
-
it('should set up parent observers', () => {
|
|
954
|
-
const container = document.createElement('div');
|
|
955
|
-
container.className = 'atomix-overlay-calendar';
|
|
956
|
-
const parent = document.createElement('div');
|
|
957
|
-
const datepicker = document.createElement('div');
|
|
958
|
-
datepicker.className = 'p-datepicker';
|
|
959
|
-
parent.appendChild(datepicker);
|
|
960
|
-
container.appendChild(parent);
|
|
961
|
-
document.body.appendChild(container);
|
|
962
|
-
|
|
963
|
-
(component as any)._startCalendarObservers();
|
|
964
|
-
|
|
965
|
-
expect((component as any)._parentObservers.length).toBeGreaterThan(0);
|
|
966
|
-
|
|
967
|
-
(component as any)._stopCalendarObservers();
|
|
968
|
-
document.body.removeChild(container);
|
|
969
|
-
});
|
|
970
|
-
|
|
971
|
-
it('should schedule update when child DOM changes', (done) => {
|
|
972
|
-
const container = document.createElement('div');
|
|
973
|
-
container.className = 'atomix-overlay-calendar';
|
|
974
|
-
const parent = document.createElement('div');
|
|
975
|
-
const datepicker = document.createElement('div');
|
|
976
|
-
datepicker.className = 'p-datepicker';
|
|
977
|
-
parent.appendChild(datepicker);
|
|
978
|
-
container.appendChild(parent);
|
|
979
|
-
document.body.appendChild(container);
|
|
980
|
-
|
|
981
|
-
const scheduleSpy = jest.spyOn(component as any, '_scheduleUpdate');
|
|
982
|
-
(component as any)._startCalendarObservers();
|
|
983
|
-
|
|
984
|
-
// Trigger a DOM mutation inside the datepicker
|
|
985
|
-
const newChild = document.createElement('span');
|
|
986
|
-
datepicker.appendChild(newChild);
|
|
987
|
-
|
|
988
|
-
// MutationObserver callbacks are async
|
|
989
|
-
setTimeout(() => {
|
|
990
|
-
expect(scheduleSpy).toHaveBeenCalled();
|
|
991
|
-
(component as any)._stopCalendarObservers();
|
|
992
|
-
document.body.removeChild(container);
|
|
993
|
-
done();
|
|
994
|
-
}, 50);
|
|
995
|
-
});
|
|
996
|
-
|
|
997
|
-
it('should schedule update and reattach when parent DOM changes', (done) => {
|
|
998
|
-
jest.useFakeTimers();
|
|
999
|
-
const container = document.createElement('div');
|
|
1000
|
-
container.className = 'atomix-overlay-calendar';
|
|
1001
|
-
const parent = document.createElement('div');
|
|
1002
|
-
const datepicker = document.createElement('div');
|
|
1003
|
-
datepicker.className = 'p-datepicker';
|
|
1004
|
-
parent.appendChild(datepicker);
|
|
1005
|
-
container.appendChild(parent);
|
|
1006
|
-
document.body.appendChild(container);
|
|
1007
|
-
|
|
1008
|
-
const scheduleSpy = jest.spyOn(component as any, '_scheduleUpdate');
|
|
1009
|
-
(component as any)._startCalendarObservers();
|
|
1010
|
-
|
|
1011
|
-
// Trigger a parent DOM mutation (adding a sibling to datepicker)
|
|
1012
|
-
const sibling = document.createElement('div');
|
|
1013
|
-
parent.appendChild(sibling);
|
|
1014
|
-
|
|
1015
|
-
// Use real timers for the MutationObserver callback
|
|
1016
|
-
jest.useRealTimers();
|
|
1017
|
-
setTimeout(() => {
|
|
1018
|
-
expect(scheduleSpy).toHaveBeenCalled();
|
|
1019
|
-
(component as any)._stopCalendarObservers();
|
|
1020
|
-
document.body.removeChild(container);
|
|
1021
|
-
done();
|
|
1022
|
-
}, 200);
|
|
1023
|
-
});
|
|
1024
|
-
});
|
|
1025
|
-
|
|
1026
|
-
describe('private _updateStartEndRangeClasses', () => {
|
|
1027
|
-
it('should add start-range and end-range classes to highlighted spans', () => {
|
|
1028
|
-
// Set up DOM with a calendar structure
|
|
1029
|
-
const container = document.createElement('div');
|
|
1030
|
-
container.className = 'atomix-overlay-calendar';
|
|
1031
|
-
const datepicker = document.createElement('div');
|
|
1032
|
-
datepicker.className = 'p-datepicker';
|
|
1033
|
-
|
|
1034
|
-
// Create header with month/year
|
|
1035
|
-
const header = document.createElement('div');
|
|
1036
|
-
header.className = 'p-datepicker-header';
|
|
1037
|
-
const title = document.createElement('div');
|
|
1038
|
-
title.className = 'p-datepicker-title';
|
|
1039
|
-
const monthEl = document.createElement('span');
|
|
1040
|
-
monthEl.className = 'p-datepicker-month';
|
|
1041
|
-
monthEl.textContent = 'January';
|
|
1042
|
-
const yearEl = document.createElement('span');
|
|
1043
|
-
yearEl.className = 'p-datepicker-year';
|
|
1044
|
-
yearEl.textContent = '2024';
|
|
1045
|
-
title.appendChild(monthEl);
|
|
1046
|
-
title.appendChild(yearEl);
|
|
1047
|
-
header.appendChild(title);
|
|
1048
|
-
datepicker.appendChild(header);
|
|
1049
|
-
|
|
1050
|
-
// Create table with highlighted spans
|
|
1051
|
-
const table = document.createElement('table');
|
|
1052
|
-
const tbody = document.createElement('tbody');
|
|
1053
|
-
const tr = document.createElement('tr');
|
|
1054
|
-
|
|
1055
|
-
const td1 = document.createElement('td');
|
|
1056
|
-
const span1 = document.createElement('span');
|
|
1057
|
-
span1.className = 'p-highlight';
|
|
1058
|
-
span1.textContent = '10';
|
|
1059
|
-
td1.appendChild(span1);
|
|
1060
|
-
tr.appendChild(td1);
|
|
1061
|
-
|
|
1062
|
-
const td2 = document.createElement('td');
|
|
1063
|
-
const span2 = document.createElement('span');
|
|
1064
|
-
span2.className = 'p-highlight';
|
|
1065
|
-
span2.textContent = '11';
|
|
1066
|
-
td2.appendChild(span2);
|
|
1067
|
-
tr.appendChild(td2);
|
|
1068
|
-
|
|
1069
|
-
const td3 = document.createElement('td');
|
|
1070
|
-
const span3 = document.createElement('span');
|
|
1071
|
-
span3.className = 'p-highlight';
|
|
1072
|
-
span3.textContent = '12';
|
|
1073
|
-
td3.appendChild(span3);
|
|
1074
|
-
tr.appendChild(td3);
|
|
1075
|
-
|
|
1076
|
-
tbody.appendChild(tr);
|
|
1077
|
-
table.appendChild(tbody);
|
|
1078
|
-
datepicker.appendChild(table);
|
|
1079
|
-
container.appendChild(datepicker);
|
|
1080
|
-
document.body.appendChild(container);
|
|
1081
|
-
|
|
1082
|
-
// Set selected date range
|
|
1083
|
-
component.selectedDate = [new Date(2024, 0, 10), new Date(2024, 0, 12)];
|
|
1084
|
-
|
|
1085
|
-
(component as any)._updateStartEndRangeClasses();
|
|
1086
|
-
|
|
1087
|
-
expect(span1.classList.contains('start-range')).toBe(true);
|
|
1088
|
-
expect(span2.classList.contains('between-range')).toBe(true);
|
|
1089
|
-
expect(span3.classList.contains('end-range')).toBe(true);
|
|
1090
|
-
|
|
1091
|
-
document.body.removeChild(container);
|
|
1092
|
-
});
|
|
1093
|
-
|
|
1094
|
-
it('should handle single-day range (same start and end)', () => {
|
|
1095
|
-
const container = document.createElement('div');
|
|
1096
|
-
container.className = 'atomix-overlay-calendar';
|
|
1097
|
-
const datepicker = document.createElement('div');
|
|
1098
|
-
datepicker.className = 'p-datepicker';
|
|
1099
|
-
|
|
1100
|
-
const header = document.createElement('div');
|
|
1101
|
-
header.className = 'p-datepicker-header';
|
|
1102
|
-
const title = document.createElement('div');
|
|
1103
|
-
title.className = 'p-datepicker-title';
|
|
1104
|
-
const monthEl = document.createElement('span');
|
|
1105
|
-
monthEl.className = 'p-datepicker-month';
|
|
1106
|
-
monthEl.textContent = 'January';
|
|
1107
|
-
const yearEl = document.createElement('span');
|
|
1108
|
-
yearEl.className = 'p-datepicker-year';
|
|
1109
|
-
yearEl.textContent = '2024';
|
|
1110
|
-
title.appendChild(monthEl);
|
|
1111
|
-
title.appendChild(yearEl);
|
|
1112
|
-
header.appendChild(title);
|
|
1113
|
-
datepicker.appendChild(header);
|
|
1114
|
-
|
|
1115
|
-
const table = document.createElement('table');
|
|
1116
|
-
const tbody = document.createElement('tbody');
|
|
1117
|
-
const tr = document.createElement('tr');
|
|
1118
|
-
const td1 = document.createElement('td');
|
|
1119
|
-
const span1 = document.createElement('span');
|
|
1120
|
-
span1.className = 'p-highlight';
|
|
1121
|
-
span1.textContent = '15';
|
|
1122
|
-
td1.appendChild(span1);
|
|
1123
|
-
tr.appendChild(td1);
|
|
1124
|
-
tbody.appendChild(tr);
|
|
1125
|
-
table.appendChild(tbody);
|
|
1126
|
-
datepicker.appendChild(table);
|
|
1127
|
-
container.appendChild(datepicker);
|
|
1128
|
-
document.body.appendChild(container);
|
|
1129
|
-
|
|
1130
|
-
component.selectedDate = [new Date(2024, 0, 15), new Date(2024, 0, 15)];
|
|
1131
|
-
|
|
1132
|
-
(component as any)._updateStartEndRangeClasses();
|
|
1133
|
-
|
|
1134
|
-
expect(span1.classList.contains('start-range')).toBe(true);
|
|
1135
|
-
expect(span1.classList.contains('end-range')).toBe(true);
|
|
1136
|
-
|
|
1137
|
-
document.body.removeChild(container);
|
|
1138
|
-
});
|
|
1139
|
-
|
|
1140
|
-
it('should handle data-date attribute on spans', () => {
|
|
1141
|
-
const container = document.createElement('div');
|
|
1142
|
-
container.className = 'atomix-overlay-calendar';
|
|
1143
|
-
const datepicker = document.createElement('div');
|
|
1144
|
-
datepicker.className = 'p-datepicker';
|
|
1145
|
-
|
|
1146
|
-
const table = document.createElement('table');
|
|
1147
|
-
const tbody = document.createElement('tbody');
|
|
1148
|
-
const tr = document.createElement('tr');
|
|
1149
|
-
|
|
1150
|
-
const td1 = document.createElement('td');
|
|
1151
|
-
const span1 = document.createElement('span');
|
|
1152
|
-
span1.className = 'p-highlight';
|
|
1153
|
-
span1.setAttribute('data-date', '2024-01-10');
|
|
1154
|
-
span1.textContent = '10';
|
|
1155
|
-
td1.appendChild(span1);
|
|
1156
|
-
tr.appendChild(td1);
|
|
1157
|
-
|
|
1158
|
-
const td2 = document.createElement('td');
|
|
1159
|
-
const span2 = document.createElement('span');
|
|
1160
|
-
span2.className = 'p-highlight';
|
|
1161
|
-
span2.setAttribute('data-date', '2024-01-12');
|
|
1162
|
-
span2.textContent = '12';
|
|
1163
|
-
td2.appendChild(span2);
|
|
1164
|
-
tr.appendChild(td2);
|
|
1165
|
-
|
|
1166
|
-
tbody.appendChild(tr);
|
|
1167
|
-
table.appendChild(tbody);
|
|
1168
|
-
datepicker.appendChild(table);
|
|
1169
|
-
container.appendChild(datepicker);
|
|
1170
|
-
document.body.appendChild(container);
|
|
1171
|
-
|
|
1172
|
-
component.selectedDate = [new Date(2024, 0, 10), new Date(2024, 0, 12)];
|
|
1173
|
-
|
|
1174
|
-
(component as any)._updateStartEndRangeClasses();
|
|
1175
|
-
|
|
1176
|
-
expect(span1.classList.contains('start-range')).toBe(true);
|
|
1177
|
-
expect(span2.classList.contains('end-range')).toBe(true);
|
|
1178
|
-
|
|
1179
|
-
document.body.removeChild(container);
|
|
1180
|
-
});
|
|
1181
|
-
|
|
1182
|
-
it('should handle data-date attribute on td elements', () => {
|
|
1183
|
-
const container = document.createElement('div');
|
|
1184
|
-
container.className = 'atomix-overlay-calendar';
|
|
1185
|
-
const datepicker = document.createElement('div');
|
|
1186
|
-
datepicker.className = 'p-datepicker';
|
|
1187
|
-
|
|
1188
|
-
const table = document.createElement('table');
|
|
1189
|
-
const tbody = document.createElement('tbody');
|
|
1190
|
-
const tr = document.createElement('tr');
|
|
1191
|
-
|
|
1192
|
-
const td1 = document.createElement('td');
|
|
1193
|
-
td1.setAttribute('data-date', '2024-02-05');
|
|
1194
|
-
const span1 = document.createElement('span');
|
|
1195
|
-
span1.className = 'p-highlight';
|
|
1196
|
-
span1.textContent = '5';
|
|
1197
|
-
td1.appendChild(span1);
|
|
1198
|
-
tr.appendChild(td1);
|
|
1199
|
-
|
|
1200
|
-
tbody.appendChild(tr);
|
|
1201
|
-
table.appendChild(tbody);
|
|
1202
|
-
datepicker.appendChild(table);
|
|
1203
|
-
container.appendChild(datepicker);
|
|
1204
|
-
document.body.appendChild(container);
|
|
1205
|
-
|
|
1206
|
-
component.selectedDate = [new Date(2024, 1, 5), new Date(2024, 1, 5)];
|
|
1207
|
-
|
|
1208
|
-
(component as any)._updateStartEndRangeClasses();
|
|
1209
|
-
|
|
1210
|
-
expect(span1.classList.contains('start-range')).toBe(true);
|
|
1211
|
-
|
|
1212
|
-
document.body.removeChild(container);
|
|
1213
|
-
});
|
|
1214
|
-
|
|
1215
|
-
it('should return early when no highlighted items found', () => {
|
|
1216
|
-
const container = document.createElement('div');
|
|
1217
|
-
container.className = 'atomix-overlay-calendar';
|
|
1218
|
-
const datepicker = document.createElement('div');
|
|
1219
|
-
datepicker.className = 'p-datepicker';
|
|
1220
|
-
container.appendChild(datepicker);
|
|
1221
|
-
document.body.appendChild(container);
|
|
1222
|
-
|
|
1223
|
-
// No highlighted spans - should not throw
|
|
1224
|
-
expect(() => (component as any)._updateStartEndRangeClasses()).not.toThrow();
|
|
1225
|
-
|
|
1226
|
-
document.body.removeChild(container);
|
|
1227
|
-
});
|
|
1228
|
-
|
|
1229
|
-
it('should use modelDate when selectedDate is not a 2-element array', () => {
|
|
1230
|
-
const container = document.createElement('div');
|
|
1231
|
-
container.className = 'atomix-overlay-calendar';
|
|
1232
|
-
const datepicker = document.createElement('div');
|
|
1233
|
-
datepicker.className = 'p-datepicker';
|
|
1234
|
-
|
|
1235
|
-
const header = document.createElement('div');
|
|
1236
|
-
header.className = 'p-datepicker-header';
|
|
1237
|
-
const title = document.createElement('div');
|
|
1238
|
-
title.className = 'p-datepicker-title';
|
|
1239
|
-
const monthEl = document.createElement('span');
|
|
1240
|
-
monthEl.className = 'p-datepicker-month';
|
|
1241
|
-
monthEl.textContent = 'March';
|
|
1242
|
-
const yearEl = document.createElement('span');
|
|
1243
|
-
yearEl.className = 'p-datepicker-year';
|
|
1244
|
-
yearEl.textContent = '2024';
|
|
1245
|
-
title.appendChild(monthEl);
|
|
1246
|
-
title.appendChild(yearEl);
|
|
1247
|
-
header.appendChild(title);
|
|
1248
|
-
datepicker.appendChild(header);
|
|
1249
|
-
|
|
1250
|
-
const table = document.createElement('table');
|
|
1251
|
-
const tbody = document.createElement('tbody');
|
|
1252
|
-
const tr = document.createElement('tr');
|
|
1253
|
-
const td1 = document.createElement('td');
|
|
1254
|
-
const span1 = document.createElement('span');
|
|
1255
|
-
span1.className = 'p-highlight';
|
|
1256
|
-
span1.textContent = '5';
|
|
1257
|
-
td1.appendChild(span1);
|
|
1258
|
-
tr.appendChild(td1);
|
|
1259
|
-
const td2 = document.createElement('td');
|
|
1260
|
-
const span2 = document.createElement('span');
|
|
1261
|
-
span2.className = 'p-highlight';
|
|
1262
|
-
span2.textContent = '10';
|
|
1263
|
-
td2.appendChild(span2);
|
|
1264
|
-
tr.appendChild(td2);
|
|
1265
|
-
tbody.appendChild(tr);
|
|
1266
|
-
table.appendChild(tbody);
|
|
1267
|
-
datepicker.appendChild(table);
|
|
1268
|
-
container.appendChild(datepicker);
|
|
1269
|
-
document.body.appendChild(container);
|
|
1270
|
-
|
|
1271
|
-
// Set selectedDate to null but modelDate to a valid range
|
|
1272
|
-
component.selectedDate = null;
|
|
1273
|
-
component.modelDate = [new Date(2024, 2, 5), new Date(2024, 2, 10)];
|
|
1274
|
-
|
|
1275
|
-
(component as any)._updateStartEndRangeClasses();
|
|
1276
|
-
|
|
1277
|
-
expect(span1.classList.contains('start-range')).toBe(true);
|
|
1278
|
-
expect(span2.classList.contains('end-range')).toBe(true);
|
|
1279
|
-
|
|
1280
|
-
document.body.removeChild(container);
|
|
1281
|
-
});
|
|
1282
|
-
|
|
1283
|
-
it('should fall back to detected range when neither selectedDate nor modelDate has 2 elements', () => {
|
|
1284
|
-
const container = document.createElement('div');
|
|
1285
|
-
container.className = 'atomix-overlay-calendar';
|
|
1286
|
-
const datepicker = document.createElement('div');
|
|
1287
|
-
datepicker.className = 'p-datepicker';
|
|
1288
|
-
|
|
1289
|
-
const header = document.createElement('div');
|
|
1290
|
-
header.className = 'p-datepicker-header';
|
|
1291
|
-
const title = document.createElement('div');
|
|
1292
|
-
title.className = 'p-datepicker-title';
|
|
1293
|
-
const monthEl = document.createElement('span');
|
|
1294
|
-
monthEl.className = 'p-datepicker-month';
|
|
1295
|
-
monthEl.textContent = 'February';
|
|
1296
|
-
const yearEl = document.createElement('span');
|
|
1297
|
-
yearEl.className = 'p-datepicker-year';
|
|
1298
|
-
yearEl.textContent = '2024';
|
|
1299
|
-
title.appendChild(monthEl);
|
|
1300
|
-
title.appendChild(yearEl);
|
|
1301
|
-
header.appendChild(title);
|
|
1302
|
-
datepicker.appendChild(header);
|
|
1303
|
-
|
|
1304
|
-
const table = document.createElement('table');
|
|
1305
|
-
const tbody = document.createElement('tbody');
|
|
1306
|
-
const tr = document.createElement('tr');
|
|
1307
|
-
const td1 = document.createElement('td');
|
|
1308
|
-
const span1 = document.createElement('span');
|
|
1309
|
-
span1.className = 'p-highlight';
|
|
1310
|
-
span1.textContent = '1';
|
|
1311
|
-
td1.appendChild(span1);
|
|
1312
|
-
tr.appendChild(td1);
|
|
1313
|
-
const td2 = document.createElement('td');
|
|
1314
|
-
const span2 = document.createElement('span');
|
|
1315
|
-
span2.className = 'p-highlight';
|
|
1316
|
-
span2.textContent = '28';
|
|
1317
|
-
td2.appendChild(span2);
|
|
1318
|
-
tr.appendChild(td2);
|
|
1319
|
-
tbody.appendChild(tr);
|
|
1320
|
-
table.appendChild(tbody);
|
|
1321
|
-
datepicker.appendChild(table);
|
|
1322
|
-
container.appendChild(datepicker);
|
|
1323
|
-
document.body.appendChild(container);
|
|
1324
|
-
|
|
1325
|
-
// Neither selectedDate nor modelDate has 2 elements
|
|
1326
|
-
component.selectedDate = null;
|
|
1327
|
-
component.modelDate = null;
|
|
1328
|
-
|
|
1329
|
-
(component as any)._updateStartEndRangeClasses();
|
|
1330
|
-
|
|
1331
|
-
// Should use detected start/end from the highlighted spans
|
|
1332
|
-
expect(span1.classList.contains('start-range')).toBe(true);
|
|
1333
|
-
expect(span2.classList.contains('end-range')).toBe(true);
|
|
1334
|
-
|
|
1335
|
-
document.body.removeChild(container);
|
|
1336
|
-
});
|
|
1337
|
-
|
|
1338
|
-
it('should handle span without textContent gracefully', () => {
|
|
1339
|
-
const container = document.createElement('div');
|
|
1340
|
-
container.className = 'atomix-overlay-calendar';
|
|
1341
|
-
const datepicker = document.createElement('div');
|
|
1342
|
-
datepicker.className = 'p-datepicker';
|
|
1343
|
-
|
|
1344
|
-
const header = document.createElement('div');
|
|
1345
|
-
header.className = 'p-datepicker-header';
|
|
1346
|
-
const title = document.createElement('div');
|
|
1347
|
-
title.className = 'p-datepicker-title';
|
|
1348
|
-
const monthEl = document.createElement('span');
|
|
1349
|
-
monthEl.className = 'p-datepicker-month';
|
|
1350
|
-
monthEl.textContent = 'January';
|
|
1351
|
-
const yearEl = document.createElement('span');
|
|
1352
|
-
yearEl.className = 'p-datepicker-year';
|
|
1353
|
-
yearEl.textContent = '2024';
|
|
1354
|
-
title.appendChild(monthEl);
|
|
1355
|
-
title.appendChild(yearEl);
|
|
1356
|
-
header.appendChild(title);
|
|
1357
|
-
datepicker.appendChild(header);
|
|
1358
|
-
|
|
1359
|
-
const table = document.createElement('table');
|
|
1360
|
-
const tbody = document.createElement('tbody');
|
|
1361
|
-
const tr = document.createElement('tr');
|
|
1362
|
-
const td1 = document.createElement('td');
|
|
1363
|
-
const span1 = document.createElement('span');
|
|
1364
|
-
span1.className = 'p-highlight';
|
|
1365
|
-
// No textContent - empty span
|
|
1366
|
-
td1.appendChild(span1);
|
|
1367
|
-
tr.appendChild(td1);
|
|
1368
|
-
tbody.appendChild(tr);
|
|
1369
|
-
table.appendChild(tbody);
|
|
1370
|
-
datepicker.appendChild(table);
|
|
1371
|
-
container.appendChild(datepicker);
|
|
1372
|
-
document.body.appendChild(container);
|
|
1373
|
-
|
|
1374
|
-
component.selectedDate = [new Date(2024, 0, 1), new Date(2024, 0, 31)];
|
|
1375
|
-
|
|
1376
|
-
// Should not throw even with empty span
|
|
1377
|
-
expect(() => (component as any)._updateStartEndRangeClasses()).not.toThrow();
|
|
1378
|
-
|
|
1379
|
-
document.body.removeChild(container);
|
|
1380
|
-
});
|
|
1381
|
-
});
|
|
1382
|
-
|
|
1383
|
-
describe('private _findElementByDate', () => {
|
|
1384
|
-
it('should return undefined when no date is provided', () => {
|
|
1385
|
-
const result = (component as any)._findElementByDate(undefined);
|
|
1386
|
-
expect(result).toBeUndefined();
|
|
1387
|
-
});
|
|
1388
|
-
|
|
1389
|
-
it('should return undefined when element is not found in DOM', () => {
|
|
1390
|
-
const result = (component as any)._findElementByDate(new Date(2024, 0, 15));
|
|
1391
|
-
expect(result).toBeUndefined();
|
|
1392
|
-
});
|
|
1393
|
-
|
|
1394
|
-
it('should find element by padded data-date in overlay', () => {
|
|
1395
|
-
const container = document.createElement('div');
|
|
1396
|
-
container.className = 'atomix-overlay-calendar';
|
|
1397
|
-
const td = document.createElement('td');
|
|
1398
|
-
td.setAttribute('data-date', '2024-01-15');
|
|
1399
|
-
container.appendChild(td);
|
|
1400
|
-
document.body.appendChild(container);
|
|
1401
|
-
|
|
1402
|
-
const result = (component as any)._findElementByDate(new Date(2024, 0, 15));
|
|
1403
|
-
expect(result).toBe(td);
|
|
1404
|
-
|
|
1405
|
-
document.body.removeChild(container);
|
|
1406
|
-
});
|
|
1407
|
-
|
|
1408
|
-
it('should find element by unpadded data-date', () => {
|
|
1409
|
-
const el = document.createElement('td');
|
|
1410
|
-
el.setAttribute('data-date', '2024-1-5');
|
|
1411
|
-
document.body.appendChild(el);
|
|
1412
|
-
|
|
1413
|
-
const result = (component as any)._findElementByDate(new Date(2024, 0, 5));
|
|
1414
|
-
expect(result).toBe(el);
|
|
1415
|
-
|
|
1416
|
-
document.body.removeChild(el);
|
|
1417
|
-
});
|
|
1418
|
-
|
|
1419
|
-
it('should return element directly when closest td is null in overlay', () => {
|
|
1420
|
-
const container = document.createElement('div');
|
|
1421
|
-
container.className = 'atomix-overlay-calendar';
|
|
1422
|
-
const span = document.createElement('span');
|
|
1423
|
-
span.setAttribute('data-date', '2024-03-10');
|
|
1424
|
-
container.appendChild(span);
|
|
1425
|
-
document.body.appendChild(container);
|
|
1426
|
-
|
|
1427
|
-
const result = (component as any)._findElementByDate(new Date(2024, 2, 10));
|
|
1428
|
-
expect(result).toBe(span);
|
|
1429
|
-
|
|
1430
|
-
document.body.removeChild(container);
|
|
1431
|
-
});
|
|
1432
|
-
|
|
1433
|
-
it('should return element directly when closest td is null outside overlay', () => {
|
|
1434
|
-
const span = document.createElement('span');
|
|
1435
|
-
span.setAttribute('data-date', '2024-4-20');
|
|
1436
|
-
document.body.appendChild(span);
|
|
1437
|
-
|
|
1438
|
-
const result = (component as any)._findElementByDate(new Date(2024, 3, 20));
|
|
1439
|
-
expect(result).toBe(span);
|
|
1440
|
-
|
|
1441
|
-
document.body.removeChild(span);
|
|
1442
|
-
});
|
|
1443
|
-
});
|
|
1444
|
-
|
|
1445
|
-
describe('private isoDate', () => {
|
|
1446
|
-
it('should format date as ISO string', () => {
|
|
1447
|
-
const result = (component as any).isoDate(new Date(2024, 0, 5));
|
|
1448
|
-
expect(result).toBe('2024-01-05');
|
|
1449
|
-
});
|
|
1450
|
-
|
|
1451
|
-
it('should pad month and day with zeros', () => {
|
|
1452
|
-
const result = (component as any).isoDate(new Date(2024, 11, 25));
|
|
1453
|
-
expect(result).toBe('2024-12-25');
|
|
1454
|
-
});
|
|
1455
|
-
});
|
|
1456
|
-
|
|
1457
|
-
describe('ngOnInit with inline mode', () => {
|
|
1458
|
-
it('should start calendar observers when inline is true', () => {
|
|
1459
|
-
component.inline = true;
|
|
1460
|
-
const spy = jest.spyOn(component as any, '_startCalendarObservers');
|
|
1461
|
-
component.ngOnInit();
|
|
1462
|
-
expect(spy).toHaveBeenCalled();
|
|
1463
|
-
});
|
|
1464
|
-
});
|
|
1465
|
-
});
|