This commit is contained in:
larssand
2026-08-24 21:28:38 +02:00
parent 355a1ad3b0
commit 3aeb77a042
13 changed files with 642 additions and 8 deletions

View File

@@ -7,8 +7,10 @@ const {
buildPublicTrainingProfile,
findPublicTrainingShare,
hasPublicTrainingShare,
getPublicBestDurationResult,
normalizePublicTrainingSince,
normalizePublicTrainingWindow,
splitPublicTrainingStints,
} = require("../server/public_training_profile.js");
const DRIVER_ONE_TOKEN = "driver-one-token-12345678901234567890";
@@ -109,3 +111,17 @@ test("public timer query normalization bounds age and window values", () => {
assert.equal(normalizePublicTrainingWindow("-100"), 0);
assert.equal(normalizePublicTrainingWindow(String(25 * 60 * 60 * 1000)), 24 * 60 * 60 * 1000);
});
test("public profile duration result includes the lap started before five minutes", () => {
const laps = Array.from({ length: 16 }, (_, index) => ({
sessionId: "practice_1",
timestamp: (index + 1) * 18_000,
lapMs: 18_000,
}));
laps.push({ sessionId: "practice_1", timestamp: 314_123, lapMs: 26_123 });
const result = getPublicBestDurationResult(splitPublicTrainingStints(laps), 300_000);
assert.equal(result.lapCount, 17);
assert.equal(result.totalMs, 314_123);
assert.equal(result.averageLapMs, 18_478);
});