test(08-10): cover data-system/data-state gap codes and add loader tests

- eventDispatch: assert codes 171 (missing event id) and 172 (non-boolean reduce result)

- path/system: assert code 182 when binding a foreign CoreState layer

- data-state event: assert code 1001 for an unknown setBlock tile

- loader: new loader.test.ts covering PrefixedJSONCProcessor 66/67, DefaultDataLoaderHook 69/success, and MotaDataLoader public surface (66/67/68/69; 68 recorded unreachable)
This commit is contained in:
AncTe committed 2026-10-08 14:45:10 +08:00
1 parent b932f8cecd
commit 47c6e2c8db
4 files changed
+235

No files matched your search

@@ -16,6 +16,7 @@ import {
type IGameEventInvocation
} from '../types';
import { AnonTokyoInterpreter } from '@motajs/anon-tokyo';
import { logger } from '@motajs/common';
import { IStateBase } from '@user/data-base';
vi.hoisted(() => {
@@ -524,6 +525,37 @@ describe('event execute modes and reductions', () => {
).resolves.toEqual([true]);
expect(calls).toEqual(['valid']);
});
// 验证事件 id 不在事件存储时告警码 171 并跳过该事件
it('warns code 171 for an event id missing from the store', async () => {
const fixture = createFixture();
const warn = vi.spyOn(logger, 'warn');
await fixture.executor.execute(
[invocation('missing', modules.EventTrigger.OnEnter)],
{ custom: {} }
);
expect(warn).toHaveBeenCalledWith(171, 'missing');
});
// 验证折叠时事件返回非布尔值告警码 172 并按短路语义继续
it('warns code 172 for a non-boolean event result during reduction', async () => {
const fixture = createFixture();
const warn = vi.spyOn(logger, 'warn');
fixture.events.set('non-bool', {
trigger: modules.EventTrigger.OnEnter,
execute: async () => 5
});
fixture.executor.setReduce(modules.EventReduceMode.OrReduce);
await fixture.executor.execute(
[invocation('non-bool', modules.EventTrigger.OnEnter)],
{ custom: {} }
);
expect(warn).toHaveBeenCalledWith(172, '5');
});
});
describe('enter leave hit trigger hooks', () => {
@@ -610,4 +610,16 @@ describe('pathfinding system', () => {
await result!.controller.onEnd;
expect(result!.controller.done).toBe(true);
});
// 验证向求解器绑定属于其他 CoreState 的图层时告警码 182 并不建立绑定
it('warns code 182 when binding a layer from another CoreState', () => {
const a = createSystem([1, 1, 1], 3);
const b = createSystem([1, 1, 1], 3);
const result = modules.logger.catch(() =>
a.system.finder.useMapLayer(b.layer)
);
expect(result.info.map(info => info.code)).toContain(182);
});
});