25 lines
1.0 KiB
JavaScript
25 lines
1.0 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { ARENA_STAGES, VALIDATED_ARENA_STAGES, chooseArenaStage } from "./arena-stages.mjs";
|
|
|
|
test("the rated pool contains all eight validated arenas", () => {
|
|
assert.equal(ARENA_STAGES.length, 8);
|
|
assert.deepEqual(VALIDATED_ARENA_STAGES.map((stage) => stage.id), ARENA_STAGES.map((stage) => stage.id));
|
|
});
|
|
|
|
test("rated selection covers the pool uniformly and avoids the previous arena", () => {
|
|
const choices = VALIDATED_ARENA_STAGES.map((_, index, pool) => (
|
|
chooseArenaStage({ random: () => (index + 0.25) / pool.length })
|
|
));
|
|
assert.deepEqual(choices.map((stage) => stage.id), VALIDATED_ARENA_STAGES.map((stage) => stage.id));
|
|
|
|
const previousStageId = VALIDATED_ARENA_STAGES[0].id;
|
|
for (let index = 0; index < VALIDATED_ARENA_STAGES.length - 1; index += 1) {
|
|
const selected = chooseArenaStage({
|
|
previousStageId,
|
|
random: () => (index + 0.25) / (VALIDATED_ARENA_STAGES.length - 1),
|
|
});
|
|
assert.notEqual(selected.id, previousStageId);
|
|
}
|
|
});
|