Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/packages/exports/src/limits-edge.test.ts
T
2026-07-08 16:15:37 +02:00

33 lines
1.4 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { EXPORT_PLAN_ROW_CAPS, ExportRowCapExceededError, resolveExportRowCap } from "./limits.js";
describe("resolveExportRowCap — unknown format fallback", () => {
it("falls back to an unbounded format cap for unrecognised formats", () => {
// Unknown format -> FORMAT_HARD_CAPS lookup misses -> Infinity fallback;
// the enterprise plan is also unbounded, so the effective cap is Infinity.
expect(resolveExportRowCap("enterprise", "parquet" as never)).toBe(Number.POSITIVE_INFINITY);
});
it("still applies the plan cap when only the format is unknown", () => {
expect(resolveExportRowCap("free", "parquet" as never)).toBe(EXPORT_PLAN_ROW_CAPS.free);
});
});
describe("ExportRowCapExceededError message", () => {
it("describes an unbounded cap as 'unlimited' rather than 'Infinity'", () => {
const error = new ExportRowCapExceededError(100, Number.POSITIVE_INFINITY, "enterprise", "csv");
expect(error.message).toContain("unlimited");
expect(error.message).not.toContain("Infinity");
expect(error.code).toBe("EXPORT_ROW_LIMIT_PLAN");
});
it("prints the numeric cap when it is finite", () => {
const error = new ExportRowCapExceededError(20_000, 10_000, "free", "csv");
expect(error.message).toContain("10000");
expect(error.message).not.toContain("unlimited");
});
});