本仓 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,未来以本仓历史为主
81 lines
1.9 KiB
TypeScript
81 lines
1.9 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { projectFormBindings } from '../../src/commands/form/info.ts'
|
|
|
|
describe('form info --bindings projection', () => {
|
|
it('flattens select fields with dictionary metadata', () => {
|
|
const bindings = projectFormBindings({
|
|
formData: {
|
|
fields: [
|
|
{
|
|
__vModel__: 'f_topic_direction',
|
|
__config__: {
|
|
jnpfKey: 'select',
|
|
label: '赛题方向',
|
|
dataType: 'dictionary',
|
|
dictionaryType: 'dict-1',
|
|
},
|
|
},
|
|
{
|
|
__vModel__: 'f_team_name',
|
|
__config__: {
|
|
jnpfKey: 'input',
|
|
label: '团队名称',
|
|
required: true,
|
|
},
|
|
},
|
|
],
|
|
},
|
|
})
|
|
expect(bindings).toEqual([
|
|
{
|
|
field: 'f_topic_direction',
|
|
jnpfKey: 'select',
|
|
label: '赛题方向',
|
|
dataType: 'dictionary',
|
|
dictionaryType: 'dict-1',
|
|
required: false,
|
|
modelId: null,
|
|
},
|
|
{
|
|
field: 'f_team_name',
|
|
jnpfKey: 'input',
|
|
label: '团队名称',
|
|
dataType: null,
|
|
dictionaryType: null,
|
|
required: true,
|
|
modelId: null,
|
|
},
|
|
])
|
|
})
|
|
|
|
it('skips entries without __vModel__', () => {
|
|
const bindings = projectFormBindings({
|
|
formData: {
|
|
fields: [
|
|
{ __config__: { jnpfKey: 'input' } },
|
|
],
|
|
},
|
|
})
|
|
expect(bindings).toEqual([])
|
|
})
|
|
|
|
it('keeps entries with __vModel__ but missing __config__', () => {
|
|
const bindings = projectFormBindings({
|
|
formData: {
|
|
fields: [{ __vModel__: 'f_a' }],
|
|
},
|
|
})
|
|
expect(bindings).toEqual([
|
|
{
|
|
field: 'f_a',
|
|
jnpfKey: undefined,
|
|
label: undefined,
|
|
dataType: null,
|
|
dictionaryType: null,
|
|
required: false,
|
|
modelId: null,
|
|
},
|
|
])
|
|
})
|
|
})
|