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); });