From 99a482356cdae5faff1a24e8d5489a648912feca Mon Sep 17 00:00:00 2001 From: Lars Decker Date: Sat, 27 Dec 2025 03:45:47 +0100 Subject: [PATCH 1/2] Fix FinTS TIME formatting and coverage --- packages/fints/src/__tests__/test-format.ts | 15 +++++++++++++++ .../fints/src/__tests__/test-pin-tan-client.ts | 4 ++-- packages/fints/src/format.ts | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 packages/fints/src/__tests__/test-format.ts diff --git a/packages/fints/src/__tests__/test-format.ts b/packages/fints/src/__tests__/test-format.ts new file mode 100644 index 0000000..b7f7d14 --- /dev/null +++ b/packages/fints/src/__tests__/test-format.ts @@ -0,0 +1,15 @@ +import { Format } from "../format"; + +// FinTS 3.0 Formals TIME datatype (https://www.hbci-zka.de/downloads/FinTS_3_0/FinTS3.0_Formals_2010-12-20_final_version.pdf) +// specifies HHmmss with minutes rather than months. +describe("Format.time", () => { + it("formats hours, minutes, and seconds as HHmmss", () => { + const date = new Date(Date.UTC(2024, 11, 24, 8, 3, 45)); + expect(Format.time(date)).toBe("080345"); + }); + + it("does not substitute the month for minutes", () => { + const date = new Date(Date.UTC(2024, 5, 15, 12, 59, 1)); + expect(Format.time(date)).toBe("125901"); + }); +}); diff --git a/packages/fints/src/__tests__/test-pin-tan-client.ts b/packages/fints/src/__tests__/test-pin-tan-client.ts index 658f8b1..7f52862 100644 --- a/packages/fints/src/__tests__/test-pin-tan-client.ts +++ b/packages/fints/src/__tests__/test-pin-tan-client.ts @@ -15,8 +15,8 @@ const productId = "fints"; let client: PinTanClient; beforeEach(() => { - jest.spyOn(Format, "date").mockImplementation((date) => (date ? format(date, "HHMMss") : "20180101")); - jest.spyOn(Format, "time").mockImplementation((time) => (time ? format(time, "HHMMss") : "120000")); + jest.spyOn(Format, "date").mockImplementation((date) => (date ? format(date, "HHmmss") : "20180101")); + jest.spyOn(Format, "time").mockImplementation((time) => (time ? format(time, "HHmmss") : "120000")); jest.spyOn(Math, "random").mockReturnValue(0.5); client = new PinTanClient({ blz, name, pin, url, productId }); }); diff --git a/packages/fints/src/format.ts b/packages/fints/src/format.ts index 48a218f..e50cb6f 100644 --- a/packages/fints/src/format.ts +++ b/packages/fints/src/format.ts @@ -86,7 +86,8 @@ export const Format = { */ time(date?: Date) { const dateToFormat = date ? date : new Date(); - return format(dateToFormat, "HHMMss"); + // FinTS 3.0 Formals (TIME datatype) requires HHmmss with minutes, see https://www.hbci-zka.de/downloads/FinTS_3_0/FinTS3.0_Formals_2010-12-20_final_version.pdf. + return format(dateToFormat, "HHmmss"); }, /** * Return an empty string. From 98615735a6cd42eba27c4bf0e3840aecb4240efb Mon Sep 17 00:00:00 2001 From: Lars Decker Date: Sat, 27 Dec 2025 03:49:40 +0100 Subject: [PATCH 2/2] Update packages/fints/src/__tests__/test-pin-tan-client.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- packages/fints/src/__tests__/test-pin-tan-client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fints/src/__tests__/test-pin-tan-client.ts b/packages/fints/src/__tests__/test-pin-tan-client.ts index 7f52862..ecb1df3 100644 --- a/packages/fints/src/__tests__/test-pin-tan-client.ts +++ b/packages/fints/src/__tests__/test-pin-tan-client.ts @@ -15,7 +15,7 @@ const productId = "fints"; let client: PinTanClient; beforeEach(() => { - jest.spyOn(Format, "date").mockImplementation((date) => (date ? format(date, "HHmmss") : "20180101")); + jest.spyOn(Format, "date").mockImplementation((date) => (date ? format(date, "yyyyMMdd") : "20180101")); jest.spyOn(Format, "time").mockImplementation((time) => (time ? format(time, "HHmmss") : "120000")); jest.spyOn(Math, "random").mockReturnValue(0.5); client = new PinTanClient({ blz, name, pin, url, productId });