import { expect, test } from "vitest";

import { secondsUntilOsloMidnight } from "./revalidation.ts";

test("normal day: 12:00 CEST is 12h from midnight", () => {
  const now = new Date("2026-07-07T10:00:00Z");
  expect(secondsUntilOsloMidnight(now)).toBe(12 * 3600);
});

test("clamps to 60s just before midnight", () => {
  const now = new Date("2026-07-07T21:59:30Z");
  expect(secondsUntilOsloMidnight(now)).toBe(60);
});

test("DST fall-back day is 25h (2026-10-25)", () => {
  const now = new Date("2026-10-24T22:00:00Z");
  expect(secondsUntilOsloMidnight(now)).toBe(25 * 3600);
});

test("DST spring-forward day is 23h (2026-03-29)", () => {
  const now = new Date("2026-03-28T23:00:00Z");
  expect(secondsUntilOsloMidnight(now)).toBe(23 * 3600);
});
