diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-16 14:23:32 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-16 14:23:32 +0200 |
| commit | 53ab332e6d2afe9818914e0026310e4cadcc4202 (patch) | |
| tree | 198d708fa05d4247bdcc0cf2900fdf551d61b7d6 /web/static_test | |
| parent | 2d18d177f48285eb123e7da8680fc00e7a6fe19c (diff) | |
refactor(web): migrate browser code to TypeScript
Diffstat (limited to 'web/static_test')
| -rw-r--r-- | web/static_test/official-climb-profile-logic.test.js | 37 | ||||
| -rw-r--r-- | web/static_test/ride-detail-logic.test.js | 45 |
2 files changed, 0 insertions, 82 deletions
diff --git a/web/static_test/official-climb-profile-logic.test.js b/web/static_test/official-climb-profile-logic.test.js deleted file mode 100644 index 9976c66..0000000 --- a/web/static_test/official-climb-profile-logic.test.js +++ /dev/null @@ -1,37 +0,0 @@ -import test from "node:test"; -import assert from "node:assert/strict"; -import { displayStepForLength, profileBandForSlope, officialProfileSections } from "../static/official-climb-profile-logic.js"; - -test("selects a display step that keeps long profiles readable", () => { - assert.equal(displayStepForLength(2_400), 100); - assert.equal(displayStepForLength(4_500), 200); - assert.equal(displayStepForLength(7_000), 500); - assert.equal(displayStepForLength(20_000), 1000); -}); - -test("assigns each slope to its color band", () => { - assert.equal(profileBandForSlope(-0.1), "downhill"); - assert.equal(profileBandForSlope(2.9), "0-3"); - assert.equal(profileBandForSlope(3), "3-6"); - assert.equal(profileBandForSlope(6), "6-9"); - assert.equal(profileBandForSlope(9), "9-12"); - assert.equal(profileBandForSlope(12), "12-plus"); -}); - -test("interpolates profile sections at the selected step", () => { - const points = [ - { distanceKm: 0, elevationM: 100 }, - { distanceKm: 0.12, elevationM: 106 }, - { distanceKm: 0.2, elevationM: 114 }, - { distanceKm: 0.25, elevationM: 120 }, - ]; - const sections = officialProfileSections(points, 0, 3, 100); - - assert.equal(sections.length, 3); - assert.equal(sections[0].startDistanceKm, 0); - assert.equal(sections[0].endDistanceKm, 0.1); - assert.equal(sections[0].startElevation, 100); - assert.equal(sections[0].endElevation, 105); - assert.equal(sections[2].endDistanceKm, 0.25); - assert.equal(sections[2].endElevation, 120); -}); diff --git a/web/static_test/ride-detail-logic.test.js b/web/static_test/ride-detail-logic.test.js deleted file mode 100644 index 2d9a695..0000000 --- a/web/static_test/ride-detail-logic.test.js +++ /dev/null @@ -1,45 +0,0 @@ -import test from "node:test"; -import assert from "node:assert/strict"; -import { - categoryForScore, - climbMetrics, - cotacolForClimb, - elevationAtDistance, - formatDistance, - formatElevation, - nearestPointIndex, -} from "../static/ride-detail-logic.js"; - -const points = [ - { distanceKm: 0, elevationM: 100 }, - { distanceKm: 0.12, elevationM: 106 }, - { distanceKm: 0.2, elevationM: 114 }, - { distanceKm: 0.25, elevationM: 120 }, -]; - -test("finds the nearest profile point by distance", () => { - assert.equal(nearestPointIndex(points, 0.01), 0); - assert.equal(nearestPointIndex(points, 0.15), 1); - assert.equal(nearestPointIndex(points, 0.24), 3); -}); - -test("interpolates elevation between route points", () => { - assert.equal(elevationAtDistance(points, 0, 100), 105); - assert.equal(elevationAtDistance(points, 2, 250), 120); -}); - -test("calculates climb metrics with the Cotacol score", () => { - const metrics = climbMetrics(points, { startIndex: 0, endIndex: 3 }); - - assert.equal(metrics.distanceKm, 0.25); - assert.equal(metrics.elevationGain, 20); - assert.equal(metrics.slope, 8); - assert.equal(metrics.cotacol, cotacolForClimb(points, 0, 3)); - assert.equal(metrics.category, categoryForScore(metrics.score)); -}); - -test("formats profile labels consistently", () => { - assert.equal(formatDistance(2.4), "2.4 km"); - assert.equal(formatDistance(12.4), "12 km"); - assert.equal(formatElevation(123.6), "124 m"); -}); |