style(01-12): normalize event store test line endings

- Apply the repository Prettier CRLF format to the focused event-store regression without changing assertions.
This commit is contained in:
unanmed 2026-09-09 11:34:52 +08:00
parent 15d9f25b44
commit f423aad84a

View File

@ -1,76 +1,76 @@
import { AnonTokyoInterpreter } from 'anon-tokyo'; import { AnonTokyoInterpreter } from 'anon-tokyo';
import { import {
afterAll, afterAll,
afterEach, afterEach,
beforeAll, beforeAll,
describe, describe,
expect, expect,
it, it,
vi vi
} from 'vitest'; } from 'vitest';
interface TestModules { interface TestModules {
GameEvent: typeof import('@user/data-common').GameEvent; GameEvent: typeof import('@user/data-common').GameEvent;
GameEventStore: typeof import('@user/data-common').GameEventStore; GameEventStore: typeof import('@user/data-common').GameEventStore;
logger: typeof import('@motajs/common').logger; logger: typeof import('@motajs/common').logger;
} }
let modules: TestModules; let modules: TestModules;
beforeAll(async () => { beforeAll(async () => {
vi.stubGlobal('main', { replayChecking: true }); vi.stubGlobal('main', { replayChecking: true });
vi.stubGlobal('location', { origin: 'http://localhost' }); vi.stubGlobal('location', { origin: 'http://localhost' });
const commonModule = await import('@user/data-common'); const commonModule = await import('@user/data-common');
const loggerModule = await import('@motajs/common'); const loggerModule = await import('@motajs/common');
modules = { modules = {
GameEvent: commonModule.GameEvent, GameEvent: commonModule.GameEvent,
GameEventStore: commonModule.GameEventStore, GameEventStore: commonModule.GameEventStore,
logger: loggerModule.logger logger: loggerModule.logger
}; };
}); });
afterEach(() => { afterEach(() => {
vi.restoreAllMocks(); vi.restoreAllMocks();
}); });
afterAll(() => { afterAll(() => {
vi.unstubAllGlobals(); vi.unstubAllGlobals();
}); });
function createEvent() { function createEvent() {
const interpreter = new AnonTokyoInterpreter({ const interpreter = new AnonTokyoInterpreter({
builtInFunctions: [], builtInFunctions: [],
globalFunctions: [] globalFunctions: []
}); });
return new modules.GameEvent(interpreter, []); return new modules.GameEvent(interpreter, []);
} }
describe('GameEventStore public barrel behavior', () => { describe('GameEventStore public barrel behavior', () => {
it('retrieves an event by the id used when adding it', () => { it('retrieves an event by the id used when adding it', () => {
const store = new modules.GameEventStore(); const store = new modules.GameEventStore();
const event = createEvent(); const event = createEvent();
store.addEvent('event-id', event); store.addEvent('event-id', event);
expect(store.getEvent('event-id')).toBe(event); expect(store.getEvent('event-id')).toBe(event);
}); });
it('returns null for an unknown id', () => { it('returns null for an unknown id', () => {
const store = new modules.GameEventStore(); const store = new modules.GameEventStore();
expect(store.getEvent('missing-id')).toBeNull(); expect(store.getEvent('missing-id')).toBeNull();
}); });
it('warns and overwrites when an id is added twice', () => { it('warns and overwrites when an id is added twice', () => {
const store = new modules.GameEventStore(); const store = new modules.GameEventStore();
const firstEvent = createEvent(); const firstEvent = createEvent();
const secondEvent = createEvent(); const secondEvent = createEvent();
const warning = vi.spyOn(modules.logger, 'warn'); const warning = vi.spyOn(modules.logger, 'warn');
store.addEvent('duplicate-id', firstEvent); store.addEvent('duplicate-id', firstEvent);
store.addEvent('duplicate-id', secondEvent); store.addEvent('duplicate-id', secondEvent);
expect(warning).toHaveBeenCalledWith(170, 'duplicate-id'); expect(warning).toHaveBeenCalledWith(170, 'duplicate-id');
expect(store.getEvent('duplicate-id')).toBe(secondEvent); expect(store.getEvent('duplicate-id')).toBe(secondEvent);
}); });
}); });