/** * The scenario pool a Mode's picker offers. * * Duel's only behavioral difference from Scenario is this filter, so it is * the one piece of the challenge screen's Mode handling worth exercising * against real data rather than reading the source: a catalog shaped like * the actual four scenarios (three head-to-head, one four-player) has to * come out narrowed for Duel and untouched for Scenario. * * Run with `npm test`. */ import { test } from "node:test"; import assert from "node:assert/strict"; import { scenarioPool } from "../src/screens/scenario-pool.ts"; /** Shaped like services/api/src/matches/scenarios.rs's SCENARIOS, slot * counts only — this test does not care what is in them. */ const catalog = [ { path: "TrainingScenarios/1-FirstRun.mms", name: "First Run", description: "", slots: [ { name: "TraineeA", units: [] }, { name: "TraineeB", units: [] }, ], }, { path: "TrainingScenarios/2-FinalExam.mms", name: "Final Exam", description: "", slots: [ { name: "TraineeA", units: [] }, { name: "TraineeB", units: [] }, ], }, { path: "TrainingScenarios/4-DivideAndConquer.mms", name: "Divide and Conquer", description: "", slots: [ { name: "Defender", units: [] }, { name: "Attacker", units: [] }, ], }, { path: "MonteDiablo/MonteDiablo-Four_Players.mms", name: "The Battle of Monte Diablo", description: "", slots: [ { name: "Steiner2nd", units: [] }, { name: "Steiner7th", units: [] }, { name: "Davion", units: [] }, { name: "ComStar", units: [] }, ], }, ]; test("Duel keeps only the two-slot scenarios", () => { const pool = scenarioPool(catalog, "duel"); assert.equal(pool.length, 3); assert.ok(pool.every((entry) => entry.slots.length === 2)); assert.ok( !pool.some((entry) => entry.path.includes("MonteDiablo")), "Duel's pool must exclude the four-slot scenario", ); }); test("Scenario keeps the whole catalog, four-slot entry included", () => { const pool = scenarioPool(catalog, "scenario"); assert.equal(pool.length, catalog.length); assert.ok(pool.some((entry) => entry.path.includes("MonteDiablo"))); }); test("an all-two-slot catalog is unchanged either way", () => { const twoSlotOnly = catalog.filter((entry) => entry.slots.length === 2); assert.deepEqual(scenarioPool(twoSlotOnly, "duel"), twoSlotOnly); assert.deepEqual(scenarioPool(twoSlotOnly, "scenario"), twoSlotOnly); });