Files
ssw-mvp/dacli/tests/unit/di_list_encode.test.ts
T
admin 4d096dd97e chore(dacli): 提交 dacli CLI 工具源码并过滤敏感/噪声文件
- dacli/ 整目录被 .gitignore 忽略,本次 force-add 其业务源码(766 文件)
- 排除 node_modules/.env(含 PGPASSWORD 等敏感信息)/.DS_Store/__pycache__/*.pyc
- 新增 dacli/.gitignore 长期管理内部噪声,新增文件仍需 git add -f
- 根 .gitignore 补充 .cache/ 与诊断脚本忽略,并加 dacli 段说明
2026-08-06 19:02:39 +08:00

36 lines
1.1 KiB
TypeScript

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