import { describe, expect, it } from 'vitest' import { enrichDataInterfaceListWithEnCode } from '../../src/commands/di/list.ts' describe('di list enCode enrichment', () => { it('fills missing enCode from an id→enCode map', () => { const selector = [ { id: 'cat-a', category: '0', children: [ { id: 'di-1', category: '1', fullName: '状态查询' }, { id: 'di-2', category: '1', fullName: '审核查询' }, ], }, ] const result = enrichDataInterfaceListWithEnCode(selector, { 'di-1': 'statusQuery', 'di-2': 'auditQuery', }) expect(result).toEqual([ { id: 'di-1', category: '1', fullName: '状态查询', enCode: 'statusQuery' }, { id: 'di-2', category: '1', fullName: '审核查询', enCode: 'auditQuery' }, ]) }) it('leaves enCode alone when the selector already carries it', () => { const result = enrichDataInterfaceListWithEnCode( [{ id: 'di-1', category: '1', enCode: 'explicit', fullName: '已带编码' }], { 'di-1': 'overridden' }, ) expect(result[0].enCode).toBe('explicit') }) })