26 lines
1.2 KiB
JavaScript
26 lines
1.2 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { getScheduleDriftSummary } from "../src/core_views.js";
|
|
|
|
const now = new Date(2026, 10, 16, 21, 0, 0).getTime();
|
|
const min = 60000;
|
|
|
|
test("schedule drift: nothing started today shows no drift", () => {
|
|
const lastWeek = now - 3 * 24 * 60 * min;
|
|
const state = { sessions: [{ type: "qualification", durationMin: 5, startedAt: lastWeek, endedAt: lastWeek + 6 * min, status: "finished" }] };
|
|
assert.equal(getScheduleDriftSummary(state, now), null);
|
|
});
|
|
|
|
test("schedule drift: a running open practice never counts", () => {
|
|
const state = { sessions: [{ type: "open_practice", durationMin: 0, startedAt: now - 130 * min, status: "running" }] };
|
|
assert.equal(getScheduleDriftSummary(state, now), null);
|
|
});
|
|
|
|
test("schedule drift: today's timed heats are compared with their planned length", () => {
|
|
const state = { sessions: [
|
|
{ type: "qualification", durationMin: 5, startedAt: now - 60 * min, endedAt: now - 53 * min, status: "finished" },
|
|
{ type: "free_practice", durationMin: 0, startedAt: now - 120 * min, endedAt: now - 70 * min, status: "finished" },
|
|
] };
|
|
assert.deepEqual(getScheduleDriftSummary(state, now), { plannedMs: 5 * min, actualMs: 7 * min, driftMs: 2 * min });
|
|
});
|