Files
DndGamePlayer/app/main/sceneTraps/sceneTrapsStore.test.ts
T
Ivan Fontosh fed5674468 feat(traps): activation VFX/SFX, explosion effect, and help section
Wire mimic/pit/arrow/laser media on activate, poison/explosion via effects, and document the scene editor and traps in Instructions.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-25 12:35:22 +08:00

39 lines
1.6 KiB
TypeScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { SceneTrapsStore } from './sceneTrapsStore';
void test('SceneTrapsStore: сохраняет runtime при переключении сцен внутри сессии', () => {
const store = new SceneTrapsStore();
store.switchScene('scene_a', ['t1']);
store.dispatch({ kind: 'activate', trapId: 't1' });
assert.equal(store.getState().byId.t1?.status, 'active');
assert.equal(store.getState().byId.t1?.revealed, true);
store.switchScene('scene_b', ['t2']);
assert.equal(store.getState().byId.t2?.status, 'inactive');
store.switchScene('scene_a', ['t1']);
assert.equal(store.getState().byId.t1?.status, 'active');
assert.equal(store.getState().byId.t1?.revealed, true);
});
void test('SceneTrapsStore: resetSession сбрасывает кэш к дефолту (кнопка «Запустить»)', () => {
const store = new SceneTrapsStore();
store.switchScene('scene_a', ['t1', 't2']);
store.dispatch({ kind: 'reveal', trapId: 't1' });
store.dispatch({ kind: 'activate', trapId: 't2' });
assert.equal(store.getState().byId.t1?.revealed, true);
assert.equal(store.getState().byId.t2?.status, 'active');
assert.ok(store.getState().lastActivation);
store.resetSession();
store.switchScene('scene_a', ['t1', 't2']);
assert.equal(store.getState().byId.t1?.status, 'inactive');
assert.equal(store.getState().byId.t1?.revealed, false);
assert.equal(store.getState().byId.t2?.status, 'inactive');
assert.equal(store.getState().byId.t2?.revealed, false);
assert.equal(store.getState().lastActivation, null);
});