feat(race-day): live race for the race controller with order, laps, gaps and estimated finish (1.47.0)
This commit is contained in:
1 parent
c4163441fc
commit
54487a18a6
12 files changed
+169
-7
No files matched your search
@@ -0,0 +1,14 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { estimateFinish } from "../src/timing_logic.js";
|
||||
|
||||
test("estimated finish: laps and time when a 5-minute heat is up, at the car's recent pace", () => {
|
||||
// 10 laps in 3:00, last two laps 18 s: 120 s left = 7 more laps (the 7th crosses after 5:00).
|
||||
assert.deepEqual(estimateFinish({ laps: 10, totalElapsedMs: 180000, lastLapMs: 18000, previousLapMs: 18000 }, 300000), { laps: 17, timeMs: 306000, paceMs: 18000 });
|
||||
// No recent laps known: the average lap.
|
||||
assert.equal(estimateFinish({ laps: 4, totalElapsedMs: 80000 }, 300000).paceMs, 20000);
|
||||
// Over time: the laps it has are its result.
|
||||
assert.deepEqual(estimateFinish({ laps: 16, totalElapsedMs: 301000, lastLapMs: 19000 }, 300000), { laps: 16, timeMs: 301000, paceMs: 19000 });
|
||||
assert.equal(estimateFinish({ laps: 0, totalElapsedMs: 0 }, 300000), null, "no lap yet");
|
||||
assert.equal(estimateFinish({ laps: 5, totalElapsedMs: 90000 }, null), null, "untimed session");
|
||||
});
|
||||
Reference in new issue
Block a user