import test from "node:test" import assert from "node:assert/strict" import { getBankAccountOwnerName, isExpiredBankingError, } from "../src/modules/cron/bankstatementsync.service" test("reads the GoCardless owner_name for a bank account", () => { assert.equal( getBankAccountOwnerName({ owner_name: "Neue Firma GmbH" }), "Neue Firma GmbH" ) }) test("does not overwrite the stored owner with an empty provider value", () => { assert.equal(getBankAccountOwnerName({ owner_name: "" }), null) assert.equal(getBankAccountOwnerName({}), null) assert.equal(getBankAccountOwnerName(null), null) }) test("recognizes expired EUA errors from direct and central banking responses", () => { assert.equal(isExpiredBankingError({ response: { data: { detail: "EUA was valid for 90 days and it expired" } } }), true) assert.equal(isExpiredBankingError(new Error("EUA was valid for 90 days and it expired")), true) assert.equal(isExpiredBankingError({ response: { data: { message: "temporary provider error" } } }), false) })