// entity 正規化 — exact match(語意合併屬基本盤 embed 模組),走 mock client。 import { describe, it, expect } from 'vitest'; import { createEntity, findEntityByName, listEntities } from '../src/actions/entity-crud'; import { normalizeEntity } from '../src/actions/entity-normalize'; import { mockClient } from './mock-client'; describe('entity-crud', () => { it('建立後可 exact 查回(大小寫不敏感)', async () => { const c = mockClient(); await createEntity(c, 'InkStone'); const found = await findEntityByName(c, 'inkstone'); expect(found?.canonical).toBe('InkStone'); }); it('listEntities 列出', async () => { const c = mockClient(); await createEntity(c, 'A'); await createEntity(c, 'B'); const all = await listEntities(c); expect(all.map((e) => e.canonical).sort()).toEqual(['A', 'B']); }); }); describe('normalizeEntity', () => { it('已存在回 canonical,不存在建新回原值', async () => { const c = mockClient(); await createEntity(c, 'InkStone'); expect(await normalizeEntity(c, 'INKSTONE')).toBe('InkStone'); expect(await normalizeEntity(c, '新公司')).toBe('新公司'); }); });