feat(overlay): show places gained since the start in the OBS tower
Heats and finals started together show ▲/▼ against the start order (new OBS option, on by default). In practice the best lap is no longer printed twice as both result and best. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
18
tests/overlay_position_change.test.js
Normal file
18
tests/overlay_position_change.test.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { getPositionChange } from "../src/overlays.js";
|
||||
|
||||
test("places gained or lost since the start - only for heats and finals started together", () => {
|
||||
const order = ["a", "b", "c", "d", "e"];
|
||||
const final = { type: "final", startMode: "position", status: "running" };
|
||||
assert.equal(getPositionChange(final, order, "e", 2), 3, "started 5th, now 2nd: +3");
|
||||
assert.equal(getPositionChange(final, order, "a", 3), -2, "started 1st, now 3rd: -2");
|
||||
assert.equal(getPositionChange(final, order, "c", 3), 0);
|
||||
assert.equal(getPositionChange(final, order, "late_entry", 1), null, "not in the start order");
|
||||
assert.equal(getPositionChange({ ...final, startMode: "mass", type: "heat" }, order, "e", 1), 4);
|
||||
assert.equal(getPositionChange({ ...final, status: "ready" }, order, "e", 2), null, "not before the start");
|
||||
assert.equal(getPositionChange({ ...final, type: "open_practice" }, order, "e", 2), null, "practice ranks on best lap");
|
||||
assert.equal(getPositionChange({ ...final, type: "qualification" }, order, "e", 2), null, "qualifying has individual clocks");
|
||||
assert.equal(getPositionChange({ ...final, startMode: "flying" }, order, "e", 2), null, "no common start order");
|
||||
assert.equal(getPositionChange(null, order, "e", 2), null);
|
||||
});
|
||||
Reference in New Issue
Block a user