本仓 2026-08-12 从 ssw main (192.168.1.18:13300/ssw/ssw-mvp) 的 dacli/ subpath 抽取,作为独立仓托管到 gitea:3000/ssw/dacli.git。 - 工作树为 ssw main dacli subpath 最新版 (110 commit, 08-12) - 历史未带 ssw main 整体历史(避免大仓污染) - 此为新仓基线 commit,未来以本仓历史为主
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { flattenDataInterfaceSelector } from '../../src/commands/di/list.ts'
|
|
|
|
describe('di list selector fallback', () => {
|
|
it('flattens interface leaves and keeps category folders out of the result', () => {
|
|
const result = flattenDataInterfaceSelector([
|
|
{
|
|
id: 'category-a',
|
|
category: '0',
|
|
fullName: '报名接口',
|
|
children: [
|
|
{ id: 'di-1', category: '1', enCode: 'statusQuery', fullName: '状态查询' },
|
|
{ id: 'di-2', category: 1, enCode: 'auditQuery', fullName: '审核查询' },
|
|
],
|
|
},
|
|
{ id: 'category-b', category: '0', children: [] },
|
|
])
|
|
|
|
expect(result).toEqual([
|
|
{ id: 'di-1', category: '1', enCode: 'statusQuery', fullName: '状态查询' },
|
|
{ id: 'di-2', category: 1, enCode: 'auditQuery', fullName: '审核查询' },
|
|
])
|
|
})
|
|
|
|
it('filters by keyword and applies pagination after flattening', () => {
|
|
const selector = [
|
|
{
|
|
category: '0',
|
|
children: [
|
|
{ id: 'di-1', category: '1', enCode: 'statusQuery', fullName: '状态查询' },
|
|
{ id: 'di-2', category: '1', enCode: 'auditQuery', fullName: '审核查询' },
|
|
{ id: 'di-3', category: '1', enCode: 'statusDetail', fullName: '状态详情' },
|
|
],
|
|
},
|
|
]
|
|
|
|
const all = flattenDataInterfaceSelector(selector)
|
|
const filtered = all.filter((item) => `${item.enCode} ${item.fullName}`.includes('status'))
|
|
expect(filtered.slice(1, 2).map((item) => item.id)).toEqual(['di-3'])
|
|
})
|
|
})
|