clone

a browser grid puzzle game where you push words around to rewrite the rules of each level

Define approved bundled world order

Dami committed bee2e17
commit
bee2e1734534b05cdfd4478bf0ded347e05a1435
parent
e319be1182db66bcc88d745204109968f5f3965c
author
Dami <dami.etoile@gmail.com>
3 files changed, +54 -0
Asrc/bundled-world-order.js6++++++
Asrc/bundled-worlds.js17++++++++++++++++
Atests/bundled-worlds.test.js31++++++++++++++++++++++++++++++
A src/bundled-world-order.js +6 -0
A src/bundled-worlds.js +17 -0
A tests/bundled-worlds.test.js +31 -0
@@ -0,0 +1,31 @@
1+import test from 'node:test';2+import assert from 'node:assert/strict';3+import { readFile } from 'node:fs/promises';4+import { fileURLToPath } from 'node:url';5+import { loadMod, CURRENT_RULES_VERSION } from '../src/mods.js';6+import { BUNDLED_WORLD_FILES } from '../src/bundled-world-order.js';7+8+const root = fileURLToPath(new URL('../', import.meta.url));9+const approved = ['crossword.cjs', 'crate-works.cjs', 'tidewater.cjs'];10+11+test('approved bundled world order is stable and each source loads at current rules', async () => {12+ assert.deepEqual(BUNDLED_WORLD_FILES, approved);13+ const loaded = [];14+ for (const filename of BUNDLED_WORLD_FILES) {15+ const source = await readFile(`${root}/mods/worlds/${filename}`, 'utf8');16+ const mod = loadMod(source, { filename });17+ loaded.push({ filename, id: mod.manifest.id, rules: mod.manifest.rules });18+ }19+ assert.deepEqual(loaded, [20+ { filename: 'crossword.cjs', id: 'crossword', rules: CURRENT_RULES_VERSION },21+ { filename: 'crate-works.cjs', id: 'crate-works', rules: CURRENT_RULES_VERSION },22+ { filename: 'tidewater.cjs', id: 'tidewater', rules: CURRENT_RULES_VERSION },23+ ]);24+});25+26+test('garden basics and word lab remain separate importable packs', async () => {27+ for (const [filename, id] of [['garden-basics.cjs', 'garden-basics'], ['word-lab.cjs', 'word-lab']]) {28+ const source = await readFile(`${root}/mods/${filename}`, 'utf8');29+ assert.equal(loadMod(source, { filename }).manifest.id, id);30+ }31+});