Split- och depåstatistik är implementerad
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
} from "../src/event_race_logic.js";
|
||||
import {
|
||||
buildFinalStandings,
|
||||
buildSessionChannelStats,
|
||||
compareNumberSet,
|
||||
formatLeaderboardGap,
|
||||
getCompetitorSeedMetric,
|
||||
@@ -423,3 +424,26 @@ test("final standings count the configured best legs per main", () => {
|
||||
assert.equal(standings[0].score, "2 (1+1+2)");
|
||||
assert.equal(standings[1].score, "3 (1+2+2)");
|
||||
});
|
||||
|
||||
test("session channel statistics summarize splits and pit stops per competitor", () => {
|
||||
const result = {
|
||||
competitors: {
|
||||
team_1: { displayName: "Team One", driverName: "Driver One", carName: "Car One" },
|
||||
},
|
||||
splits: [
|
||||
{ competitorKey: "team_1", splitMs: 8000 },
|
||||
{ competitorKey: "team_1", splitMs: 7600 },
|
||||
],
|
||||
pitStops: [
|
||||
{ competitorKey: "team_1", driverName: "Driver One", carName: "Car One", enteredAt: 100000, exitedAt: 112000, pitStopMs: 12000 },
|
||||
{ competitorKey: "team_1", driverName: "Driver Two", carName: "Car Two", enteredAt: 200000, exitedAt: 209000, pitStopMs: 9000 },
|
||||
],
|
||||
};
|
||||
const stats = buildSessionChannelStats({ id: "session_1" }, { ensureSessionResult: () => result });
|
||||
assert.equal(stats.splitCount, 2);
|
||||
assert.equal(stats.pitStopCount, 2);
|
||||
assert.equal(stats.totalPitMs, 21000);
|
||||
assert.equal(stats.competitors[0].averageSplitMs, 7800);
|
||||
assert.equal(stats.competitors[0].bestPitStopMs, 9000);
|
||||
assert.equal(stats.pitStops[1].driverName, "Driver Two");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user