Skip to content
21 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { BUSY_LIMIT, stillBusy } from "./busy.ts";
5
6test("a pressed button is busy until the status changes", () => {
7 const press = { status: "starting", at: 1_000 };
8 assert.equal(stillBusy(press, "starting", 1_500), true);
9 assert.equal(stillBusy(press, "running", 1_500), false);
10});
11
12test("a pressed button is given back when nothing changes for a while", () => {
13 const press = { status: "starting", at: 1_000 };
14 assert.equal(stillBusy(press, "starting", 1_000 + BUSY_LIMIT - 1), true);
15 assert.equal(stillBusy(press, "starting", 1_000 + BUSY_LIMIT), false);
16 assert.equal(BUSY_LIMIT, 20_000);
17});
18
19test("a button nobody pressed is not busy", () => {
20 assert.equal(stillBusy(null, "starting", 0), false);
21});