clone

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

main
miau-is-true / tests / warning-lines.test.js
warning-lines.test.js 2.5K
1import test from 'node:test';2import assert from 'node:assert/strict';3import { warningLines } from '../src/scenes/warning-lines.js';45test('warning lines group ordinary loose words but preserve cross-proof ambiguity context', () => {6 const pack = { levels: [{ id: 'plain', title: 'Unknown words' }] };7 const lines = warningLines(pack, [8 { word: 'SHUT', levelId: 'plain', message: 'SHUT is not a known noun or declared property in this proof.' },9 { word: 'OPEN', levelId: 'plain', message: 'OPEN is not a known noun or declared property in this proof.' },10 { word: 'TICK', levelId: 'plain', message: 'TICK is used as a thing in another proof but is not a known noun here.' },11 ]);12 assert.deepEqual(lines, [13 'Proof 1, Unknown words: TICK is a thing in another proof but not here.',14 "Proof 1, Unknown words: SHUT and OPEN aren't rule words or things in this proof, so they can't do anything.",15 ]);16});1718test('formed cross-proof property ambiguity keeps its consequence', () => {19 const lines = warningLines({ levels: [{ id: 'door', title: 'Key and door' }] }, [{20 word: 'SHUT', levelId: 'door', sentence: 'DOOR IS SHUT',21 message: 'SHUT is declared as a property in another proof and used as a thing here; DOOR IS SHUT will transform DOOR into SHUT.',22 }]);23 assert.deepEqual(lines, [24 'Proof 1, Key and door: SHUT is a rule word in one proof and a thing in another, so DOOR IS SHUT would turn every door into a SHUT.',25 ]);26});2728test('pack and proof authoring notes keep their messages and scope', () => {29 const pack = { levels: [{ id: 'long', title: 'A lengthy proof title' }] };30 assert.deepEqual(warningLines(pack, [31 { word: 'RULES', sentence: null, message: 'This pack was made for older rules; some proofs may play differently.' },32 { word: 'TITLE', levelId: 'long', sentence: null, message: 'Proof titles should use 24 characters or fewer for easier reading.' },33 { word: 'WORLD', sentence: null, message: "Tagline can't use ·; use a comma or a dash." },34 { word: 'RULES', levelId: 'long', sentence: null, message: 'Rule text is too complex to analyze safely; reduce stacked rule alternatives.' },35 ]), [36 'This pack was made for older rules; some proofs may play differently.',37 'Proof 1, A lengthy proof title: Proof titles should use 24 characters or fewer for easier reading.',38 "Tagline can't use ·; use a comma or a dash.",39 'Proof 1, A lengthy proof title: Rule text is too complex to analyze safely; reduce stacked rule alternatives.',40 ]);41});