From ad5b47f2a509c93f5f7d8b827d21b95aa128f92e Mon Sep 17 00:00:00 2001 From: James Collins Date: Fri, 24 Mar 2023 09:31:27 +1000 Subject: [PATCH] updated tests for new SMDate object --- resources/js/tests/datetime.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/js/tests/datetime.test.ts b/resources/js/tests/datetime.test.ts index a130bf1..01d4d12 100644 --- a/resources/js/tests/datetime.test.ts +++ b/resources/js/tests/datetime.test.ts @@ -1,33 +1,33 @@ import { expect, describe, it } from "vitest"; -import { format } from "../helpers/datetime"; +import { SMDate } from "../helpers/datetime"; describe("format()", () => { it("should return an empty string when the first argument is not a Date object", () => { - const result = format("not a date", "yyyy-MM-dd"); + const result = new SMDate("not a date").format("yyyy-MM-dd"); expect(result).toEqual(""); }); it("should format the date correctly", () => { const date = new Date("2022-02-19T12:34:56"); - const result = format(date, "yyyy-MM-dd HH:mm:ss"); + const result = new SMDate(date).format("yyyy-MM-dd HH:mm:ss"); expect(result).toEqual("2022-02-19 12:34:56"); }); it("should handle single-digit month and day", () => { const date = new Date("2022-01-01T00:00:00"); - const result = format(date, "yy-M-d"); + const result = new SMDate(date).format("yy-M-d"); expect(result).toEqual("22-1-1"); }); it("should handle day of week and month name abbreviations", () => { const date = new Date("2022-03-22T00:00:00"); - const result = format(date, "EEE, MMM dd, yyyy"); + const result = new SMDate(date).format("EEE, MMM dd, yyyy"); expect(result).toEqual("Tue, Mar 22, 2022"); }); it("should handle 12-hour clock with am/pm", () => { const date = new Date("2022-01-01T12:34:56"); - const result = format(date, "hh:mm:ss aa"); + const result = new SMDate(date).format("hh:mm:ss aa"); expect(result).toEqual("12:34:56 pm"); }); });