From 32c727be5abd5fb8bb5bfcc9c27a1f5b4d2ddc06 Mon Sep 17 00:00:00 2001 From: Freddie Yebra Date: Tue, 7 Jan 2025 12:49:58 -0600 Subject: [PATCH 1/2] Add test case to dateUtil. --- frontend/tests/utils/dateUtil.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/tests/utils/dateUtil.test.ts b/frontend/tests/utils/dateUtil.test.ts index b4213f36d..3349b7d72 100644 --- a/frontend/tests/utils/dateUtil.test.ts +++ b/frontend/tests/utils/dateUtil.test.ts @@ -17,4 +17,10 @@ describe("formatDate", () => { it("returns a human readable string for properly formatted dates", () => { expect(formatDate("2024-10-10")).toBe("October 10, 2024"); }); + + it("invokes console warn when date string does not contain 3 parts", () => { + const logSpy = jest.spyOn(global.console, "warn"); + formatDate("10-1019999"); + expect(logSpy).toHaveBeenCalledWith("invalid date string provided for parse"); + }); }); From a7197543285a81bb05dfe6c6f741762c5738080d Mon Sep 17 00:00:00 2001 From: Freddie Yebra Date: Tue, 7 Jan 2025 14:06:03 -0600 Subject: [PATCH 2/2] Fix linting. --- frontend/tests/utils/dateUtil.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/tests/utils/dateUtil.test.ts b/frontend/tests/utils/dateUtil.test.ts index 3349b7d72..8529eb04c 100644 --- a/frontend/tests/utils/dateUtil.test.ts +++ b/frontend/tests/utils/dateUtil.test.ts @@ -21,6 +21,8 @@ describe("formatDate", () => { it("invokes console warn when date string does not contain 3 parts", () => { const logSpy = jest.spyOn(global.console, "warn"); formatDate("10-1019999"); - expect(logSpy).toHaveBeenCalledWith("invalid date string provided for parse"); + expect(logSpy).toHaveBeenCalledWith( + "invalid date string provided for parse", + ); }); });