Files
dacli/tests/unit/test_run_choice_value.test.ts
sushub f403a7e80e import: ssw/dacli@eea0ebc (2026-08-12) 起点版本
本仓 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,未来以本仓历史为主
2026-08-12 15:58:06 +08:00

38 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { pickChoiceValue } from '../../src/commands/test/run.ts'
describe('test run pickChoiceValue', () => {
it('returns first option value when no dictionary binding exists', async () => {
const value = await pickChoiceValue(
{} as any,
new Map(),
{ options: [{ value: 'finance' }] },
'f_topic_direction',
)
expect(value).toBe('finance')
})
it('falls back to "1" when both options and dictionary are missing', async () => {
const value = await pickChoiceValue(
{} as any,
new Map(),
{},
'f_topic_direction',
)
expect(value).toBe('1')
})
it('returns cached dictionary enCode on subsequent calls', async () => {
const cache = new Map<string, Array<Record<string, unknown>>>([
['dict-id', [{ enCode: 'pending' }, { enCode: 'approved' }]],
])
const value = await pickChoiceValue(
{} as any,
cache,
{ dataType: 'dictionary', dictionaryType: 'dict-id' },
'f_registration_status',
)
expect(value).toBe('pending')
})
})