- commit
- 8ecc483177ce8e8347785469d91e5e47e29b56b9
- parent
- be2b6dbb88baff29c49162b48337378e65e02312
- author
- Dami <dami.etoile@gmail.com>
| M | src/ | 3 | --- |
| M | tests/ | 17 | +++++++++++++++++ |
@@ -445,6 +445,23 @@ test('restore replays a same-level snapshot with automata phases and no undo ent
445445 assert.throws(() => game.restore({ ...initial, objects: [{ ...initial.objects[0], id: 'foreign' }] }), /not authored/);446446 });447447 448+test('restore is idempotent for settled one-link transformation snapshots', () => {449+ const game = createGame(level([450+ word('BABA', 0, 0), word('IS', 1, 0), word('ROCK', 2, 0),451+ word('ROCK', 0, 1), word('IS', 1, 1), word('FLAG', 2, 1),452+ word('MIAU', 0, 2), word('IS', 1, 2), word('YOU', 2, 2),453+ object('BABA', 4, 3, 'baba'), object('MIAU', 0, 3, 'player'),454+ ]));455+ assert.equal(game.getState().objects.find(object => object.id === 'baba').noun, 'ROCK');456+ const settled = game.getState();457+ game.restore(settled);458+ assert.equal(game.getState().objects.find(object => object.id === 'baba').noun, 'ROCK');459+ game.restore(game.getState());460+ assert.equal(game.getState().objects.find(object => object.id === 'baba').noun, 'ROCK');461+ const next = game.step(1, 0);462+ assert.equal(next.transformed.find(entry => entry.id === 'baba').to, 'FLAG');463+});464+448465 test('WIN, SINK and DEFEAT resolve on contact', () => {449466 const game = createGame(level([450467 word('BABA', 0, 0), word('IS', 1, 0), word('YOU', 2, 0),