Skip to content
Make the player visible with a procedural 3D humanoid132be7c
JavaScript39 lines1.6 KB
import { test } from 'node:test';import assert from 'node:assert/strict';import { LEVELS, getLevel, listLevels } from './levels.mjs'; test('at least four levels with unique ids and sequential indexes', () => {  assert.ok(LEVELS.length >= 4);  const ids = new Set(LEVELS.map((l) => l.id));  assert.equal(ids.size, LEVELS.length);  LEVELS.forEach((l, i) => assert.equal(l.index, i));}); test('every level has valid arena, theme, difficulty and gravity', () => {  for (const l of LEVELS) {    assert.equal(typeof l.name, 'string');    assert.ok(l.arena.width > 200 && l.arena.height > 200);    assert.ok(l.arena.padding >= 0 && l.arena.padding * 2 < l.arena.width);    assert.ok(l.arena.floorY > 0 && l.arena.floorY <= l.arena.height);    for (const key of ['sky', 'ground', 'accent']) assert.match(l.theme[key], /^#[0-9a-f]{6}$/i);    assert.ok(l.theme.fog >= 0 && l.theme.fog <= 1);    assert.ok(l.botDifficulty >= 0 && l.botDifficulty <= 1);    assert.ok(l.gravity > 0.5 && l.gravity < 2);    assert.ok(Number.isInteger(l.roundsToWin) && l.roundsToWin >= 1);    assert.ok(l.roundTime > 0);    assert.ok(Object.isFrozen(l) && Object.isFrozen(l.arena));  }}); test('difficulty ramps up across levels', () => {  for (let i = 1; i < LEVELS.length; i++) assert.ok(LEVELS[i].botDifficulty > LEVELS[i - 1].botDifficulty);}); test('getLevel by id and index, listLevels summary', () => {  assert.equal(getLevel('dojo'), LEVELS[0]);  assert.equal(getLevel(2), LEVELS[2]);  assert.equal(getLevel('nope'), null);  assert.equal(getLevel(99), null);  assert.deepEqual(listLevels()[0], { id: 'dojo', name: 'Moonlit Dojo', index: 0, botDifficulty: 0.25 });});