返回 DeepSeek-Reasonix
restartBudget.test.ts
根目录 / desktop / electron / src / main / restartBudget.test.ts
1 import assert from "node:assert/strict";
2 import { test } from "node:test";
3 import { RestartBudget } from "./restartBudget.js";
4
5 test("three automatic restarts per five minutes, then the budget is exhausted", () => {
6 const budget = new RestartBudget();
7 const start = 1_000_000;
8 assert.equal(budget.allow(start), true);
9 assert.equal(budget.allow(start + 1_000), true);
10 assert.equal(budget.allow(start + 2_000), true);
11 assert.equal(budget.allow(start + 3_000), false);
12 assert.equal(budget.allow(start + 4 * 60_000), false, "still inside the window");
13 assert.equal(budget.allow(start + 5 * 60_000 + 1), true, "the oldest restart aged out");
14 assert.equal(budget.allow(start + 5 * 60_000 + 2), false);
15 });
16
16 lines TYPESCRIPT