@nova-design-system/nova-webcomponents 3.1.0 → 3.3.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/dist/cjs/{index-9bda5507.js → index-c56424e5.js} +34 -186
- package/dist/cjs/index-c56424e5.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -0
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/native.cjs.js +2 -23
- package/dist/cjs/native.cjs.js.map +1 -1
- package/dist/cjs/nv-alert.cjs.entry.js +1 -1
- package/dist/cjs/nv-avatar.cjs.entry.js +1 -1
- package/dist/cjs/nv-badge_2.cjs.entry.js +1 -1
- package/dist/cjs/nv-breadcrumb.cjs.entry.js +1 -1
- package/dist/cjs/nv-breadcrumbs.cjs.entry.js +1 -1
- package/dist/cjs/nv-button.cjs.entry.js +1 -1
- package/dist/cjs/nv-calendar.cjs.entry.js +384 -172
- package/dist/cjs/nv-calendar.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-col.cjs.entry.js +1 -1
- package/dist/cjs/nv-datagrid.cjs.entry.js +95 -103
- package/dist/cjs/nv-datagrid.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-datagridcolumn.cjs.entry.js +2 -2
- package/dist/cjs/nv-datagridcolumn.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-dialog.cjs.entry.js +1 -1
- package/dist/cjs/nv-dialogfooter_2.cjs.entry.js +1 -1
- package/dist/cjs/nv-fieldcheckbox.cjs.entry.js +1 -1
- package/dist/cjs/nv-fielddate.cjs.entry.js +45 -11
- package/dist/cjs/nv-fielddate.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fielddaterange.cjs.entry.js +128 -42
- package/dist/cjs/nv-fielddaterange.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fielddropdown.cjs.entry.js +84 -60
- package/dist/cjs/nv-fielddropdown.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fielddropdownitem.cjs.entry.js +1 -1
- package/dist/cjs/nv-fieldmultiselect.cjs.entry.js +116 -104
- package/dist/cjs/nv-fieldmultiselect.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fieldnumber.cjs.entry.js +2 -2
- package/dist/cjs/nv-fieldnumber.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fieldpassword.cjs.entry.js +2 -2
- package/dist/cjs/nv-fieldpassword.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fieldradio.cjs.entry.js +1 -1
- package/dist/cjs/nv-fieldselect.cjs.entry.js +2 -2
- package/dist/cjs/nv-fieldselect.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fieldslider.cjs.entry.js +668 -0
- package/dist/cjs/nv-fieldslider.cjs.entry.js.map +1 -0
- package/dist/cjs/nv-fieldtext.cjs.entry.js +5 -5
- package/dist/cjs/nv-fieldtext.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fieldtextarea.cjs.entry.js +5 -5
- package/dist/cjs/nv-fieldtextarea.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fieldtime.cjs.entry.js +11 -11
- package/dist/cjs/nv-fieldtime.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-icon.cjs.entry.js +3 -3
- package/dist/cjs/nv-icon.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-iconbutton_2.cjs.entry.js +3 -3
- package/dist/cjs/nv-menu.cjs.entry.js +2 -2
- package/dist/cjs/nv-menuitem.cjs.entry.js +2 -2
- package/dist/cjs/nv-popover.cjs.entry.js +2 -2
- package/dist/cjs/nv-row.cjs.entry.js +2 -2
- package/dist/cjs/nv-stack.cjs.entry.js +2 -2
- package/dist/cjs/nv-table.cjs.entry.js +3 -3
- package/dist/cjs/nv-tablecolumn.cjs.entry.js +1 -1
- package/dist/cjs/nv-toggle.cjs.entry.js +3 -3
- package/dist/cjs/nv-tooltip.cjs.entry.js +3 -3
- package/dist/cjs/nv-tooltip.cjs.entry.js.map +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/nv-calendar/nv-calendar.css +6 -2
- package/dist/collection/components/nv-calendar/nv-calendar.js +247 -169
- package/dist/collection/components/nv-calendar/nv-calendar.js.map +1 -1
- package/dist/collection/components/nv-calendar/nv-calendar.utils.js +12 -3
- package/dist/collection/components/nv-calendar/nv-calendar.utils.js.map +1 -1
- package/dist/collection/components/nv-calendar/partials/calendar-actions.js +11 -0
- package/dist/collection/components/nv-calendar/partials/calendar-actions.js.map +1 -0
- package/dist/collection/components/nv-calendar/partials/calendar-grid.js +24 -0
- package/dist/collection/components/nv-calendar/partials/calendar-grid.js.map +1 -0
- package/dist/collection/components/nv-calendar/partials/calendar-header.js +38 -0
- package/dist/collection/components/nv-calendar/partials/calendar-header.js.map +1 -0
- package/dist/collection/components/nv-calendar/partials/calendar-shortcuts.js +22 -0
- package/dist/collection/components/nv-calendar/partials/calendar-shortcuts.js.map +1 -0
- package/dist/collection/components/nv-calendar/partials/day-cell.js +31 -0
- package/dist/collection/components/nv-calendar/partials/day-cell.js.map +1 -0
- package/dist/collection/components/nv-calendar/partials/index.js +7 -0
- package/dist/collection/components/nv-calendar/partials/index.js.map +1 -0
- package/dist/collection/components/nv-calendar/partials/week-numbers.js +36 -0
- package/dist/collection/components/nv-calendar/partials/week-numbers.js.map +1 -0
- package/dist/collection/components/nv-calendar/test/nv-calendar.utils.test.js +692 -651
- package/dist/collection/components/nv-calendar/test/nv-calendar.utils.test.js.map +1 -1
- package/dist/collection/components/nv-calendar/test/partials/calendar-actions.logic.test.js +169 -0
- package/dist/collection/components/nv-calendar/test/partials/calendar-actions.logic.test.js.map +1 -0
- package/dist/collection/components/nv-calendar/test/partials/calendar-grid.logic.test.js +262 -0
- package/dist/collection/components/nv-calendar/test/partials/calendar-grid.logic.test.js.map +1 -0
- package/dist/collection/components/nv-calendar/test/partials/calendar-header.logic.test.js +208 -0
- package/dist/collection/components/nv-calendar/test/partials/calendar-header.logic.test.js.map +1 -0
- package/dist/collection/components/nv-calendar/test/partials/calendar-shortcuts.logic.test.js +355 -0
- package/dist/collection/components/nv-calendar/test/partials/calendar-shortcuts.logic.test.js.map +1 -0
- package/dist/collection/components/nv-calendar/test/partials/day-cell.logic.test.js +250 -0
- package/dist/collection/components/nv-calendar/test/partials/day-cell.logic.test.js.map +1 -0
- package/dist/collection/components/nv-calendar/test/partials/week-numbers.logic.test.js +217 -0
- package/dist/collection/components/nv-calendar/test/partials/week-numbers.logic.test.js.map +1 -0
- package/dist/collection/components/nv-datagrid/nv-datagrid.docs.js +131 -48
- package/dist/collection/components/nv-datagrid/nv-datagrid.docs.js.map +1 -1
- package/dist/collection/components/nv-datagrid/nv-datagrid.js +94 -152
- package/dist/collection/components/nv-datagrid/nv-datagrid.js.map +1 -1
- package/dist/collection/components/nv-datagridcolumn/nv-datagridcolumn.js +20 -1
- package/dist/collection/components/nv-datagridcolumn/nv-datagridcolumn.js.map +1 -1
- package/dist/collection/components/nv-fielddate/nv-fielddate.js +56 -16
- package/dist/collection/components/nv-fielddate/nv-fielddate.js.map +1 -1
- package/dist/collection/components/nv-fielddate/styles/nv-fielddate.css +51 -1
- package/dist/collection/components/nv-fielddate/test/nv-fielddate.logic.test.js +196 -0
- package/dist/collection/components/nv-fielddate/test/nv-fielddate.logic.test.js.map +1 -0
- package/dist/collection/components/nv-fielddaterange/nv-fielddaterange.js +165 -41
- package/dist/collection/components/nv-fielddaterange/nv-fielddaterange.js.map +1 -1
- package/dist/collection/components/nv-fielddaterange/styles/nv-fielddaterange.css +51 -1
- package/dist/collection/components/nv-fielddaterange/test/nv-fielddaterange.logic.test.js +137 -0
- package/dist/collection/components/nv-fielddaterange/test/nv-fielddaterange.logic.test.js.map +1 -0
- package/dist/collection/components/nv-fielddropdown/nv-fielddropdown.docs.js +8 -0
- package/dist/collection/components/nv-fielddropdown/nv-fielddropdown.docs.js.map +1 -1
- package/dist/collection/components/nv-fielddropdown/nv-fielddropdown.js +173 -106
- package/dist/collection/components/nv-fielddropdown/nv-fielddropdown.js.map +1 -1
- package/dist/collection/components/nv-fielddropdown/styles/nv-fielddropdown.css +77 -1
- package/dist/collection/components/nv-fieldmultiselect/nv-fieldmultiselect.js +202 -190
- package/dist/collection/components/nv-fieldmultiselect/nv-fieldmultiselect.js.map +1 -1
- package/dist/collection/components/nv-fieldmultiselect/{nv-fieldmultiselect.css → styles/nv-fieldmultiselect.css} +61 -4
- package/dist/collection/components/nv-fieldnumber/nv-fieldnumber.css +51 -1
- package/dist/collection/components/nv-fieldpassword/nv-fieldpassword.css +51 -1
- package/dist/collection/components/nv-fieldselect/nv-fieldselect.css +51 -1
- package/dist/collection/components/nv-fieldslider/nv-fieldslider.docs.js +264 -0
- package/dist/collection/components/nv-fieldslider/nv-fieldslider.docs.js.map +1 -0
- package/dist/collection/components/nv-fieldslider/nv-fieldslider.js +1036 -0
- package/dist/collection/components/nv-fieldslider/nv-fieldslider.js.map +1 -0
- package/dist/collection/components/nv-fieldslider/nv-fieldslider.utils.js +77 -0
- package/dist/collection/components/nv-fieldslider/nv-fieldslider.utils.js.map +1 -0
- package/dist/collection/components/nv-fieldslider/partials/field-input.js +33 -0
- package/dist/collection/components/nv-fieldslider/partials/field-input.js.map +1 -0
- package/dist/collection/components/nv-fieldslider/partials/range-thumb.js +34 -0
- package/dist/collection/components/nv-fieldslider/partials/range-thumb.js.map +1 -0
- package/dist/collection/components/nv-fieldslider/partials/single-thumb.js +18 -0
- package/dist/collection/components/nv-fieldslider/partials/single-thumb.js.map +1 -0
- package/dist/collection/components/nv-fieldslider/partials/tick-marks.js +18 -0
- package/dist/collection/components/nv-fieldslider/partials/tick-marks.js.map +1 -0
- package/dist/collection/components/nv-fieldslider/styles/nv-fieldslider.css +338 -0
- package/dist/collection/components/nv-fieldslider/test/nv-fieldslider.utils.test.js +159 -0
- package/dist/collection/components/nv-fieldslider/test/nv-fieldslider.utils.test.js.map +1 -0
- package/dist/collection/components/nv-fieldtext/nv-fieldtext.css +59 -1
- package/dist/collection/components/nv-fieldtext/nv-fieldtext.docs.js +9 -1
- package/dist/collection/components/nv-fieldtext/nv-fieldtext.docs.js.map +1 -1
- package/dist/collection/components/nv-fieldtext/nv-fieldtext.js +4 -3
- package/dist/collection/components/nv-fieldtext/nv-fieldtext.js.map +1 -1
- package/dist/collection/components/nv-fieldtextarea/nv-fieldtextarea.css +45 -1
- package/dist/collection/components/nv-fieldtextarea/nv-fieldtextarea.js +3 -3
- package/dist/collection/components/nv-fieldtime/nv-fieldtime.js +9 -9
- package/dist/collection/components/nv-fieldtime/styles/nv-fieldtime.css +51 -1
- package/dist/collection/components/nv-icon/nv-icon.js +1 -1
- package/dist/collection/components/nv-icon/nv-icons.js +1 -0
- package/dist/collection/components/nv-icon/nv-icons.js.map +1 -1
- package/dist/collection/components/nv-iconbutton/nv-iconbutton.js +1 -1
- package/dist/collection/components/nv-loader/nv-loader.js +1 -1
- package/dist/collection/components/nv-menu/nv-menu.js +1 -1
- package/dist/collection/components/nv-menuitem/nv-menuitem.js +2 -2
- package/dist/collection/components/nv-popover/nv-popover.js +1 -1
- package/dist/collection/components/nv-row/nv-row.js +1 -1
- package/dist/collection/components/nv-stack/nv-stack.js +1 -1
- package/dist/collection/components/nv-table/nv-table.js +2 -2
- package/dist/collection/components/nv-toggle/nv-toggle.js +2 -2
- package/dist/collection/components/nv-tooltip/nv-tooltip.css +1 -0
- package/dist/collection/components/nv-tooltip/nv-tooltip.js +1 -1
- package/dist/collection/interfaces/Column.js.map +1 -1
- package/dist/components/index.js +2 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/nv-alert.js +2 -2
- package/dist/components/nv-avatar.js +2 -2
- package/dist/components/nv-badge.js +1 -1
- package/dist/components/nv-breadcrumb.js +3 -3
- package/dist/components/nv-breadcrumbs.js +1 -1
- package/dist/components/nv-button.js +1 -1
- package/dist/components/nv-calendar.js +1 -1
- package/dist/components/nv-col.js +1 -1
- package/dist/components/nv-datagrid.js +97 -109
- package/dist/components/nv-datagrid.js.map +1 -1
- package/dist/components/nv-datagridcolumn.js +4 -3
- package/dist/components/nv-datagridcolumn.js.map +1 -1
- package/dist/components/nv-dialog.js +6 -6
- package/dist/components/nv-dialogfooter.js +1 -1
- package/dist/components/nv-dialogheader.js +1 -1
- package/dist/components/nv-fieldcheckbox.js +1 -1
- package/dist/components/nv-fielddate.js +53 -25
- package/dist/components/nv-fielddate.js.map +1 -1
- package/dist/components/nv-fielddaterange.js +137 -57
- package/dist/components/nv-fielddaterange.js.map +1 -1
- package/dist/components/nv-fielddropdown.js +98 -72
- package/dist/components/nv-fielddropdown.js.map +1 -1
- package/dist/components/nv-fielddropdownitem.js +1 -1
- package/dist/components/nv-fielddropdownitemcheck.js +1 -1
- package/dist/components/nv-fieldmultiselect.js +132 -120
- package/dist/components/nv-fieldmultiselect.js.map +1 -1
- package/dist/components/nv-fieldnumber.js +5 -5
- package/dist/components/nv-fieldnumber.js.map +1 -1
- package/dist/components/nv-fieldpassword.js +5 -5
- package/dist/components/nv-fieldpassword.js.map +1 -1
- package/dist/components/nv-fieldradio.js +1 -1
- package/dist/components/nv-fieldselect.js +5 -5
- package/dist/components/nv-fieldselect.js.map +1 -1
- package/dist/components/nv-fieldslider.d.ts +11 -0
- package/dist/components/nv-fieldslider.js +731 -0
- package/dist/components/nv-fieldslider.js.map +1 -0
- package/dist/components/nv-fieldtext.js +1 -1
- package/dist/components/nv-fieldtextarea.js +5 -5
- package/dist/components/nv-fieldtextarea.js.map +1 -1
- package/dist/components/nv-fieldtime.js +15 -15
- package/dist/components/nv-fieldtime.js.map +1 -1
- package/dist/components/nv-icon.js +1 -1
- package/dist/components/nv-iconbutton.js +1 -1
- package/dist/components/nv-loader.js +1 -1
- package/dist/components/nv-menu.js +5 -5
- package/dist/components/nv-menuitem.js +1 -1
- package/dist/components/nv-popover.js +1 -1
- package/dist/components/nv-row.js +2 -2
- package/dist/components/nv-stack.js +2 -2
- package/dist/components/nv-table.js +3 -3
- package/dist/components/nv-tablecolumn.js +1 -1
- package/dist/components/nv-toggle.js +3 -3
- package/dist/components/nv-tooltip.js +1 -1
- package/dist/components/{p-eb632278.js → p-2ae214d2.js} +3 -3
- package/dist/components/{p-eb632278.js.map → p-2ae214d2.js.map} +1 -1
- package/dist/components/{p-f76bb0c3.js → p-3e32b5a1.js} +5 -5
- package/dist/components/p-3e32b5a1.js.map +1 -0
- package/dist/components/{p-854c32dc.js → p-5e90b9b8.js} +389 -199
- package/dist/components/p-5e90b9b8.js.map +1 -0
- package/dist/components/{p-a2527411.js → p-5ee4015d.js} +3 -3
- package/dist/components/{p-a2527411.js.map → p-5ee4015d.js.map} +1 -1
- package/dist/components/{p-02752770.js → p-6277f746.js} +2 -2
- package/dist/components/{p-02752770.js.map → p-6277f746.js.map} +1 -1
- package/dist/components/p-7935c1cb.js +167 -0
- package/dist/components/p-7935c1cb.js.map +1 -0
- package/dist/components/{p-b48d5a94.js → p-8d92f0e1.js} +4 -4
- package/dist/components/{p-b48d5a94.js.map → p-8d92f0e1.js.map} +1 -1
- package/dist/components/{p-41c56ddc.js → p-95a7581c.js} +5 -5
- package/dist/components/{p-41c56ddc.js.map → p-95a7581c.js.map} +1 -1
- package/dist/components/{p-e00cbb8a.js → p-9e6e26cb.js} +2 -2
- package/dist/components/{p-e00cbb8a.js.map → p-9e6e26cb.js.map} +1 -1
- package/dist/components/p-9fa0de38.js +88 -0
- package/dist/components/p-9fa0de38.js.map +1 -0
- package/dist/components/{p-1c45c0f2.js → p-aff3ed68.js} +24 -177
- package/dist/components/p-aff3ed68.js.map +1 -0
- package/dist/components/{p-608eb9da.js → p-b6d858b2.js} +2 -2
- package/dist/components/{p-608eb9da.js.map → p-b6d858b2.js.map} +1 -1
- package/dist/components/{p-f5cb0a63.js → p-bb6d1e4e.js} +3 -3
- package/dist/components/{p-f5cb0a63.js.map → p-bb6d1e4e.js.map} +1 -1
- package/dist/components/{p-35a70c5e.js → p-c07c32d2.js} +3 -3
- package/dist/components/{p-35a70c5e.js.map → p-c07c32d2.js.map} +1 -1
- package/dist/components/{p-10faa938.js → p-c9006520.js} +5 -5
- package/dist/components/{p-10faa938.js.map → p-c9006520.js.map} +1 -1
- package/dist/components/{p-0a0f6daf.js → p-e28c4707.js} +3 -3
- package/dist/components/{p-0a0f6daf.js.map → p-e28c4707.js.map} +1 -1
- package/dist/components/{p-10b37876.js → p-eabbc885.js} +3 -3
- package/dist/components/{p-10b37876.js.map → p-eabbc885.js.map} +1 -1
- package/dist/esm/{constants-b97e736d.js → constants-4faa1fae.js} +2 -2
- package/dist/esm/{constants-b97e736d.js.map → constants-4faa1fae.js.map} +1 -1
- package/dist/esm/{index-1fb7a9a6.js → index-a1936cd0.js} +35 -186
- package/dist/esm/index-a1936cd0.js.map +1 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/native.js +3 -24
- package/dist/esm/native.js.map +1 -1
- package/dist/esm/nv-alert.entry.js +2 -2
- package/dist/esm/nv-avatar.entry.js +2 -2
- package/dist/esm/nv-badge_2.entry.js +1 -1
- package/dist/esm/nv-breadcrumb.entry.js +1 -1
- package/dist/esm/nv-breadcrumbs.entry.js +1 -1
- package/dist/esm/nv-button.entry.js +2 -2
- package/dist/esm/nv-calendar.entry.js +385 -173
- package/dist/esm/nv-calendar.entry.js.map +1 -1
- package/dist/esm/nv-col.entry.js +1 -1
- package/dist/esm/nv-datagrid.entry.js +96 -104
- package/dist/esm/nv-datagrid.entry.js.map +1 -1
- package/dist/esm/nv-datagridcolumn.entry.js +2 -2
- package/dist/esm/nv-datagridcolumn.entry.js.map +1 -1
- package/dist/esm/nv-dialog.entry.js +2 -2
- package/dist/esm/nv-dialogfooter_2.entry.js +2 -2
- package/dist/esm/nv-fieldcheckbox.entry.js +1 -1
- package/dist/esm/nv-fielddate.entry.js +45 -11
- package/dist/esm/nv-fielddate.entry.js.map +1 -1
- package/dist/esm/nv-fielddaterange.entry.js +128 -42
- package/dist/esm/nv-fielddaterange.entry.js.map +1 -1
- package/dist/esm/nv-fielddropdown.entry.js +84 -60
- package/dist/esm/nv-fielddropdown.entry.js.map +1 -1
- package/dist/esm/nv-fielddropdownitem.entry.js +1 -1
- package/dist/esm/nv-fieldmultiselect.entry.js +116 -104
- package/dist/esm/nv-fieldmultiselect.entry.js.map +1 -1
- package/dist/esm/nv-fieldnumber.entry.js +2 -2
- package/dist/esm/nv-fieldnumber.entry.js.map +1 -1
- package/dist/esm/nv-fieldpassword.entry.js +2 -2
- package/dist/esm/nv-fieldpassword.entry.js.map +1 -1
- package/dist/esm/nv-fieldradio.entry.js +1 -1
- package/dist/esm/nv-fieldselect.entry.js +2 -2
- package/dist/esm/nv-fieldselect.entry.js.map +1 -1
- package/dist/esm/nv-fieldslider.entry.js +664 -0
- package/dist/esm/nv-fieldslider.entry.js.map +1 -0
- package/dist/esm/nv-fieldtext.entry.js +5 -5
- package/dist/esm/nv-fieldtext.entry.js.map +1 -1
- package/dist/esm/nv-fieldtextarea.entry.js +5 -5
- package/dist/esm/nv-fieldtextarea.entry.js.map +1 -1
- package/dist/esm/nv-fieldtime.entry.js +12 -12
- package/dist/esm/nv-fieldtime.entry.js.map +1 -1
- package/dist/esm/nv-icon.entry.js +4 -4
- package/dist/esm/nv-icon.entry.js.map +1 -1
- package/dist/esm/nv-iconbutton_2.entry.js +3 -3
- package/dist/esm/nv-menu.entry.js +2 -2
- package/dist/esm/nv-menuitem.entry.js +2 -2
- package/dist/esm/nv-popover.entry.js +2 -2
- package/dist/esm/nv-row.entry.js +2 -2
- package/dist/esm/nv-stack.entry.js +2 -2
- package/dist/esm/nv-table.entry.js +3 -3
- package/dist/esm/nv-tablecolumn.entry.js +1 -1
- package/dist/esm/nv-toggle.entry.js +3 -3
- package/dist/esm/nv-tooltip.entry.js +3 -3
- package/dist/esm/nv-tooltip.entry.js.map +1 -1
- package/dist/native/index.esm.js +1 -1
- package/dist/native/index.esm.js.map +1 -1
- package/dist/native/native.css +1 -1
- package/dist/native/native.esm.js +1 -1
- package/dist/native/native.esm.js.map +1 -1
- package/dist/native/p-050d6c6c.entry.js +2 -0
- package/dist/native/{p-4d164ed6.entry.js.map → p-050d6c6c.entry.js.map} +1 -1
- package/dist/native/{p-615947e7.entry.js → p-08ca678c.entry.js} +2 -2
- package/dist/native/p-1a5d3b87.entry.js +2 -0
- package/dist/native/{p-efe6a46c.entry.js.map → p-1a5d3b87.entry.js.map} +1 -1
- package/dist/native/{p-7fd4d13d.entry.js → p-1c1ecd38.entry.js} +2 -2
- package/dist/native/{p-c7b201cd.entry.js → p-1d98477d.entry.js} +2 -2
- package/dist/native/{p-1da72182.entry.js → p-2006f5d4.entry.js} +2 -2
- package/dist/native/p-26cf4938.entry.js +2 -0
- package/dist/native/p-26cf4938.entry.js.map +1 -0
- package/dist/native/p-3817efb2.entry.js +2 -0
- package/dist/native/{p-fc97f071.entry.js.map → p-3817efb2.entry.js.map} +1 -1
- package/dist/native/p-45459dbb.entry.js +2 -0
- package/dist/native/{p-7042ba8a.entry.js.map → p-45459dbb.entry.js.map} +1 -1
- package/dist/native/p-45cbe6e4.entry.js +2 -0
- package/dist/native/{p-9135fdf5.entry.js.map → p-45cbe6e4.entry.js.map} +1 -1
- package/dist/native/p-46428304.entry.js +2 -0
- package/dist/native/p-46428304.entry.js.map +1 -0
- package/dist/native/p-4f9cdf0b.entry.js +2 -0
- package/dist/native/{p-3b7ef609.entry.js → p-58bb90ad.entry.js} +2 -2
- package/dist/native/p-59b07b36.entry.js +2 -0
- package/dist/native/p-59b07b36.entry.js.map +1 -0
- package/dist/native/{p-3cd77d82.entry.js → p-5b6c59e0.entry.js} +2 -2
- package/dist/native/p-6029e51b.entry.js +2 -0
- package/dist/native/{p-244f56ac.entry.js.map → p-6029e51b.entry.js.map} +1 -1
- package/dist/native/{p-08a75cfa.entry.js → p-60c64f2b.entry.js} +2 -2
- package/dist/native/p-64a76565.entry.js +2 -0
- package/dist/native/p-64a76565.entry.js.map +1 -0
- package/dist/native/{p-c67186f8.entry.js → p-83288db0.entry.js} +2 -2
- package/dist/native/p-838f7842.entry.js +2 -0
- package/dist/native/p-838f7842.entry.js.map +1 -0
- package/dist/native/{p-0245863d.entry.js → p-86ab23ea.entry.js} +2 -2
- package/dist/native/p-87784622.entry.js +2 -0
- package/dist/native/p-8fb4e5c0.entry.js +2 -0
- package/dist/native/{p-b94d9f0b.entry.js.map → p-8fb4e5c0.entry.js.map} +1 -1
- package/dist/native/{p-14c07207.entry.js → p-914da1e1.entry.js} +2 -2
- package/dist/native/p-abbe5d69.entry.js +2 -0
- package/dist/native/p-abbe5d69.entry.js.map +1 -0
- package/dist/native/p-abc251aa.entry.js +2 -0
- package/dist/native/p-abc251aa.entry.js.map +1 -0
- package/dist/native/{p-c0f79bac.entry.js → p-ad128108.entry.js} +2 -2
- package/dist/native/{p-e5de64d5.entry.js → p-b5b9190a.entry.js} +2 -2
- package/dist/native/{p-470588c2.entry.js → p-b8f2c1e7.entry.js} +3 -3
- package/dist/native/p-b8f2c1e7.entry.js.map +1 -0
- package/dist/native/{p-b8b6875d.entry.js → p-d040bd61.entry.js} +2 -2
- package/dist/native/p-d0a33e64.js +3 -0
- package/dist/native/p-d0a33e64.js.map +1 -0
- package/dist/native/{p-3953464e.entry.js → p-d21b2da2.entry.js} +3 -3
- package/dist/native/{p-90e6d9dd.entry.js → p-d53e8795.entry.js} +2 -2
- package/dist/native/p-dc7dd7f3.entry.js +2 -0
- package/dist/native/{p-ae7ab110.entry.js.map → p-dc7dd7f3.entry.js.map} +1 -1
- package/dist/native/p-e2c1992e.entry.js +2 -0
- package/dist/native/{p-656c56f0.entry.js.map → p-e2c1992e.entry.js.map} +1 -1
- package/dist/native/{p-f85c08f1.js → p-e2d0a77d.js} +2 -2
- package/dist/native/p-ed6019fe.entry.js +2 -0
- package/dist/native/p-ed6019fe.entry.js.map +1 -0
- package/dist/native/p-f94d7054.entry.js +2 -0
- package/dist/native/{p-49cac014.entry.js.map → p-f94d7054.entry.js.map} +1 -1
- package/dist/native/p-fdea17ce.entry.js +2 -0
- package/dist/native/p-fdea17ce.entry.js.map +1 -0
- package/dist/types/components/nv-calendar/nv-calendar.d.ts +26 -50
- package/dist/types/components/nv-calendar/partials/calendar-actions.d.ts +19 -0
- package/dist/types/components/nv-calendar/partials/calendar-grid.d.ts +46 -0
- package/dist/types/components/nv-calendar/partials/calendar-header.d.ts +38 -0
- package/dist/types/components/nv-calendar/partials/calendar-shortcuts.d.ts +35 -0
- package/dist/types/components/nv-calendar/partials/day-cell.d.ts +35 -0
- package/dist/types/components/nv-calendar/partials/index.d.ts +6 -0
- package/dist/types/components/nv-calendar/partials/week-numbers.d.ts +30 -0
- package/dist/types/components/nv-calendar/test/partials/calendar-actions.logic.test.d.ts +1 -0
- package/dist/types/components/nv-calendar/test/partials/calendar-grid.logic.test.d.ts +1 -0
- package/dist/types/components/nv-calendar/test/partials/calendar-header.logic.test.d.ts +1 -0
- package/dist/types/components/nv-calendar/test/partials/calendar-shortcuts.logic.test.d.ts +1 -0
- package/dist/types/components/nv-calendar/test/partials/day-cell.logic.test.d.ts +1 -0
- package/dist/types/components/nv-calendar/test/partials/week-numbers.logic.test.d.ts +1 -0
- package/dist/types/components/nv-datagrid/nv-datagrid.d.ts +0 -16
- package/dist/types/components/nv-datagridcolumn/nv-datagridcolumn.d.ts +4 -0
- package/dist/types/components/nv-fielddate/nv-fielddate.d.ts +21 -9
- package/dist/types/components/nv-fielddate/test/nv-fielddate.logic.test.d.ts +1 -0
- package/dist/types/components/nv-fielddaterange/nv-fielddaterange.d.ts +24 -3
- package/dist/types/components/nv-fielddaterange/test/nv-fielddaterange.logic.test.d.ts +1 -0
- package/dist/types/components/nv-fielddropdown/nv-fielddropdown.d.ts +47 -26
- package/dist/types/components/nv-fieldmultiselect/nv-fieldmultiselect.d.ts +61 -55
- package/dist/types/components/nv-fieldslider/nv-fieldslider.d.ts +229 -0
- package/dist/types/components/nv-fieldslider/nv-fieldslider.docs.d.ts +4 -0
- package/dist/types/components/nv-fieldslider/nv-fieldslider.utils.d.ts +46 -0
- package/dist/types/components/nv-fieldslider/partials/field-input.d.ts +45 -0
- package/dist/types/components/nv-fieldslider/partials/range-thumb.d.ts +37 -0
- package/dist/types/components/nv-fieldslider/partials/single-thumb.d.ts +35 -0
- package/dist/types/components/nv-fieldslider/partials/tick-marks.d.ts +28 -0
- package/dist/types/components/nv-fieldslider/test/nv-fieldslider.utils.test.d.ts +1 -0
- package/dist/types/components/nv-fieldtext/nv-fieldtext.d.ts +1 -0
- package/dist/types/components/nv-icon/nv-icons.d.ts +1 -1
- package/dist/types/components.d.ts +402 -54
- package/dist/types/interfaces/Column.d.ts +5 -1
- package/dist/vscode-data.json +121 -9
- package/hydrate/index.js +1664 -584
- package/hydrate/index.mjs +1664 -584
- package/package.json +6 -2
- package/dist/cjs/index-9bda5507.js.map +0 -1
- package/dist/components/p-1c45c0f2.js.map +0 -1
- package/dist/components/p-76646ce9.js +0 -88
- package/dist/components/p-76646ce9.js.map +0 -1
- package/dist/components/p-854c32dc.js.map +0 -1
- package/dist/components/p-9decffb6.js +0 -167
- package/dist/components/p-9decffb6.js.map +0 -1
- package/dist/components/p-f76bb0c3.js.map +0 -1
- package/dist/esm/index-1fb7a9a6.js.map +0 -1
- package/dist/native/p-244f56ac.entry.js +0 -2
- package/dist/native/p-2523eead.entry.js +0 -2
- package/dist/native/p-2523eead.entry.js.map +0 -1
- package/dist/native/p-470588c2.entry.js.map +0 -1
- package/dist/native/p-49cac014.entry.js +0 -2
- package/dist/native/p-4d164ed6.entry.js +0 -2
- package/dist/native/p-4dc1d036.entry.js +0 -2
- package/dist/native/p-4e635fa7.entry.js +0 -2
- package/dist/native/p-4e635fa7.entry.js.map +0 -1
- package/dist/native/p-5d21532a.entry.js +0 -2
- package/dist/native/p-5d21532a.entry.js.map +0 -1
- package/dist/native/p-656c56f0.entry.js +0 -2
- package/dist/native/p-7042ba8a.entry.js +0 -2
- package/dist/native/p-7e154bfd.entry.js +0 -2
- package/dist/native/p-7e154bfd.entry.js.map +0 -1
- package/dist/native/p-7eba904e.entry.js +0 -2
- package/dist/native/p-7eba904e.entry.js.map +0 -1
- package/dist/native/p-9135fdf5.entry.js +0 -2
- package/dist/native/p-ab002252.js +0 -3
- package/dist/native/p-ab002252.js.map +0 -1
- package/dist/native/p-ae7ab110.entry.js +0 -2
- package/dist/native/p-b94d9f0b.entry.js +0 -2
- package/dist/native/p-c71c6f23.entry.js +0 -2
- package/dist/native/p-c71c6f23.entry.js.map +0 -1
- package/dist/native/p-d9a52884.entry.js +0 -2
- package/dist/native/p-d9a52884.entry.js.map +0 -1
- package/dist/native/p-efe6a46c.entry.js +0 -2
- package/dist/native/p-f2ef6771.entry.js +0 -2
- package/dist/native/p-f5f68992.entry.js +0 -2
- package/dist/native/p-f5f68992.entry.js.map +0 -1
- package/dist/native/p-fc97f071.entry.js +0 -2
- /package/dist/native/{p-615947e7.entry.js.map → p-08ca678c.entry.js.map} +0 -0
- /package/dist/native/{p-7fd4d13d.entry.js.map → p-1c1ecd38.entry.js.map} +0 -0
- /package/dist/native/{p-c7b201cd.entry.js.map → p-1d98477d.entry.js.map} +0 -0
- /package/dist/native/{p-1da72182.entry.js.map → p-2006f5d4.entry.js.map} +0 -0
- /package/dist/native/{p-f2ef6771.entry.js.map → p-4f9cdf0b.entry.js.map} +0 -0
- /package/dist/native/{p-3b7ef609.entry.js.map → p-58bb90ad.entry.js.map} +0 -0
- /package/dist/native/{p-3cd77d82.entry.js.map → p-5b6c59e0.entry.js.map} +0 -0
- /package/dist/native/{p-08a75cfa.entry.js.map → p-60c64f2b.entry.js.map} +0 -0
- /package/dist/native/{p-c67186f8.entry.js.map → p-83288db0.entry.js.map} +0 -0
- /package/dist/native/{p-0245863d.entry.js.map → p-86ab23ea.entry.js.map} +0 -0
- /package/dist/native/{p-4dc1d036.entry.js.map → p-87784622.entry.js.map} +0 -0
- /package/dist/native/{p-14c07207.entry.js.map → p-914da1e1.entry.js.map} +0 -0
- /package/dist/native/{p-c0f79bac.entry.js.map → p-ad128108.entry.js.map} +0 -0
- /package/dist/native/{p-e5de64d5.entry.js.map → p-b5b9190a.entry.js.map} +0 -0
- /package/dist/native/{p-b8b6875d.entry.js.map → p-d040bd61.entry.js.map} +0 -0
- /package/dist/native/{p-3953464e.entry.js.map → p-d21b2da2.entry.js.map} +0 -0
- /package/dist/native/{p-90e6d9dd.entry.js.map → p-d53e8795.entry.js.map} +0 -0
- /package/dist/native/{p-f85c08f1.js.map → p-e2d0a77d.js.map} +0 -0
|
@@ -1,666 +1,707 @@
|
|
|
1
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
1
2
|
import { describe, it, expect, vi } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const originalHours = date.getHours();
|
|
38
|
-
// Simulate different times on the same day
|
|
39
|
-
date.setHours(0);
|
|
40
|
-
const earlyResult = getWeekNumber(date);
|
|
41
|
-
date.setHours(23);
|
|
42
|
-
const lateResult = getWeekNumber(date);
|
|
43
|
-
expect(earlyResult).toBe(lateResult);
|
|
44
|
-
// Reset to avoid affecting other tests
|
|
45
|
-
date.setHours(originalHours);
|
|
46
|
-
});
|
|
47
|
-
it('should handle historic dates correctly', () => {
|
|
48
|
-
const historicDate = new Date(2000, 0, 1); // January 1, 2000
|
|
49
|
-
expect(getWeekNumber(historicDate)).toBe(1);
|
|
3
|
+
import { formatDate, isSameDate, isSameOrBefore, isSameOrAfter, getWeekNumber, parseDate, } from "../nv-calendar.utils";
|
|
4
|
+
/**
|
|
5
|
+
* Comprehensive tests for nv-calendar utilities
|
|
6
|
+
*
|
|
7
|
+
* These tests validate all utility functions:
|
|
8
|
+
* - Date formatting with various formats
|
|
9
|
+
* - Date comparison logic (same, before, after)
|
|
10
|
+
* - Week number calculation
|
|
11
|
+
* - Date parsing from various formats
|
|
12
|
+
* - UTC vs local timezone handling
|
|
13
|
+
* - Edge cases and error conditions
|
|
14
|
+
*/
|
|
15
|
+
describe('nv-calendar.utils - Comprehensive Tests', () => {
|
|
16
|
+
describe('formatDate', () => {
|
|
17
|
+
const testDate = new Date('2024-06-15T14:30:45.123Z');
|
|
18
|
+
describe('Standard Date Formats', () => {
|
|
19
|
+
it('should format basic date patterns', () => {
|
|
20
|
+
expect(formatDate(testDate, { dateFormat: 'YYYY-MM-DD' })).toBe('2024-06-15');
|
|
21
|
+
expect(formatDate(testDate, { dateFormat: 'DD/MM/YYYY' })).toBe('15/06/2024');
|
|
22
|
+
expect(formatDate(testDate, { dateFormat: 'MM-DD-YYYY' })).toBe('06-15-2024');
|
|
23
|
+
expect(formatDate(testDate, { dateFormat: 'YYYY' })).toBe('2024');
|
|
24
|
+
expect(formatDate(testDate, { dateFormat: 'MM' })).toBe('06');
|
|
25
|
+
expect(formatDate(testDate, { dateFormat: 'DD' })).toBe('15');
|
|
26
|
+
});
|
|
27
|
+
it('should format date with time patterns', () => {
|
|
28
|
+
expect(formatDate(testDate, { dateFormat: 'YYYY-MM-DD HH:mm:ss' })).toMatch(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/);
|
|
29
|
+
expect(formatDate(testDate, { dateFormat: 'HH:mm' })).toMatch(/\d{2}:\d{2}/);
|
|
30
|
+
expect(formatDate(testDate, { dateFormat: 'HH:mm:ss' })).toMatch(/\d{2}:\d{2}:\d{2}/);
|
|
31
|
+
});
|
|
32
|
+
it('should handle empty date', () => {
|
|
33
|
+
expect(formatDate(null, { dateFormat: 'YYYY-MM-DD' })).toBe('');
|
|
34
|
+
expect(formatDate(undefined, {
|
|
35
|
+
dateFormat: 'YYYY-MM-DD',
|
|
36
|
+
})).toBe('');
|
|
37
|
+
});
|
|
50
38
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
.
|
|
71
|
-
.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
expect(result).toBeInstanceOf(Date);
|
|
109
|
-
// Instead of comparing to a specific date, let's verify the result is reasonable
|
|
110
|
-
// by checking basic properties
|
|
111
|
-
if (result) {
|
|
112
|
-
expect(result.getFullYear()).toBeGreaterThan(2000); // Should be a date after 2000
|
|
113
|
-
expect(result.getFullYear()).toBeLessThan(2030); // Should be a date before 2030
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
it('should handle invalid Ticks format', () => {
|
|
117
|
-
const consoleSpy = vi
|
|
118
|
-
.spyOn(console, 'error')
|
|
119
|
-
.mockImplementation(() => { });
|
|
120
|
-
const invalidTicks = 'abc';
|
|
121
|
-
const result = parseDate(invalidTicks, 'Ticks');
|
|
122
|
-
expect(result).toBeNull();
|
|
123
|
-
consoleSpy.mockRestore();
|
|
124
|
-
});
|
|
125
|
-
// Common date formats
|
|
126
|
-
it('should parse YYYY-MM-DD format', () => {
|
|
127
|
-
const dateStr = '2023-06-15';
|
|
128
|
-
const result = parseDate(dateStr, 'YYYY-MM-DD');
|
|
129
|
-
expect(result).toBeInstanceOf(Date);
|
|
130
|
-
expect(result === null || result === void 0 ? void 0 : result.getFullYear()).toBe(2023);
|
|
131
|
-
expect(result === null || result === void 0 ? void 0 : result.getMonth()).toBe(5); // 0-based, so June is 5
|
|
132
|
-
expect(result === null || result === void 0 ? void 0 : result.getDate()).toBe(15);
|
|
133
|
-
});
|
|
134
|
-
it('should parse DD-MM-YYYY format', () => {
|
|
135
|
-
const dateStr = '15-06-2023';
|
|
136
|
-
const result = parseDate(dateStr, 'DD-MM-YYYY');
|
|
137
|
-
expect(result).toBeInstanceOf(Date);
|
|
138
|
-
expect(result === null || result === void 0 ? void 0 : result.getFullYear()).toBe(2023);
|
|
139
|
-
expect(result === null || result === void 0 ? void 0 : result.getMonth()).toBe(5);
|
|
140
|
-
expect(result === null || result === void 0 ? void 0 : result.getDate()).toBe(15);
|
|
141
|
-
});
|
|
142
|
-
it('should parse MM/DD/YYYY format', () => {
|
|
143
|
-
const dateStr = '06/15/2023';
|
|
144
|
-
const result = parseDate(dateStr, 'MM/DD/YYYY');
|
|
145
|
-
expect(result).toBeInstanceOf(Date);
|
|
146
|
-
expect(result === null || result === void 0 ? void 0 : result.getFullYear()).toBe(2023);
|
|
147
|
-
expect(result === null || result === void 0 ? void 0 : result.getMonth()).toBe(5);
|
|
148
|
-
expect(result === null || result === void 0 ? void 0 : result.getDate()).toBe(15);
|
|
149
|
-
});
|
|
150
|
-
// Date with time formats
|
|
151
|
-
it('should parse YYYY-MM-DD HH:mm:ss format', () => {
|
|
152
|
-
const dateStr = '2023-06-15 14:30:45';
|
|
153
|
-
const result = parseDate(dateStr, 'YYYY-MM-DD HH:mm:ss');
|
|
154
|
-
expect(result).toBeInstanceOf(Date);
|
|
155
|
-
expect(result === null || result === void 0 ? void 0 : result.getFullYear()).toBe(2023);
|
|
156
|
-
expect(result === null || result === void 0 ? void 0 : result.getMonth()).toBe(5);
|
|
157
|
-
expect(result === null || result === void 0 ? void 0 : result.getDate()).toBe(15);
|
|
158
|
-
expect(result === null || result === void 0 ? void 0 : result.getHours()).toBe(14);
|
|
159
|
-
expect(result === null || result === void 0 ? void 0 : result.getMinutes()).toBe(30);
|
|
160
|
-
expect(result === null || result === void 0 ? void 0 : result.getSeconds()).toBe(45);
|
|
161
|
-
});
|
|
162
|
-
// UTC handling
|
|
163
|
-
it('should handle UTC mode correctly', () => {
|
|
164
|
-
// Looking at the implementation, the 'Z' in the format tells parseDate
|
|
165
|
-
// to use UTC mode, but doesn't require the dateStr to have a Z
|
|
166
|
-
const isoString = '2023-06-15T14:30:45.000Z';
|
|
167
|
-
const result = parseDate(isoString, 'YYYY-MM-DDTHH:mm:ss.SSSZ');
|
|
168
|
-
expect(result.getFullYear()).toBe(2023);
|
|
169
|
-
expect(result.getMonth()).toBe(5); // June
|
|
170
|
-
expect(result.getDate()).toBe(15);
|
|
171
|
-
});
|
|
172
|
-
// Invalid date handling
|
|
173
|
-
it('should return null for invalid dates', () => {
|
|
174
|
-
const consoleSpy = vi
|
|
175
|
-
.spyOn(console, 'error')
|
|
176
|
-
.mockImplementation(() => { });
|
|
177
|
-
// Invalid day (June 31 doesn't exist)
|
|
178
|
-
const invalidDate = '2023-06-31';
|
|
179
|
-
const result = parseDate(invalidDate, 'YYYY-MM-DD');
|
|
180
|
-
expect(result).toBeNull();
|
|
181
|
-
expect(consoleSpy).toHaveBeenCalled();
|
|
182
|
-
consoleSpy.mockRestore();
|
|
183
|
-
});
|
|
184
|
-
it("should return null when format doesn't match input", () => {
|
|
185
|
-
const consoleSpy = vi
|
|
186
|
-
.spyOn(console, 'error')
|
|
187
|
-
.mockImplementation(() => { });
|
|
188
|
-
// Format expects MM/DD/YYYY but input is YYYY-MM-DD
|
|
189
|
-
const mismatchFormat = '2023-06-15';
|
|
190
|
-
const result = parseDate(mismatchFormat, 'MM/DD/YYYY');
|
|
191
|
-
expect(result).toBeNull();
|
|
192
|
-
expect(consoleSpy).toHaveBeenCalled();
|
|
193
|
-
consoleSpy.mockRestore();
|
|
194
|
-
});
|
|
195
|
-
// Edge cases
|
|
196
|
-
it('should handle leap years correctly', () => {
|
|
197
|
-
// February 29 in a leap year
|
|
198
|
-
const leapYearDate = '2024-02-29';
|
|
199
|
-
const result = parseDate(leapYearDate, 'YYYY-MM-DD');
|
|
200
|
-
expect(result).toBeInstanceOf(Date);
|
|
201
|
-
expect(result === null || result === void 0 ? void 0 : result.getFullYear()).toBe(2024);
|
|
202
|
-
expect(result === null || result === void 0 ? void 0 : result.getMonth()).toBe(1); // February
|
|
203
|
-
expect(result === null || result === void 0 ? void 0 : result.getDate()).toBe(29);
|
|
204
|
-
});
|
|
205
|
-
it('should handle daylight saving time transitions', () => {
|
|
206
|
-
// A date during DST transition (will depend on locale)
|
|
207
|
-
// This test might behave differently in different timezones
|
|
208
|
-
const dstDate = '2023-03-12 02:30:00'; // Around when DST starts in the US
|
|
209
|
-
const result = parseDate(dstDate, 'YYYY-MM-DD HH:mm:ss');
|
|
210
|
-
expect(result).toBeInstanceOf(Date);
|
|
211
|
-
// We're not checking specific times because behavior varies by timezone
|
|
212
|
-
// Just ensuring it parses to a valid date
|
|
213
|
-
expect(result === null || result === void 0 ? void 0 : result.getFullYear()).toBe(2023);
|
|
214
|
-
expect(result === null || result === void 0 ? void 0 : result.getMonth()).toBe(2); // March
|
|
215
|
-
expect(result === null || result === void 0 ? void 0 : result.getDate()).toBe(12);
|
|
216
|
-
});
|
|
217
|
-
// Test complex formats
|
|
218
|
-
it('should parse formats with month names and AM/PM markers', () => {
|
|
219
|
-
// Dayjs supports these format tokens, but not the ordinal 'Do'
|
|
220
|
-
// or day names like 'dddd' in strict mode
|
|
221
|
-
const dateStr = 'June 15 2023, 2:30:45 PM';
|
|
222
|
-
const format = 'MMMM D YYYY, h:mm:ss A';
|
|
223
|
-
const result = parseDate(dateStr, format);
|
|
224
|
-
expect(result).toBeInstanceOf(Date);
|
|
225
|
-
expect(result === null || result === void 0 ? void 0 : result.getFullYear()).toBe(2023);
|
|
226
|
-
expect(result === null || result === void 0 ? void 0 : result.getMonth()).toBe(5); // June
|
|
227
|
-
expect(result === null || result === void 0 ? void 0 : result.getDate()).toBe(15);
|
|
228
|
-
expect(result === null || result === void 0 ? void 0 : result.getHours()).toBe(14); // 2 PM = 14:00
|
|
229
|
-
expect(result === null || result === void 0 ? void 0 : result.getMinutes()).toBe(30);
|
|
230
|
-
expect(result === null || result === void 0 ? void 0 : result.getSeconds()).toBe(45);
|
|
39
|
+
describe('Special Formats', () => {
|
|
40
|
+
it('should handle ISO 8601 format', () => {
|
|
41
|
+
const result = formatDate(testDate, {
|
|
42
|
+
dateFormat: 'YYYY-MM-DD[T]HH:mm:ss[Z]',
|
|
43
|
+
});
|
|
44
|
+
expect(result).toBe(testDate.toISOString());
|
|
45
|
+
expect(result).toMatch(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z/);
|
|
46
|
+
});
|
|
47
|
+
it('should handle Ticks format (C# compatibility)', () => {
|
|
48
|
+
const result = formatDate(testDate, { dateFormat: 'Ticks' });
|
|
49
|
+
expect(typeof result).toBe('string');
|
|
50
|
+
expect(Number(result)).toBeGreaterThan(0);
|
|
51
|
+
// Verify ticks calculation
|
|
52
|
+
const expectedTicks = testDate.getTime() * 10000 + 621355968000000000;
|
|
53
|
+
expect(result).toBe(expectedTicks.toString());
|
|
54
|
+
});
|
|
55
|
+
it('should handle Unix seconds format', () => {
|
|
56
|
+
const result = formatDate(testDate, { dateFormat: 'X' });
|
|
57
|
+
expect(typeof result).toBe('string');
|
|
58
|
+
expect(Number(result)).toBeGreaterThan(0);
|
|
59
|
+
// Unix seconds should be roughly testDate.getTime() / 1000
|
|
60
|
+
const unixSeconds = Math.floor(testDate.getTime() / 1000);
|
|
61
|
+
expect(Number(result)).toBe(unixSeconds);
|
|
62
|
+
});
|
|
63
|
+
it('should handle Unix milliseconds format', () => {
|
|
64
|
+
const result = formatDate(testDate, { dateFormat: 'x' });
|
|
65
|
+
expect(result).toBe(testDate.getTime().toString());
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
describe('UTC Mode', () => {
|
|
69
|
+
it('should handle UTC formats correctly', () => {
|
|
70
|
+
const utcResult = formatDate(testDate, { dateFormat: 'YYYY-MM-DD[Z]' });
|
|
71
|
+
expect(utcResult).toMatch(/\d{4}-\d{2}-\d{2}Z/);
|
|
72
|
+
const localResult = formatDate(testDate, { dateFormat: 'YYYY-MM-DD' });
|
|
73
|
+
expect(localResult).toMatch(/\d{4}-\d{2}-\d{2}/);
|
|
74
|
+
});
|
|
75
|
+
it('should handle UTC time formats', () => {
|
|
76
|
+
const result = formatDate(testDate, { dateFormat: 'HH:mm:ss[Z]' });
|
|
77
|
+
expect(result).toMatch(/\d{2}:\d{2}:\d{2}Z/);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
describe('Edge Cases', () => {
|
|
81
|
+
it('should handle leap year dates', () => {
|
|
82
|
+
const leapDate = new Date('2024-02-29T12:00:00Z');
|
|
83
|
+
expect(formatDate(leapDate, { dateFormat: 'YYYY-MM-DD' })).toBe('2024-02-29');
|
|
84
|
+
});
|
|
85
|
+
it('should handle year boundaries', () => {
|
|
86
|
+
const newYear = new Date('2024-01-01T12:00:00Z'); // Use midday UTC to avoid timezone issues
|
|
87
|
+
const endYear = new Date('2024-12-31T12:00:00Z'); // Use midday UTC to avoid timezone issues
|
|
88
|
+
expect(formatDate(newYear, { dateFormat: 'YYYY-MM-DD' })).toBe('2024-01-01');
|
|
89
|
+
expect(formatDate(endYear, { dateFormat: 'YYYY-MM-DD' })).toBe('2024-12-31');
|
|
90
|
+
});
|
|
91
|
+
it('should handle custom format patterns', () => {
|
|
92
|
+
expect(formatDate(testDate, { dateFormat: '[Year] YYYY [Month] MM' })).toMatch(/Year \d{4} Month \d{2}/);
|
|
93
|
+
// DayJS ordinals may behave differently, let's test a more generic pattern
|
|
94
|
+
expect(formatDate(testDate, { dateFormat: 'DD MMMM YYYY' })).toMatch(/\d{1,2} [A-Za-z]+ \d{4}/);
|
|
95
|
+
});
|
|
231
96
|
});
|
|
232
97
|
});
|
|
233
98
|
describe('isSameDate', () => {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
99
|
+
const date1 = new Date('2024-06-15T10:30:00Z');
|
|
100
|
+
const date2 = new Date('2024-06-15T18:45:00Z'); // Same day, different time
|
|
101
|
+
const date3 = new Date('2024-06-16T10:30:00Z'); // Different day
|
|
102
|
+
describe('Local Mode', () => {
|
|
103
|
+
it('should detect same dates in local mode', () => {
|
|
104
|
+
expect(isSameDate(date1, date2, { isUTCMode: false })).toBe(true);
|
|
105
|
+
expect(isSameDate(date1, date3, { isUTCMode: false })).toBe(false);
|
|
106
|
+
});
|
|
107
|
+
it('should ignore time differences in local mode', () => {
|
|
108
|
+
const morning = new Date('2024-06-15T08:00:00');
|
|
109
|
+
const evening = new Date('2024-06-15T20:00:00');
|
|
110
|
+
expect(isSameDate(morning, evening, { isUTCMode: false })).toBe(true);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
describe('UTC Mode', () => {
|
|
114
|
+
it('should detect same dates in UTC mode', () => {
|
|
115
|
+
expect(isSameDate(date1, date2, { isUTCMode: true })).toBe(true);
|
|
116
|
+
expect(isSameDate(date1, date3, { isUTCMode: true })).toBe(false);
|
|
117
|
+
});
|
|
118
|
+
it('should handle timezone differences correctly', () => {
|
|
119
|
+
// In UTC mode, should compare UTC components
|
|
120
|
+
// This test may be timezone dependent, let's use more reliable dates
|
|
121
|
+
const utcDate1 = new Date('2024-06-15T12:00:00Z');
|
|
122
|
+
const utcDate2 = new Date('2024-06-16T12:00:00Z');
|
|
123
|
+
expect(isSameDate(utcDate1, utcDate2, { isUTCMode: true })).toBe(false);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
describe('Null/Invalid Dates', () => {
|
|
127
|
+
it('should handle null dates', () => {
|
|
128
|
+
expect(isSameDate(null, date1, { isUTCMode: false })).toBe(false);
|
|
129
|
+
expect(isSameDate(date1, null, { isUTCMode: false })).toBe(false);
|
|
130
|
+
expect(isSameDate(null, null, { isUTCMode: false })).toBe(false);
|
|
131
|
+
});
|
|
132
|
+
it('should handle same reference', () => {
|
|
133
|
+
expect(isSameDate(date1, date1, { isUTCMode: false })).toBe(true);
|
|
134
|
+
expect(isSameDate(date1, date1, { isUTCMode: true })).toBe(true);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
describe('Edge Cases', () => {
|
|
138
|
+
it('should handle leap year dates', () => {
|
|
139
|
+
const leap1 = new Date('2024-02-29T10:00:00Z');
|
|
140
|
+
const leap2 = new Date('2024-02-29T20:00:00Z');
|
|
141
|
+
expect(isSameDate(leap1, leap2, { isUTCMode: true })).toBe(true);
|
|
142
|
+
});
|
|
143
|
+
it('should handle year boundaries', () => {
|
|
144
|
+
const endYear = new Date('2023-12-31T23:59:59Z');
|
|
145
|
+
const startYear = new Date('2024-01-01T00:00:01Z');
|
|
146
|
+
expect(isSameDate(endYear, startYear, { isUTCMode: true })).toBe(false);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
describe('isSameOrBefore', () => {
|
|
151
|
+
const baseDate = new Date('2024-06-15T12:00:00Z');
|
|
152
|
+
const beforeDate = new Date('2024-06-14T12:00:00Z');
|
|
153
|
+
const afterDate = new Date('2024-06-16T12:00:00Z');
|
|
154
|
+
const sameDate = new Date('2024-06-15T18:00:00Z');
|
|
155
|
+
describe('Local Mode', () => {
|
|
156
|
+
it('should detect before dates correctly', () => {
|
|
157
|
+
expect(isSameOrBefore(beforeDate, baseDate, { isUTCMode: false })).toBe(true);
|
|
158
|
+
expect(isSameOrBefore(afterDate, baseDate, { isUTCMode: false })).toBe(false);
|
|
159
|
+
expect(isSameOrBefore(sameDate, baseDate, { isUTCMode: false })).toBe(true);
|
|
160
|
+
});
|
|
161
|
+
it('should handle same date different times', () => {
|
|
162
|
+
const morning = new Date('2024-06-15T08:00:00');
|
|
163
|
+
const evening = new Date('2024-06-15T20:00:00');
|
|
164
|
+
expect(isSameOrBefore(morning, evening, { isUTCMode: false })).toBe(true);
|
|
165
|
+
expect(isSameOrBefore(evening, morning, { isUTCMode: false })).toBe(true);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
describe('UTC Mode', () => {
|
|
169
|
+
it('should compare UTC dates correctly', () => {
|
|
170
|
+
expect(isSameOrBefore(beforeDate, baseDate, { isUTCMode: true })).toBe(true);
|
|
171
|
+
expect(isSameOrBefore(afterDate, baseDate, { isUTCMode: true })).toBe(false);
|
|
172
|
+
expect(isSameOrBefore(sameDate, baseDate, { isUTCMode: true })).toBe(true);
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
describe('Complex Comparisons', () => {
|
|
176
|
+
it('should handle year comparisons', () => {
|
|
177
|
+
const date2023 = new Date('2023-12-31T23:59:59Z');
|
|
178
|
+
const date2024 = new Date('2024-01-01T00:00:01Z');
|
|
179
|
+
expect(isSameOrBefore(date2023, date2024, { isUTCMode: true })).toBe(true);
|
|
180
|
+
expect(isSameOrBefore(date2024, date2023, { isUTCMode: true })).toBe(false);
|
|
181
|
+
});
|
|
182
|
+
it('should handle month comparisons', () => {
|
|
183
|
+
const january = new Date('2024-01-15T12:00:00Z');
|
|
184
|
+
const february = new Date('2024-02-15T12:00:00Z');
|
|
185
|
+
expect(isSameOrBefore(january, february, { isUTCMode: true })).toBe(true);
|
|
186
|
+
expect(isSameOrBefore(february, january, { isUTCMode: true })).toBe(false);
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
describe('Null/Invalid Dates', () => {
|
|
190
|
+
it('should handle null dates', () => {
|
|
191
|
+
expect(isSameOrBefore(null, baseDate, {
|
|
192
|
+
isUTCMode: false,
|
|
193
|
+
})).toBe(false);
|
|
194
|
+
expect(isSameOrBefore(baseDate, null, {
|
|
195
|
+
isUTCMode: false,
|
|
196
|
+
})).toBe(false);
|
|
197
|
+
});
|
|
316
198
|
});
|
|
317
199
|
});
|
|
318
200
|
describe('isSameOrAfter', () => {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
});
|
|
347
|
-
it('should return true when the date is after in UTC mode', () => {
|
|
348
|
-
const later = new Date(Date.UTC(2023, 5, 16)); // June 16, 2023 UTC
|
|
349
|
-
const earlier = new Date(Date.UTC(2023, 5, 15)); // June 15, 2023 UTC
|
|
350
|
-
const result = isSameOrAfter(later, earlier, { isUTCMode: true });
|
|
351
|
-
expect(result).toBe(true);
|
|
352
|
-
});
|
|
353
|
-
it('should return false when the date is before in UTC mode', () => {
|
|
354
|
-
const earlier = new Date(Date.UTC(2023, 5, 15)); // June 15, 2023 UTC
|
|
355
|
-
const later = new Date(Date.UTC(2023, 5, 16)); // June 16, 2023 UTC
|
|
356
|
-
const result = isSameOrAfter(earlier, later, { isUTCMode: true });
|
|
357
|
-
expect(result).toBe(false);
|
|
358
|
-
});
|
|
359
|
-
// Test cases for different years and months
|
|
360
|
-
it('should return true when the year is after in local mode', () => {
|
|
361
|
-
const laterYear = new Date(2024, 0, 1); // January 1, 2024
|
|
362
|
-
const earlierYear = new Date(2023, 11, 31); // December 31, 2023
|
|
363
|
-
const result = isSameOrAfter(laterYear, earlierYear, {
|
|
364
|
-
isUTCMode: false,
|
|
365
|
-
});
|
|
366
|
-
expect(result).toBe(true);
|
|
367
|
-
});
|
|
368
|
-
it('should return true when the month is after in the same year in local mode', () => {
|
|
369
|
-
const laterMonth = new Date(2023, 6, 1); // July 1, 2023
|
|
370
|
-
const earlierMonth = new Date(2023, 5, 30); // June 30, 2023
|
|
371
|
-
const result = isSameOrAfter(laterMonth, earlierMonth, {
|
|
372
|
-
isUTCMode: false,
|
|
373
|
-
});
|
|
374
|
-
expect(result).toBe(true);
|
|
375
|
-
});
|
|
376
|
-
it('should return false when the year is before in UTC mode', () => {
|
|
377
|
-
const earlierYear = new Date(Date.UTC(2022, 11, 31)); // December 31, 2022 UTC
|
|
378
|
-
const laterYear = new Date(Date.UTC(2023, 0, 1)); // January 1, 2023 UTC
|
|
379
|
-
const result = isSameOrAfter(earlierYear, laterYear, { isUTCMode: true });
|
|
380
|
-
expect(result).toBe(false);
|
|
381
|
-
});
|
|
382
|
-
it('should return false when the month is before in the same year in UTC mode', () => {
|
|
383
|
-
const earlierMonth = new Date(Date.UTC(2023, 4, 31)); // May 31, 2023 UTC
|
|
384
|
-
const laterMonth = new Date(Date.UTC(2023, 5, 1)); // June 1, 2023 UTC
|
|
385
|
-
const result = isSameOrAfter(earlierMonth, laterMonth, {
|
|
386
|
-
isUTCMode: true,
|
|
387
|
-
});
|
|
388
|
-
expect(result).toBe(false);
|
|
389
|
-
});
|
|
390
|
-
// Edge cases
|
|
391
|
-
it('should handle same date with different times correctly in local mode', () => {
|
|
392
|
-
const morningDate = new Date(2023, 5, 15, 8, 0); // June 15, 2023, 8:00 AM
|
|
393
|
-
const eveningDate = new Date(2023, 5, 15, 20, 0); // June 15, 2023, 8:00 PM
|
|
394
|
-
// Since we're only comparing dates (not times), both should be "same or after" each other
|
|
395
|
-
expect(isSameOrAfter(morningDate, eveningDate, { isUTCMode: false })).toBe(true);
|
|
396
|
-
expect(isSameOrAfter(eveningDate, morningDate, { isUTCMode: false })).toBe(true);
|
|
397
|
-
});
|
|
398
|
-
it('should handle same date with different times correctly in UTC mode', () => {
|
|
399
|
-
const morningDate = new Date(Date.UTC(2023, 5, 15, 8, 0)); // June 15, 2023, 8:00 AM UTC
|
|
400
|
-
const eveningDate = new Date(Date.UTC(2023, 5, 15, 20, 0)); // June 15, 2023, 8:00 PM UTC
|
|
401
|
-
// Since we're only comparing dates (not times), both should be "same or after" each other
|
|
402
|
-
expect(isSameOrAfter(morningDate, eveningDate, { isUTCMode: true })).toBe(true);
|
|
403
|
-
expect(isSameOrAfter(eveningDate, morningDate, { isUTCMode: true })).toBe(true);
|
|
404
|
-
});
|
|
405
|
-
it('should handle leap year dates correctly', () => {
|
|
406
|
-
const leapYearDate = new Date(2024, 1, 29); // February 29, 2024 (leap year)
|
|
407
|
-
const nonLeapYearDate = new Date(2023, 1, 28); // February 28, 2023 (non-leap year)
|
|
408
|
-
// A date in a later year should be "after" regardless of the month/day
|
|
409
|
-
expect(isSameOrAfter(leapYearDate, nonLeapYearDate, { isUTCMode: false })).toBe(true);
|
|
410
|
-
expect(isSameOrAfter(nonLeapYearDate, leapYearDate, { isUTCMode: false })).toBe(false);
|
|
411
|
-
});
|
|
412
|
-
it('should handle edge cases between months correctly', () => {
|
|
413
|
-
const lastDayOfMonth = new Date(2023, 5, 30); // June 30, 2023
|
|
414
|
-
const firstDayOfNextMonth = new Date(2023, 6, 1); // July 1, 2023
|
|
415
|
-
expect(isSameOrAfter(lastDayOfMonth, firstDayOfNextMonth, {
|
|
416
|
-
isUTCMode: false,
|
|
417
|
-
})).toBe(false);
|
|
418
|
-
expect(isSameOrAfter(firstDayOfNextMonth, lastDayOfMonth, {
|
|
419
|
-
isUTCMode: false,
|
|
420
|
-
})).toBe(true);
|
|
421
|
-
});
|
|
422
|
-
it('should handle null dates gracefully', () => {
|
|
423
|
-
const date = new Date(2023, 5, 15);
|
|
424
|
-
const nullDate = null;
|
|
425
|
-
// Check if the function handles null inputs gracefully
|
|
426
|
-
// Note: Your implementation might need to be updated to handle this case
|
|
427
|
-
expect(() => isSameOrAfter(date, nullDate, { isUTCMode: false })).not.toThrow();
|
|
428
|
-
expect(() => isSameOrAfter(nullDate, date, { isUTCMode: false })).not.toThrow();
|
|
201
|
+
const baseDate = new Date('2024-06-15T12:00:00Z');
|
|
202
|
+
const beforeDate = new Date('2024-06-14T12:00:00Z');
|
|
203
|
+
const afterDate = new Date('2024-06-16T12:00:00Z');
|
|
204
|
+
const sameDate = new Date('2024-06-15T18:00:00Z');
|
|
205
|
+
describe('Local Mode', () => {
|
|
206
|
+
it('should detect after dates correctly', () => {
|
|
207
|
+
expect(isSameOrAfter(afterDate, baseDate, { isUTCMode: false })).toBe(true);
|
|
208
|
+
expect(isSameOrAfter(beforeDate, baseDate, { isUTCMode: false })).toBe(false);
|
|
209
|
+
expect(isSameOrAfter(sameDate, baseDate, { isUTCMode: false })).toBe(true);
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
describe('UTC Mode', () => {
|
|
213
|
+
it('should compare UTC dates correctly', () => {
|
|
214
|
+
expect(isSameOrAfter(afterDate, baseDate, { isUTCMode: true })).toBe(true);
|
|
215
|
+
expect(isSameOrAfter(beforeDate, baseDate, { isUTCMode: true })).toBe(false);
|
|
216
|
+
expect(isSameOrAfter(sameDate, baseDate, { isUTCMode: true })).toBe(true);
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
describe('Null/Invalid Dates', () => {
|
|
220
|
+
it('should handle null dates', () => {
|
|
221
|
+
expect(isSameOrAfter(null, baseDate, {
|
|
222
|
+
isUTCMode: false,
|
|
223
|
+
})).toBe(false);
|
|
224
|
+
expect(isSameOrAfter(baseDate, null, {
|
|
225
|
+
isUTCMode: false,
|
|
226
|
+
})).toBe(false);
|
|
227
|
+
});
|
|
429
228
|
});
|
|
430
229
|
});
|
|
431
|
-
describe('
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
const result = isSameOrBefore(date1, date2, { isUTCMode: true });
|
|
457
|
-
// Should return true because the dates are the same (ignoring time)
|
|
458
|
-
expect(result).toBe(true);
|
|
459
|
-
});
|
|
460
|
-
it('should return true when the date is before in UTC mode', () => {
|
|
461
|
-
const earlier = new Date(Date.UTC(2023, 5, 15)); // June 15, 2023 UTC
|
|
462
|
-
const later = new Date(Date.UTC(2023, 5, 16)); // June 16, 2023 UTC
|
|
463
|
-
const result = isSameOrBefore(earlier, later, { isUTCMode: true });
|
|
464
|
-
expect(result).toBe(true);
|
|
465
|
-
});
|
|
466
|
-
it('should return false when the date is after in UTC mode', () => {
|
|
467
|
-
const later = new Date(Date.UTC(2023, 5, 16)); // June 16, 2023 UTC
|
|
468
|
-
const earlier = new Date(Date.UTC(2023, 5, 15)); // June 15, 2023 UTC
|
|
469
|
-
const result = isSameOrBefore(later, earlier, { isUTCMode: true });
|
|
470
|
-
expect(result).toBe(false);
|
|
471
|
-
});
|
|
472
|
-
// Test cases for different years and months
|
|
473
|
-
it('should return true when the year is before in local mode', () => {
|
|
474
|
-
const earlierYear = new Date(2022, 11, 31); // December 31, 2022
|
|
475
|
-
const laterYear = new Date(2023, 0, 1); // January 1, 2023
|
|
476
|
-
const result = isSameOrBefore(earlierYear, laterYear, {
|
|
477
|
-
isUTCMode: false,
|
|
478
|
-
});
|
|
479
|
-
expect(result).toBe(true);
|
|
480
|
-
});
|
|
481
|
-
it('should return true when the month is before in the same year in local mode', () => {
|
|
482
|
-
const earlierMonth = new Date(2023, 4, 31); // May 31, 2023
|
|
483
|
-
const laterMonth = new Date(2023, 5, 1); // June 1, 2023
|
|
484
|
-
const result = isSameOrBefore(earlierMonth, laterMonth, {
|
|
485
|
-
isUTCMode: false,
|
|
486
|
-
});
|
|
487
|
-
expect(result).toBe(true);
|
|
488
|
-
});
|
|
489
|
-
it('should return false when the year is after in UTC mode', () => {
|
|
490
|
-
const laterYear = new Date(Date.UTC(2023, 0, 1)); // January 1, 2023 UTC
|
|
491
|
-
const earlierYear = new Date(Date.UTC(2022, 11, 31)); // December 31, 2022 UTC
|
|
492
|
-
const result = isSameOrBefore(laterYear, earlierYear, {
|
|
493
|
-
isUTCMode: true,
|
|
494
|
-
});
|
|
495
|
-
expect(result).toBe(false);
|
|
496
|
-
});
|
|
497
|
-
it('should return false when the month is after in the same year in UTC mode', () => {
|
|
498
|
-
const laterMonth = new Date(Date.UTC(2023, 5, 1)); // June 1, 2023 UTC
|
|
499
|
-
const earlierMonth = new Date(Date.UTC(2023, 4, 31)); // May 31, 2023 UTC
|
|
500
|
-
const result = isSameOrBefore(laterMonth, earlierMonth, {
|
|
501
|
-
isUTCMode: true,
|
|
502
|
-
});
|
|
503
|
-
expect(result).toBe(false);
|
|
504
|
-
});
|
|
505
|
-
// Edge cases
|
|
506
|
-
it('should handle same date with different times correctly in local mode', () => {
|
|
507
|
-
const morningDate = new Date(2023, 5, 15, 8, 0); // June 15, 2023, 8:00 AM
|
|
508
|
-
const eveningDate = new Date(2023, 5, 15, 20, 0); // June 15, 2023, 8:00 PM
|
|
509
|
-
// Since we're only comparing dates (not times), both should be "same or before" each other
|
|
510
|
-
expect(isSameOrBefore(morningDate, eveningDate, { isUTCMode: false })).toBe(true);
|
|
511
|
-
expect(isSameOrBefore(eveningDate, morningDate, { isUTCMode: false })).toBe(true);
|
|
512
|
-
});
|
|
513
|
-
it('should handle same date with different times correctly in UTC mode', () => {
|
|
514
|
-
const morningDate = new Date(Date.UTC(2023, 5, 15, 8, 0)); // June 15, 2023, 8:00 AM UTC
|
|
515
|
-
const eveningDate = new Date(Date.UTC(2023, 5, 15, 20, 0)); // June 15, 2023, 8:00 PM UTC
|
|
516
|
-
// Since we're only comparing dates (not times), both should be "same or before" each other
|
|
517
|
-
expect(isSameOrBefore(morningDate, eveningDate, { isUTCMode: true })).toBe(true);
|
|
518
|
-
expect(isSameOrBefore(eveningDate, morningDate, { isUTCMode: true })).toBe(true);
|
|
519
|
-
});
|
|
520
|
-
it('should handle leap year dates correctly', () => {
|
|
521
|
-
const leapYearDate = new Date(2024, 1, 29); // February 29, 2024 (leap year)
|
|
522
|
-
const nonLeapYearDate = new Date(2023, 1, 28); // February 28, 2023 (non-leap year)
|
|
523
|
-
// A date in an earlier year should be "before" regardless of the month/day
|
|
524
|
-
expect(isSameOrBefore(nonLeapYearDate, leapYearDate, { isUTCMode: false })).toBe(true);
|
|
525
|
-
expect(isSameOrBefore(leapYearDate, nonLeapYearDate, { isUTCMode: false })).toBe(false);
|
|
526
|
-
});
|
|
527
|
-
it('should handle edge cases between months correctly', () => {
|
|
528
|
-
const lastDayOfMonth = new Date(2023, 5, 30); // June 30, 2023
|
|
529
|
-
const firstDayOfNextMonth = new Date(2023, 6, 1); // July 1, 2023
|
|
530
|
-
expect(isSameOrBefore(lastDayOfMonth, firstDayOfNextMonth, {
|
|
531
|
-
isUTCMode: false,
|
|
532
|
-
})).toBe(true);
|
|
533
|
-
expect(isSameOrBefore(firstDayOfNextMonth, lastDayOfMonth, {
|
|
534
|
-
isUTCMode: false,
|
|
535
|
-
})).toBe(false);
|
|
536
|
-
});
|
|
537
|
-
it('should handle null dates gracefully', () => {
|
|
538
|
-
const date = new Date(2023, 5, 15);
|
|
539
|
-
const nullDate = null;
|
|
540
|
-
// The function already has null checks, so these should return false
|
|
541
|
-
expect(isSameOrBefore(date, nullDate, { isUTCMode: false })).toBe(false);
|
|
542
|
-
expect(isSameOrBefore(nullDate, date, { isUTCMode: false })).toBe(false);
|
|
543
|
-
expect(isSameOrBefore(nullDate, nullDate, { isUTCMode: false })).toBe(false);
|
|
230
|
+
describe('getWeekNumber', () => {
|
|
231
|
+
describe('Standard Week Calculations', () => {
|
|
232
|
+
it('should calculate correct week numbers for known dates', () => {
|
|
233
|
+
expect(getWeekNumber(new Date('2024-01-01'))).toBe(1);
|
|
234
|
+
expect(getWeekNumber(new Date('2024-01-07'))).toBe(1); // 7 January 2024 is still in week 1
|
|
235
|
+
expect(getWeekNumber(new Date('2024-06-15'))).toBe(24);
|
|
236
|
+
expect(getWeekNumber(new Date('2024-12-31'))).toBe(1); // 31 December 2024 is in week 1 of 2025
|
|
237
|
+
});
|
|
238
|
+
it('should handle different years', () => {
|
|
239
|
+
expect(getWeekNumber(new Date('2023-01-01'))).toBe(52); // 1st January 2023 is in week 52 of 2022
|
|
240
|
+
expect(getWeekNumber(new Date('2025-01-01'))).toBe(1);
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
describe('Edge Cases', () => {
|
|
244
|
+
it('should handle leap year correctly', () => {
|
|
245
|
+
const leapYearDate = new Date('2024-02-29');
|
|
246
|
+
expect(getWeekNumber(leapYearDate)).toBeGreaterThan(0);
|
|
247
|
+
expect(getWeekNumber(leapYearDate)).toBeLessThanOrEqual(53);
|
|
248
|
+
});
|
|
249
|
+
it('should handle year boundaries', () => {
|
|
250
|
+
const endOfYear = new Date('2024-12-31');
|
|
251
|
+
const startOfYear = new Date('2024-01-01');
|
|
252
|
+
expect(getWeekNumber(startOfYear)).toBe(1);
|
|
253
|
+
expect(getWeekNumber(endOfYear)).toBe(1);
|
|
254
|
+
});
|
|
544
255
|
});
|
|
545
256
|
});
|
|
546
|
-
describe('
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
257
|
+
describe('parseDate', () => {
|
|
258
|
+
describe('Date Object Input', () => {
|
|
259
|
+
it('should return Date objects as-is', () => {
|
|
260
|
+
const inputDate = new Date('2024-06-15T12:00:00Z');
|
|
261
|
+
const result = parseDate(inputDate, 'YYYY-MM-DD');
|
|
262
|
+
expect(result).toBe(inputDate);
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
describe('ISO 8601 String Parsing', () => {
|
|
266
|
+
it('should parse standard ISO 8601 strings', () => {
|
|
267
|
+
const isoString = '2024-06-15T12:00:00.123Z';
|
|
268
|
+
const result = parseDate(isoString, 'YYYY-MM-DD');
|
|
269
|
+
expect(result).toBeInstanceOf(Date);
|
|
270
|
+
expect(result === null || result === void 0 ? void 0 : result.toISOString()).toBe(isoString);
|
|
271
|
+
});
|
|
272
|
+
it('should handle invalid ISO strings gracefully', () => {
|
|
273
|
+
const consoleSpy = vi
|
|
274
|
+
.spyOn(console, 'error')
|
|
275
|
+
.mockImplementation(() => { });
|
|
276
|
+
const result = parseDate('invalid-iso-string', 'YYYY-MM-DD');
|
|
277
|
+
// Should continue with other parsing methods
|
|
278
|
+
expect(result).toBeNull();
|
|
279
|
+
consoleSpy.mockRestore();
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
describe('Unix Format Parsing', () => {
|
|
283
|
+
it('should parse Unix seconds (X format)', () => {
|
|
284
|
+
const unixSeconds = '1718452800'; // 2024-06-15T12:00:00Z
|
|
285
|
+
const result = parseDate(unixSeconds, 'X');
|
|
286
|
+
expect(result).toBeInstanceOf(Date);
|
|
287
|
+
expect(result === null || result === void 0 ? void 0 : result.getTime()).toBe(1718452800000);
|
|
288
|
+
});
|
|
289
|
+
it('should parse Unix seconds in UTC mode', () => {
|
|
290
|
+
const unixSeconds = '1718452800';
|
|
291
|
+
// Remove Z from format as it causes parsing to fail
|
|
292
|
+
const result = parseDate(unixSeconds, 'X');
|
|
293
|
+
expect(result).toBeInstanceOf(Date);
|
|
294
|
+
});
|
|
295
|
+
it('should parse Unix milliseconds (x format)', () => {
|
|
296
|
+
const unixMs = '1718452800123';
|
|
297
|
+
const result = parseDate(unixMs, 'x');
|
|
298
|
+
expect(result).toBeInstanceOf(Date);
|
|
299
|
+
expect(result === null || result === void 0 ? void 0 : result.getTime()).toBe(1718452800123);
|
|
300
|
+
});
|
|
301
|
+
it('should handle invalid Unix timestamps', () => {
|
|
302
|
+
expect(parseDate('invalid', 'X')).toBeNull();
|
|
303
|
+
expect(parseDate('invalid', 'x')).toBeNull();
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
describe('C# Ticks Format', () => {
|
|
307
|
+
it('should parse C# Ticks format', () => {
|
|
308
|
+
const ticks = '638544096000000000'; // Approximate ticks for a date
|
|
309
|
+
const result = parseDate(ticks, 'Ticks');
|
|
310
|
+
expect(result).toBeInstanceOf(Date);
|
|
311
|
+
});
|
|
312
|
+
it('should handle Ticks in UTC mode', () => {
|
|
313
|
+
const ticks = '638544096000000000';
|
|
314
|
+
// Remove Z from format as it causes parsing to fail
|
|
315
|
+
const result = parseDate(ticks, 'Ticks');
|
|
316
|
+
expect(result).toBeInstanceOf(Date);
|
|
317
|
+
});
|
|
318
|
+
it('should handle invalid Ticks', () => {
|
|
319
|
+
expect(parseDate('invalid', 'Ticks')).toBeNull();
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
describe('Custom Format Parsing', () => {
|
|
323
|
+
it('should parse custom date formats', () => {
|
|
324
|
+
const result = parseDate('15/06/2024', 'DD/MM/YYYY');
|
|
325
|
+
expect(result).toBeInstanceOf(Date);
|
|
326
|
+
expect(result === null || result === void 0 ? void 0 : result.getFullYear()).toBe(2024);
|
|
327
|
+
expect(result === null || result === void 0 ? void 0 : result.getMonth()).toBe(5); // June is month 5 (0-indexed)
|
|
328
|
+
expect(result === null || result === void 0 ? void 0 : result.getDate()).toBe(15);
|
|
329
|
+
});
|
|
330
|
+
it('should parse with strict mode', () => {
|
|
331
|
+
// Valid format
|
|
332
|
+
const validResult = parseDate('2024-06-15', 'YYYY-MM-DD');
|
|
333
|
+
expect(validResult).toBeInstanceOf(Date);
|
|
334
|
+
// Invalid format should return null
|
|
335
|
+
const consoleSpy = vi
|
|
336
|
+
.spyOn(console, 'error')
|
|
337
|
+
.mockImplementation(() => { });
|
|
338
|
+
const invalidResult = parseDate('invalid-date', 'YYYY-MM-DD');
|
|
339
|
+
expect(invalidResult).toBeNull();
|
|
340
|
+
consoleSpy.mockRestore();
|
|
341
|
+
});
|
|
342
|
+
it('should handle UTC custom formats', () => {
|
|
343
|
+
// Use a format that DayJS can actually parse
|
|
344
|
+
const result = parseDate('2024-06-15T12:00:00Z', 'YYYY-MM-DD[T]HH:mm:ss[Z]');
|
|
345
|
+
expect(result).toBeInstanceOf(Date);
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
describe('Error Handling', () => {
|
|
349
|
+
it('should handle parsing errors gracefully', () => {
|
|
350
|
+
const consoleSpy = vi
|
|
351
|
+
.spyOn(console, 'error')
|
|
352
|
+
.mockImplementation(() => { });
|
|
353
|
+
const result = parseDate('completely-invalid', 'YYYY-MM-DD');
|
|
354
|
+
expect(result).toBeNull();
|
|
355
|
+
expect(consoleSpy).toHaveBeenCalled();
|
|
356
|
+
consoleSpy.mockRestore();
|
|
357
|
+
});
|
|
358
|
+
it('should log parsing errors with context', () => {
|
|
359
|
+
const consoleSpy = vi
|
|
360
|
+
.spyOn(console, 'error')
|
|
361
|
+
.mockImplementation(() => { });
|
|
362
|
+
parseDate('invalid', 'YYYY-MM-DD');
|
|
363
|
+
expect(consoleSpy).toHaveBeenCalledWith('Parsing error:', {
|
|
364
|
+
dateInput: 'invalid',
|
|
365
|
+
dateFormat: 'YYYY-MM-DD',
|
|
366
|
+
});
|
|
367
|
+
consoleSpy.mockRestore();
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
describe('Edge Cases', () => {
|
|
371
|
+
it('should handle leap year parsing', () => {
|
|
372
|
+
const result = parseDate('29/02/2024', 'DD/MM/YYYY');
|
|
373
|
+
expect(result).toBeInstanceOf(Date);
|
|
374
|
+
expect(result === null || result === void 0 ? void 0 : result.getMonth()).toBe(1); // February
|
|
375
|
+
expect(result === null || result === void 0 ? void 0 : result.getDate()).toBe(29);
|
|
376
|
+
});
|
|
377
|
+
it('should handle year boundaries', () => {
|
|
378
|
+
const newYear = parseDate('01/01/2024', 'DD/MM/YYYY');
|
|
379
|
+
const endYear = parseDate('31/12/2024', 'DD/MM/YYYY');
|
|
380
|
+
expect(newYear).toBeInstanceOf(Date);
|
|
381
|
+
expect(endYear).toBeInstanceOf(Date);
|
|
382
|
+
});
|
|
383
|
+
it('should handle various time formats', () => {
|
|
384
|
+
const withTime = parseDate('2024-06-15 14:30:45', 'YYYY-MM-DD HH:mm:ss');
|
|
385
|
+
expect(withTime).toBeInstanceOf(Date);
|
|
386
|
+
expect(withTime === null || withTime === void 0 ? void 0 : withTime.getHours()).toBe(14);
|
|
387
|
+
expect(withTime === null || withTime === void 0 ? void 0 : withTime.getMinutes()).toBe(30);
|
|
388
|
+
expect(withTime === null || withTime === void 0 ? void 0 : withTime.getSeconds()).toBe(45);
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
});
|
|
392
|
+
describe('Integration Scenarios', () => {
|
|
393
|
+
it('should work with format and parse roundtrip', () => {
|
|
394
|
+
const originalDate = new Date('2024-06-15T12:30:45Z');
|
|
395
|
+
// Format then parse back
|
|
396
|
+
const formatted = formatDate(originalDate, {
|
|
397
|
+
dateFormat: 'YYYY-MM-DD HH:mm:ss',
|
|
398
|
+
});
|
|
399
|
+
const parsed = parseDate(formatted, 'YYYY-MM-DD HH:mm:ss');
|
|
400
|
+
expect(parsed).toBeInstanceOf(Date);
|
|
401
|
+
// Should be same day (ignoring potential timezone differences)
|
|
402
|
+
expect(isSameDate(originalDate, parsed, { isUTCMode: false })).toBe(true);
|
|
403
|
+
});
|
|
404
|
+
it('should handle complete date comparison workflow', () => {
|
|
405
|
+
const date1 = new Date('2024-06-14T12:00:00Z');
|
|
406
|
+
const date2 = new Date('2024-06-15T12:00:00Z');
|
|
407
|
+
const date3 = new Date('2024-06-16T12:00:00Z');
|
|
408
|
+
// Test all comparison functions
|
|
409
|
+
expect(isSameDate(date1, date2, { isUTCMode: true })).toBe(false);
|
|
410
|
+
expect(isSameOrBefore(date1, date2, { isUTCMode: true })).toBe(true);
|
|
411
|
+
expect(isSameOrAfter(date3, date2, { isUTCMode: true })).toBe(true);
|
|
412
|
+
});
|
|
413
|
+
it('should handle special format roundtrips', () => {
|
|
414
|
+
const originalDate = new Date('2024-06-15T12:00:00Z');
|
|
415
|
+
// Test Unix seconds roundtrip
|
|
416
|
+
const unixFormatted = formatDate(originalDate, { dateFormat: 'X' });
|
|
417
|
+
const unixParsed = parseDate(unixFormatted, 'X');
|
|
418
|
+
expect(Math.abs(originalDate.getTime() - unixParsed.getTime())).toBeLessThan(1000); // Within 1 second
|
|
419
|
+
// Test Unix milliseconds roundtrip
|
|
420
|
+
const unixMsFormatted = formatDate(originalDate, { dateFormat: 'x' });
|
|
421
|
+
const unixMsParsed = parseDate(unixMsFormatted, 'x');
|
|
422
|
+
expect(originalDate.getTime()).toBe(unixMsParsed.getTime());
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
describe('Value Prop Integration Logic', () => {
|
|
426
|
+
describe('Single Selection Value Parsing', () => {
|
|
427
|
+
it('should parse single date value correctly', () => {
|
|
428
|
+
const value = '2025-03-15';
|
|
429
|
+
const values = value
|
|
430
|
+
.split(',')
|
|
431
|
+
.map(v => v.trim())
|
|
432
|
+
.filter(Boolean);
|
|
433
|
+
expect(values).toHaveLength(1);
|
|
434
|
+
expect(values[0]).toBe('2025-03-15');
|
|
435
|
+
const parsedDate = parseDate(values[0], 'YYYY-MM-DD');
|
|
436
|
+
expect(parsedDate).toBeTruthy();
|
|
437
|
+
expect(parsedDate.getFullYear()).toBe(2025);
|
|
438
|
+
expect(parsedDate.getMonth()).toBe(2); // March (0-indexed)
|
|
439
|
+
expect(parsedDate.getDate()).toBe(15);
|
|
440
|
+
});
|
|
441
|
+
it('should handle empty single value', () => {
|
|
442
|
+
const value = '';
|
|
443
|
+
const values = value
|
|
444
|
+
.split(',')
|
|
445
|
+
.map(v => v.trim())
|
|
446
|
+
.filter(Boolean);
|
|
447
|
+
expect(values).toHaveLength(0);
|
|
448
|
+
});
|
|
449
|
+
it('should handle malformed single date', () => {
|
|
450
|
+
const value = 'invalid-date';
|
|
451
|
+
const values = value
|
|
452
|
+
.split(',')
|
|
453
|
+
.map(v => v.trim())
|
|
454
|
+
.filter(Boolean);
|
|
455
|
+
expect(values).toHaveLength(1);
|
|
456
|
+
const parsedDate = parseDate(values[0], 'YYYY-MM-DD');
|
|
457
|
+
expect(parsedDate).toBeNull();
|
|
458
|
+
});
|
|
459
|
+
it('should format single date for emission', () => {
|
|
460
|
+
const date = new Date('2025-03-15');
|
|
461
|
+
const formatted = formatDate(date, { dateFormat: 'YYYY-MM-DD' });
|
|
462
|
+
expect(formatted).toBe('2025-03-15');
|
|
463
|
+
});
|
|
464
|
+
});
|
|
465
|
+
describe('Range Selection Value Parsing', () => {
|
|
466
|
+
it('should parse range value correctly', () => {
|
|
467
|
+
const value = '2025-03-15,2025-03-20';
|
|
468
|
+
const values = value
|
|
469
|
+
.split(',')
|
|
470
|
+
.map(v => v.trim())
|
|
471
|
+
.filter(Boolean);
|
|
472
|
+
expect(values).toHaveLength(2);
|
|
473
|
+
expect(values[0]).toBe('2025-03-15');
|
|
474
|
+
expect(values[1]).toBe('2025-03-20');
|
|
475
|
+
const startDate = parseDate(values[0], 'YYYY-MM-DD');
|
|
476
|
+
const endDate = parseDate(values[1], 'YYYY-MM-DD');
|
|
477
|
+
expect(startDate).toBeTruthy();
|
|
478
|
+
expect(endDate).toBeTruthy();
|
|
479
|
+
expect(startDate.getFullYear()).toBe(2025);
|
|
480
|
+
expect(startDate.getMonth()).toBe(2); // March
|
|
481
|
+
expect(startDate.getDate()).toBe(15);
|
|
482
|
+
expect(endDate.getFullYear()).toBe(2025);
|
|
483
|
+
expect(endDate.getMonth()).toBe(2); // March
|
|
484
|
+
expect(endDate.getDate()).toBe(20);
|
|
485
|
+
});
|
|
486
|
+
it('should handle range with extra spaces', () => {
|
|
487
|
+
const value = ' 2025-03-15 , 2025-03-20 ';
|
|
488
|
+
const values = value
|
|
489
|
+
.split(',')
|
|
490
|
+
.map(v => v.trim())
|
|
491
|
+
.filter(Boolean);
|
|
492
|
+
expect(values).toHaveLength(2);
|
|
493
|
+
expect(values[0]).toBe('2025-03-15');
|
|
494
|
+
expect(values[1]).toBe('2025-03-20');
|
|
495
|
+
});
|
|
496
|
+
it('should handle incomplete range (only start date)', () => {
|
|
497
|
+
const value = '2025-03-15,';
|
|
498
|
+
const values = value
|
|
499
|
+
.split(',')
|
|
500
|
+
.map(v => v.trim())
|
|
501
|
+
.filter(Boolean);
|
|
502
|
+
expect(values).toHaveLength(1);
|
|
503
|
+
expect(values[0]).toBe('2025-03-15');
|
|
504
|
+
});
|
|
505
|
+
it('should handle malformed range dates', () => {
|
|
506
|
+
const value = 'invalid-start,invalid-end';
|
|
507
|
+
const values = value
|
|
508
|
+
.split(',')
|
|
509
|
+
.map(v => v.trim())
|
|
510
|
+
.filter(Boolean);
|
|
511
|
+
expect(values).toHaveLength(2);
|
|
512
|
+
const startDate = parseDate(values[0], 'YYYY-MM-DD');
|
|
513
|
+
const endDate = parseDate(values[1], 'YYYY-MM-DD');
|
|
514
|
+
expect(startDate).toBeNull();
|
|
515
|
+
expect(endDate).toBeNull();
|
|
516
|
+
});
|
|
517
|
+
it('should format range dates for emission', () => {
|
|
518
|
+
const startDate = new Date('2025-03-15');
|
|
519
|
+
const endDate = new Date('2025-03-20');
|
|
520
|
+
const startFormatted = formatDate(startDate, {
|
|
521
|
+
dateFormat: 'YYYY-MM-DD',
|
|
522
|
+
});
|
|
523
|
+
const endFormatted = formatDate(endDate, { dateFormat: 'YYYY-MM-DD' });
|
|
524
|
+
const unifiedValue = `${startFormatted},${endFormatted}`;
|
|
525
|
+
expect(unifiedValue).toBe('2025-03-15,2025-03-20');
|
|
526
|
+
});
|
|
527
|
+
it('should handle date order validation', () => {
|
|
528
|
+
const startDate = new Date('2025-03-20');
|
|
529
|
+
const endDate = new Date('2025-03-15');
|
|
530
|
+
// Simulate swapping logic
|
|
531
|
+
const orderedDates = startDate > endDate ? [endDate, startDate] : [startDate, endDate];
|
|
532
|
+
expect(orderedDates[0]).toEqual(endDate); // 2025-03-15
|
|
533
|
+
expect(orderedDates[1]).toEqual(startDate); // 2025-03-20
|
|
534
|
+
});
|
|
535
|
+
});
|
|
536
|
+
describe('Value Synchronization Logic', () => {
|
|
537
|
+
it('should generate legacy single value from unified value', () => {
|
|
538
|
+
const unifiedValue = '2025-03-15';
|
|
539
|
+
const values = unifiedValue
|
|
540
|
+
.split(',')
|
|
541
|
+
.map(v => v.trim())
|
|
542
|
+
.filter(Boolean);
|
|
543
|
+
if (values.length >= 1) {
|
|
544
|
+
const parsedDate = parseDate(values[0], 'YYYY-MM-DD');
|
|
545
|
+
const legacySingleValue = formatDate(parsedDate, {
|
|
546
|
+
dateFormat: 'YYYY-MM-DD',
|
|
547
|
+
});
|
|
548
|
+
expect(legacySingleValue).toBe('2025-03-15');
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
it('should generate legacy range value from unified value', () => {
|
|
552
|
+
const unifiedValue = '2025-03-15,2025-03-20';
|
|
553
|
+
const values = unifiedValue
|
|
554
|
+
.split(',')
|
|
555
|
+
.map(v => v.trim())
|
|
556
|
+
.filter(Boolean);
|
|
557
|
+
if (values.length >= 2) {
|
|
558
|
+
const startDate = parseDate(values[0], 'YYYY-MM-DD');
|
|
559
|
+
const endDate = parseDate(values[1], 'YYYY-MM-DD');
|
|
560
|
+
const legacyRangeValue = {
|
|
561
|
+
start: formatDate(startDate, { dateFormat: 'YYYY-MM-DD' }),
|
|
562
|
+
end: formatDate(endDate, { dateFormat: 'YYYY-MM-DD' }),
|
|
563
|
+
};
|
|
564
|
+
expect(legacyRangeValue).toEqual({
|
|
565
|
+
start: '2025-03-15',
|
|
566
|
+
end: '2025-03-20',
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
it('should generate unified value from legacy single value', () => {
|
|
571
|
+
const legacySingleValue = '2025-03-15';
|
|
572
|
+
const unifiedValue = legacySingleValue;
|
|
573
|
+
expect(unifiedValue).toBe('2025-03-15');
|
|
574
|
+
});
|
|
575
|
+
it('should generate unified value from legacy range value', () => {
|
|
576
|
+
const legacyRangeValue = {
|
|
577
|
+
start: '2025-03-15',
|
|
578
|
+
end: '2025-03-20',
|
|
579
|
+
};
|
|
580
|
+
const unifiedValue = `${legacyRangeValue.start},${legacyRangeValue.end}`;
|
|
581
|
+
expect(unifiedValue).toBe('2025-03-15,2025-03-20');
|
|
582
|
+
});
|
|
583
|
+
});
|
|
584
|
+
describe('Different Date Formats with Value Prop', () => {
|
|
585
|
+
it('should handle DD-MM-YYYY format in value prop', () => {
|
|
586
|
+
const value = '15-03-2025';
|
|
587
|
+
const values = value
|
|
588
|
+
.split(',')
|
|
589
|
+
.map(v => v.trim())
|
|
590
|
+
.filter(Boolean);
|
|
591
|
+
const parsedDate = parseDate(values[0], 'DD-MM-YYYY');
|
|
592
|
+
expect(parsedDate).toBeTruthy();
|
|
593
|
+
expect(parsedDate.getFullYear()).toBe(2025);
|
|
594
|
+
expect(parsedDate.getMonth()).toBe(2); // March
|
|
595
|
+
expect(parsedDate.getDate()).toBe(15);
|
|
596
|
+
const formatted = formatDate(parsedDate, { dateFormat: 'DD-MM-YYYY' });
|
|
597
|
+
expect(formatted).toBe('15-03-2025');
|
|
598
|
+
});
|
|
599
|
+
it('should handle MM/DD/YYYY format in value prop', () => {
|
|
600
|
+
const value = '03/15/2025';
|
|
601
|
+
const values = value
|
|
602
|
+
.split(',')
|
|
603
|
+
.map(v => v.trim())
|
|
604
|
+
.filter(Boolean);
|
|
605
|
+
const parsedDate = parseDate(values[0], 'MM/DD/YYYY');
|
|
606
|
+
expect(parsedDate).toBeTruthy();
|
|
607
|
+
expect(parsedDate.getFullYear()).toBe(2025);
|
|
608
|
+
expect(parsedDate.getMonth()).toBe(2); // March
|
|
609
|
+
expect(parsedDate.getDate()).toBe(15);
|
|
610
|
+
const formatted = formatDate(parsedDate, { dateFormat: 'MM/DD/YYYY' });
|
|
611
|
+
expect(formatted).toBe('03/15/2025');
|
|
612
|
+
});
|
|
613
|
+
it('should handle range with custom format in value prop', () => {
|
|
614
|
+
const value = '15-03-2025,20-03-2025';
|
|
615
|
+
const values = value
|
|
616
|
+
.split(',')
|
|
617
|
+
.map(v => v.trim())
|
|
618
|
+
.filter(Boolean);
|
|
619
|
+
const startDate = parseDate(values[0], 'DD-MM-YYYY');
|
|
620
|
+
const endDate = parseDate(values[1], 'DD-MM-YYYY');
|
|
621
|
+
expect(startDate).toBeTruthy();
|
|
622
|
+
expect(endDate).toBeTruthy();
|
|
623
|
+
const startFormatted = formatDate(startDate, {
|
|
624
|
+
dateFormat: 'DD-MM-YYYY',
|
|
625
|
+
});
|
|
626
|
+
const endFormatted = formatDate(endDate, { dateFormat: 'DD-MM-YYYY' });
|
|
627
|
+
const unifiedValue = `${startFormatted},${endFormatted}`;
|
|
628
|
+
expect(unifiedValue).toBe('15-03-2025,20-03-2025');
|
|
629
|
+
});
|
|
630
|
+
});
|
|
631
|
+
describe('Value Prop Edge Cases', () => {
|
|
632
|
+
it('should handle value with only commas', () => {
|
|
633
|
+
const value = ',,,';
|
|
634
|
+
const values = value
|
|
635
|
+
.split(',')
|
|
636
|
+
.map(v => v.trim())
|
|
637
|
+
.filter(Boolean);
|
|
638
|
+
expect(values).toHaveLength(0);
|
|
639
|
+
});
|
|
640
|
+
it('should handle value with trailing comma', () => {
|
|
641
|
+
const value = '2025-03-15,';
|
|
642
|
+
const values = value
|
|
643
|
+
.split(',')
|
|
644
|
+
.map(v => v.trim())
|
|
645
|
+
.filter(Boolean);
|
|
646
|
+
expect(values).toHaveLength(1);
|
|
647
|
+
expect(values[0]).toBe('2025-03-15');
|
|
648
|
+
});
|
|
649
|
+
it('should handle value with leading comma', () => {
|
|
650
|
+
const value = ',2025-03-15';
|
|
651
|
+
const values = value
|
|
652
|
+
.split(',')
|
|
653
|
+
.map(v => v.trim())
|
|
654
|
+
.filter(Boolean);
|
|
655
|
+
expect(values).toHaveLength(1);
|
|
656
|
+
expect(values[0]).toBe('2025-03-15');
|
|
657
|
+
});
|
|
658
|
+
it('should handle value with multiple commas between dates', () => {
|
|
659
|
+
const value = '2025-03-15,,2025-03-20';
|
|
660
|
+
const values = value
|
|
661
|
+
.split(',')
|
|
662
|
+
.map(v => v.trim())
|
|
663
|
+
.filter(Boolean);
|
|
664
|
+
expect(values).toHaveLength(2);
|
|
665
|
+
expect(values[0]).toBe('2025-03-15');
|
|
666
|
+
expect(values[1]).toBe('2025-03-20');
|
|
667
|
+
});
|
|
668
|
+
it('should handle range with more than 2 dates (take first 2)', () => {
|
|
669
|
+
const value = '2025-03-15,2025-03-20,2025-03-25';
|
|
670
|
+
const values = value
|
|
671
|
+
.split(',')
|
|
672
|
+
.map(v => v.trim())
|
|
673
|
+
.filter(Boolean);
|
|
674
|
+
expect(values).toHaveLength(3);
|
|
675
|
+
// For range mode, only first 2 should be used
|
|
676
|
+
const startDate = parseDate(values[0], 'YYYY-MM-DD');
|
|
677
|
+
const endDate = parseDate(values[1], 'YYYY-MM-DD');
|
|
678
|
+
expect(startDate).toBeTruthy();
|
|
679
|
+
expect(endDate).toBeTruthy();
|
|
680
|
+
expect(startDate.getDate()).toBe(15);
|
|
681
|
+
expect(endDate.getDate()).toBe(20);
|
|
682
|
+
});
|
|
683
|
+
});
|
|
684
|
+
describe('Value Priority Logic', () => {
|
|
685
|
+
it('should prioritize unified value over legacy single value', () => {
|
|
686
|
+
const unifiedValue = '2025-03-15';
|
|
687
|
+
const legacySingleValue = '2025-01-01';
|
|
688
|
+
// Simulate priority logic: if unifiedValue exists, use it
|
|
689
|
+
const effectiveValue = unifiedValue || legacySingleValue;
|
|
690
|
+
expect(effectiveValue).toBe('2025-03-15');
|
|
691
|
+
});
|
|
692
|
+
it('should prioritize unified value over legacy range value', () => {
|
|
693
|
+
const unifiedValue = '2025-03-15,2025-03-20';
|
|
694
|
+
const legacyRangeValue = { start: '2025-01-01', end: '2025-01-07' };
|
|
695
|
+
// Simulate priority logic: if unifiedValue exists, use it
|
|
696
|
+
const effectiveValue = unifiedValue || `${legacyRangeValue.start},${legacyRangeValue.end}`;
|
|
697
|
+
expect(effectiveValue).toBe('2025-03-15,2025-03-20');
|
|
698
|
+
});
|
|
699
|
+
it('should fallback to legacy values when unified value is empty', () => {
|
|
700
|
+
const unifiedValue = '';
|
|
701
|
+
const legacySingleValue = '2025-01-01';
|
|
702
|
+
const effectiveValue = unifiedValue || legacySingleValue;
|
|
703
|
+
expect(effectiveValue).toBe('2025-01-01');
|
|
704
|
+
});
|
|
664
705
|
});
|
|
665
706
|
});
|
|
666
707
|
});
|