From 2d73627908c53440ae8a4859bb3f4e89146531a4 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 3 Dec 2025 20:58:52 +0200 Subject: [PATCH] test(dayjs): add a test for all plugins --- packages/commons/src/lib/dayjs.spec.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/commons/src/lib/dayjs.spec.ts b/packages/commons/src/lib/dayjs.spec.ts index 7e8f41a55b..5e78057472 100644 --- a/packages/commons/src/lib/dayjs.spec.ts +++ b/packages/commons/src/lib/dayjs.spec.ts @@ -12,6 +12,19 @@ describe("dayjs", () => { }); describe("Plugins", () => { + it("advanced format is available", () => { + expect(dayjs("2023-10-01").format("Q")).not.toBe("Q"); + }); + + it("is-between is available", () => { + expect(dayjs("2023-10-02").isBetween(dayjs("2023-10-01"), dayjs("2023-10-03"))).toBe(true); + }); + + it("iso-week is available", () => { + // ISO week number: 2023-01-01 is ISO week 52 of previous year + expect(dayjs("2023-01-01").isoWeek()).toBe(52); + }); + it("is-same-or-before is available", () => { expect(dayjs("2023-10-01").isSameOrBefore(dayjs("2023-10-02"))).toBe(true); }); @@ -20,12 +33,13 @@ describe("dayjs", () => { expect(dayjs("2023-10-02").isSameOrAfter(dayjs("2023-10-01"))).toBe(true); }); - it("is-between is available", () => { - expect(dayjs("2023-10-02").isBetween(dayjs("2023-10-01"), dayjs("2023-10-03"))).toBe(true); + it("quarter-year is available", () => { + expect(dayjs("2023-05-15").quarter()).toBe(2); }); - it("advanced format is available", () => { - expect(dayjs("2023-10-01").format("Q")).not.toBe("Q"); + it("utc is available", () => { + const utcDate = dayjs("2023-10-01T12:00:00").utc(); + expect(utcDate.utcOffset()).toBe(0); }); }); });