From fdd061270713975e6730a4da56f91dea451b9899 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 11 Jun 2026 03:32:57 +0000 Subject: [PATCH 1/2] test: add unit tests for parseCafefDate Co-authored-by: toreleon <42534763+toreleon@users.noreply.github.com> --- tests/cafef.test.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/cafef.test.ts diff --git a/tests/cafef.test.ts b/tests/cafef.test.ts new file mode 100644 index 0000000..4b90466 --- /dev/null +++ b/tests/cafef.test.ts @@ -0,0 +1,33 @@ +import { describe, it, expect } from "vitest"; +import { parseCafefDate } from "../src/data/sources/cafef"; + +describe("parseCafefDate", () => { + it("should return undefined for empty inputs", () => { + expect(parseCafefDate(undefined)).toBeUndefined(); + expect(parseCafefDate("")).toBeUndefined(); + }); + + it("should parse Microsoft date format correctly", () => { + const timestamp = 1777512060000; + const input = `/Date(${timestamp})/`; + const expected = new Date(timestamp).toISOString(); + expect(parseCafefDate(input)).toBe(expected); + }); + + it("should parse normal date strings and return ISO string", () => { + const input = "2024-05-15T10:30:00Z"; + const expected = new Date(input).toISOString(); + expect(parseCafefDate(input)).toBe(expected); + }); + + it("should return the original string if it is an invalid date string", () => { + const input = "invalid-date-string"; + expect(parseCafefDate(input)).toBe(input); + }); + + it("should handle already ISO-ish strings correctly", () => { + const input = "2023-12-01"; + const expected = new Date(input).toISOString(); + expect(parseCafefDate(input)).toBe(expected); + }); +}); From 9b233f27218cde08c2fed51055e713d8ffd3a3d1 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 11 Jun 2026 03:36:15 +0000 Subject: [PATCH 2/2] fix: update relative import to include explicit .js extension Co-authored-by: toreleon <42534763+toreleon@users.noreply.github.com> --- tests/cafef.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cafef.test.ts b/tests/cafef.test.ts index 4b90466..01d17d4 100644 --- a/tests/cafef.test.ts +++ b/tests/cafef.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from "vitest"; -import { parseCafefDate } from "../src/data/sources/cafef"; +import { parseCafefDate } from "../src/data/sources/cafef.js"; describe("parseCafefDate", () => { it("should return undefined for empty inputs", () => {