Format WOD étendu : EMOM « tout à chaque intervalle », repos entre les tours ; Chelsea et Barbara (4e)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
db0b6f954c
commit
7678e580b7
@@ -1,6 +1,7 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { compareScores, wodKey, clockText, currentMovement, formatLabel, formatSeconds, parseClock, scoreLabel, validateFormat, wodClock, wodResultProblem } from "../../app/domain/wod.js";
|
||||
import { compareScores, wodKey, clockText, currentMovement, formatHint, formatLabel, formatSeconds, movesInTurn, parseClock, scoreFields, scoreLabel, validateFormat, wodClock, wodResultProblem } from "../../app/domain/wod.js";
|
||||
import { phaseText } from "../../app/ui/wod-panel.js";
|
||||
import { validateProgram } from "../../app/domain/program.js";
|
||||
import { estimatedMinutes } from "../../app/domain/progression.js";
|
||||
import { buildOnboardingBrief } from "../../app/domain/ai-brief.js";
|
||||
@@ -79,3 +80,35 @@ test("comparer deux scores : RX d'abord, puis selon le format", () => {
|
||||
assert.equal(compareScores(r({ format: am, rounds: 14, reps: 3 }), r({ format: am, rounds: 14, reps: 3 })), 0);
|
||||
assert.equal(wodKey(" Frân ", { type: "fortime" }), "fran|fortime");
|
||||
});
|
||||
|
||||
test("EMOM « tout à chaque intervalle » (Chelsea) : tous les mouvements, score en intervalles réussis", () => {
|
||||
const f = /** @type {const} */ ({ type: "emom", minutes: 30, all: true });
|
||||
assert.deepEqual(validateFormat(f, "W"), []);
|
||||
assert.match(validateFormat({ type: "emom", minutes: 30, all: "oui" }, "W")[0], /'format.all' doit valoir true ou false/);
|
||||
assert.equal(formatLabel(f), "EMOM 30 min · tout à chaque intervalle");
|
||||
assert.match(formatHint(f), /fais tous les mouvements/);
|
||||
assert.equal(movesInTurn(f), false);
|
||||
assert.equal(movesInTurn({ type: "emom", minutes: 10 }), true);
|
||||
assert.deepEqual(scoreFields(f), { seconds: false, rounds: true, reps: false });
|
||||
const r = (/** @type {number} */ rounds) => ({ format: f, rx: true, seconds: null, rounds, reps: null, kg: null, capped: false });
|
||||
assert.equal(scoreLabel(r(28)), "28 intervalles · RX");
|
||||
assert.ok(compareScores(r(30), r(28)) < 0);
|
||||
});
|
||||
|
||||
test("tours avec repos entre deux (Barbara) : effort, repos, tour suivant ; le repos ne compte pas", () => {
|
||||
const f = /** @type {const} */ ({ type: "rounds", rounds: 3, rest: 180 });
|
||||
assert.deepEqual(validateFormat(f, "W"), []);
|
||||
assert.match(validateFormat({ type: "rounds", rounds: 3, rest: 2000 }, "W")[0], /'format.rest'/);
|
||||
assert.equal(formatLabel(f), "3 tours · repos 3:00");
|
||||
assert.equal(formatLabel({ type: "rounds", rounds: 3 }), "3 tours", "sans repos, comme avant");
|
||||
assert.deepEqual(wodClock(f, 100), { phase: "work", round: 1, rounds: 3, remaining: null, elapsed: 100 });
|
||||
// tour 1 fini à 240 s : repos jusqu'à 420 s
|
||||
assert.deepEqual(wodClock(f, 300, [240]), { phase: "rest", round: 2, rounds: 3, remaining: 120, elapsed: 240 });
|
||||
assert.deepEqual(wodClock(f, 500, [240]), { phase: "work", round: 2, rounds: 3, remaining: null, elapsed: 240 + 80 });
|
||||
// tour 2 fini à 700 s (280 s d'effort), tour 3 fini à 1150 s (270 s d'effort)
|
||||
assert.deepEqual(wodClock(f, 1150, [240, 700, 1150]), { phase: "done", round: 3, rounds: 3, remaining: 0, elapsed: 240 + 280 + 270 });
|
||||
assert.equal(phaseText(f, wodClock(f, 300, [240])), "Repos · puis tour 2/3");
|
||||
assert.equal(phaseText(f, wodClock(f, 500, [240])), "Tour 2/3");
|
||||
// Le Tabata garde son repos par défaut de 10 s.
|
||||
assert.equal(formatLabel({ type: "tabata" }), "Tabata 8 × 20 s / 10 s");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user