diff options
Diffstat (limited to 'web/frontend/ride-detail-logic.test.ts')
| -rw-r--r-- | web/frontend/ride-detail-logic.test.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/web/frontend/ride-detail-logic.test.ts b/web/frontend/ride-detail-logic.test.ts index 471eb49..5104516 100644 --- a/web/frontend/ride-detail-logic.test.ts +++ b/web/frontend/ride-detail-logic.test.ts @@ -3,6 +3,7 @@ import assert from "node:assert/strict"; import { categoryForCotacol, climbMetrics, + climbSample, cotacolForClimb, elevationAtDistance, formatClimbLabel, @@ -41,6 +42,21 @@ test("calculates climb metrics with Cotacol", () => { assert.equal(metrics.category, categoryForCotacol(metrics.cotacol)); }); +test("computes the recorded sample of a climb segment", () => { + assert.deepEqual(climbSample(points, { startIndex: 0, endIndex: 3 }), { distanceM: 250, elevationGainM: 20 }); + assert.equal(climbSample(points, { startIndex: 3, endIndex: 0 }), null); +}); + +test("climb sample counts only upward steps", () => { + const rolling = [ + { distanceKm: 0, elevationM: 100 }, + { distanceKm: 0.1, elevationM: 130 }, + { distanceKm: 0.2, elevationM: 110 }, + { distanceKm: 0.3, elevationM: 140 }, + ]; + assert.deepEqual(climbSample(rolling, { startIndex: 0, endIndex: 3 }), { distanceM: 300, elevationGainM: 60 }); +}); + test("formats profile climb labels with category", () => { assert.equal(formatClimbLabel({ name: "", category: "Cat 4", cotacol: 45.9, kind: "detected" }), "Cat 4 45.9"); assert.equal(formatClimbLabel({ name: "Col de Test", category: "Cat 4", cotacol: 45.9, kind: "detected" }), "Col de Test"); |
