38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { isFormAcceptingSubmissions } from "@/lib/form/form-availability";
|
|
|
|
const now = new Date("2026-07-30T12:00:00.000Z");
|
|
|
|
describe("isFormAcceptingSubmissions", () => {
|
|
test("keeps a manually open form without a deadline open", () => {
|
|
expect(isFormAcceptingSubmissions({ isOpen: true }, now)).toBe(true);
|
|
});
|
|
|
|
test("keeps a form open before its deadline", () => {
|
|
expect(
|
|
isFormAcceptingSubmissions(
|
|
{ isOpen: true, closesAt: "2026-07-30T12:00:01.000Z" },
|
|
now,
|
|
),
|
|
).toBe(true);
|
|
});
|
|
|
|
test("closes a form when its deadline is reached", () => {
|
|
expect(
|
|
isFormAcceptingSubmissions(
|
|
{ isOpen: true, closesAt: "2026-07-30T12:00:00.000Z" },
|
|
now,
|
|
),
|
|
).toBe(false);
|
|
});
|
|
|
|
test("manual closure overrides a future deadline", () => {
|
|
expect(
|
|
isFormAcceptingSubmissions(
|
|
{ isOpen: false, closesAt: "2026-08-01T12:00:00.000Z" },
|
|
now,
|
|
),
|
|
).toBe(false);
|
|
});
|
|
});
|