clone

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

Avoid proof iris on same-scene reset

Dami committed f5d25eb
commit
f5d25ebf71a29c0745d2673d7c6e1c8cba574274
parent
cdfcc2666875afc142e05e02b6a226084e3fa41f
author
Dami <dami.etoile@gmail.com>
2 files changed, +22 -4
Msrc/app/turns.js6++++--
Mtests/turns.test.js20++++++++++++++++++--
M src/app/turns.js +4 -2
M tests/turns.test.js +18 -2
@@ -2,7 +2,7 @@ import test from 'node:test';
22 import assert from 'node:assert/strict';33 import { createTurnActions } from '../src/app/turns.js';44 5-function harness(result = { accepted: true }) {5+function harness(result = { accepted: true }, stage = null) {66 const events = [];77 let state = { won: false };88 const game = {
@@ -20,7 +20,7 @@ function harness(result = { accepted: true }) {
2020 };2121 const actions = createTurnActions({2222 getGame: () => game,23- getStage: () => null,23+ getStage: () => stage,2424 getJuice: () => juice,2525 getNow: () => 10,2626 setFeedback: message => events.push(`feedback:${message}`),
@@ -61,3 +61,19 @@ test('wait, undo, and restart use the same adapter boundary', () => {
6161 'sync', 'reset', 'consume', 'sync', 'clear', 'sound:restart', 'announce', 'ui', 'render', 'restart-complete', 'paint', 'animate:300',6262 ]);6363 });64+65+test('undo and restart preserve an active proof scene while returning from win', () => {66+ const proofEvents = [];67+ const proofStage = { scene: 'proof', show: scene => proofEvents.push(`show:${scene}`) };68+ const proof = harness({ accepted: true }, proofStage);69+ proof.actions.undo();70+ proof.actions.restart();71+ assert.equal(proofEvents.length, 0);72+73+ const winEvents = [];74+ const winStage = { scene: 'win', show: scene => winEvents.push(`show:${scene}`) };75+ const win = harness({ accepted: true }, winStage);76+ win.actions.undo();77+ win.actions.restart();78+ assert.deepEqual(winEvents, ['show:proof', 'show:proof']);79+});