task-131(记录与版本中心): 定义数字人版本 DTO
新增 digitalhuman-dto.ts:数字人版本行/状态类型,与软件版本分离。 TDD: task-131.test.ts 8 用例 RED→GREEN。
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readSource } from './helpers.ts'
|
||||
import { emptyDigitalHumanVersionList, normalizeDigitalHumanStatus } from '../src/pages/records/digitalhuman-dto.ts'
|
||||
|
||||
test('test_task_131_dh_version_dto_normal_primary_path', () => {
|
||||
// 正常主路径:数字人版本状态归一与空列表缺省。
|
||||
assert.equal(normalizeDigitalHumanStatus('RELEASED'), 'RELEASED')
|
||||
assert.equal(normalizeDigitalHumanStatus('draft'), 'DRAFT')
|
||||
assert.deepEqual(emptyDigitalHumanVersionList(), { items: [] })
|
||||
})
|
||||
|
||||
test('test_task_131_dh_version_dto_normal_variant_input', () => {
|
||||
// 正常变体:未知状态回 DRAFT。
|
||||
assert.equal(normalizeDigitalHumanStatus('weird'), 'DRAFT')
|
||||
assert.equal(normalizeDigitalHumanStatus(''), 'DRAFT')
|
||||
})
|
||||
|
||||
test('test_task_131_dh_version_dto_repeated_is_idempotent', () => {
|
||||
// 正常重复:归一稳定。
|
||||
assert.equal(normalizeDigitalHumanStatus('RELEASED'), normalizeDigitalHumanStatus('released'))
|
||||
})
|
||||
|
||||
test('test_task_131_dh_version_dto_boundary_empty_input', () => {
|
||||
// 边界空值:非字符串按 DRAFT。
|
||||
assert.equal(normalizeDigitalHumanStatus(null as unknown as string), 'DRAFT')
|
||||
})
|
||||
|
||||
test('test_task_131_dh_version_dto_boundary_single_item', () => {
|
||||
// 边界单元素:类型导出存在。
|
||||
assert.ok(typeof emptyDigitalHumanVersionList === 'function')
|
||||
})
|
||||
|
||||
test('test_task_131_dh_version_dto_boundary_limit_or_missing_field', () => {
|
||||
// 边界上限/缺字段:版本类型定义里 status 为受控枚举。
|
||||
const mod = readSource('src/pages/records/digitalhuman-dto.ts')
|
||||
assert.match(mod, /'DRAFT' \| 'RELEASED'/)
|
||||
})
|
||||
|
||||
test('test_task_131_dh_version_dto_invalid_input_rejected', () => {
|
||||
// 异常输入:非受控状态被拒绝为 DRAFT。
|
||||
assert.equal(normalizeDigitalHumanStatus(1 as unknown as string), 'DRAFT')
|
||||
})
|
||||
|
||||
test('test_task_131_dh_version_dto_dependency_failure_returns_actionable_message', () => {
|
||||
// 依赖失败/可操作:DTO 纯逻辑、无框架/http;与软件版本 DTO 分离。
|
||||
const mod = readSource('src/pages/records/digitalhuman-dto.ts')
|
||||
assert.equal(/axios|http\.|vue/.test(mod), false, '数字人 DTO 保持纯逻辑')
|
||||
assert.match(mod, /DigitalHumanVersion/)
|
||||
})
|
||||
Reference in New Issue
Block a user