Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/packages/billing/src/payment-reservation.test.ts
T

25 lines
962 B
TypeScript

import { describe, expect, it } from "vitest";
import { MAX_MOLLIE_PAYMENT_LIFETIME_MS, MOLLIE_RECONCILIATION_GRACE_MS, resolvePaymentReservation } from "./payment-reservation.js";
describe("Mollie product-acquisition reservation", () => {
const now = new Date("2026-07-17T12:00:00.000Z");
it("uses the provider expiry plus reconciliation grace", () => {
expect(resolvePaymentReservation({ expiresAt: "2026-07-30T12:00:00.000Z" }, now)).toEqual({
expiresAt: new Date("2026-08-01T12:00:00.000Z"),
trusted: true,
});
});
it.each([null, "invalid", "2026-07-17T11:59:59.000Z", "2027-01-01T00:00:00.000Z"])(
"quarantines an untrusted provider expiry %s under a bounded deadline",
(expiresAt) => {
expect(resolvePaymentReservation({ expiresAt }, now)).toEqual({
expiresAt: new Date(now.getTime() + MAX_MOLLIE_PAYMENT_LIFETIME_MS + MOLLIE_RECONCILIATION_GRACE_MS),
trusted: false,
});
},
);
});