Split- och depåstatistik är implementerad
This commit is contained in:
@@ -4,6 +4,7 @@ import assert from "node:assert/strict";
|
||||
import {
|
||||
buildDriverActivePracticeStats,
|
||||
buildDriverTrainingStats,
|
||||
buildDriverTimingChannelStats,
|
||||
buildTrainingRecommendation,
|
||||
getBestConsecutiveTrainingLaps,
|
||||
getBestTrainingDurationResult,
|
||||
@@ -110,6 +111,48 @@ test("driver statistics remain isolated and aggregate days and sessions", () =>
|
||||
assert.equal(stats.dailySummaries[1].laps, 2);
|
||||
});
|
||||
|
||||
test("split and pit statistics aggregate by personal profile and selected class", () => {
|
||||
const state = {
|
||||
drivers: [
|
||||
{ id: "driver_2wd_a", name: "Driver", profileId: "profile_1", classId: "class_2wd" },
|
||||
{ id: "driver_2wd_b", name: "Driver", profileId: "profile_1", classId: "class_2wd" },
|
||||
{ id: "driver_4wd", name: "Driver", profileId: "profile_1", classId: "class_4wd" },
|
||||
],
|
||||
sessions: [
|
||||
{ id: "session_1", name: "Practice", eventId: "event_1" },
|
||||
{ id: "session_2", name: "Endurance", eventId: "event_1" },
|
||||
],
|
||||
events: [{ id: "event_1", name: "Club day" }],
|
||||
resultsBySession: {
|
||||
session_1: {
|
||||
splits: [
|
||||
{ driverId: "driver_2wd_a", splitMs: 8100, timestamp: 1000 },
|
||||
{ driverId: "driver_2wd_b", splitMs: 7900, timestamp: 2000 },
|
||||
{ driverId: "driver_4wd", splitMs: 6500, timestamp: 3000 },
|
||||
],
|
||||
pitStops: [],
|
||||
},
|
||||
session_2: {
|
||||
splits: [],
|
||||
pitStops: [
|
||||
{ driverId: "driver_2wd_a", pitStopMs: 12500, enteredAt: 4000 },
|
||||
{ driverId: "driver_2wd_b", pitStopMs: 9500, enteredAt: 5000 },
|
||||
{ driverId: "driver_4wd", pitStopMs: 7000, enteredAt: 6000 },
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const stats = buildDriverTimingChannelStats(state, "profile_1", "class_2wd");
|
||||
assert.equal(stats.splitCount, 2);
|
||||
assert.equal(stats.bestSplitMs, 7900);
|
||||
assert.equal(stats.averageSplitMs, 8000);
|
||||
assert.equal(stats.pitStopCount, 2);
|
||||
assert.equal(stats.totalPitMs, 22000);
|
||||
assert.equal(stats.bestPitStopMs, 9500);
|
||||
assert.equal(stats.recentPitStops[0].sessionName, "Endurance");
|
||||
});
|
||||
|
||||
test("one driver profile combines transponders within a class but keeps 2WD and 4WD separate", () => {
|
||||
const state = {
|
||||
drivers: [
|
||||
|
||||
Reference in New Issue
Block a user