Files
danyang-match/ui-tests/profileLabels.test.mjs
T

29 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2026-09-30 14:05:48 +08:00
// 纯函数回归测试:枚举码 → 中文映射(修复「枚举码直渲未映射中文」)
// 运行:node ui-tests/profileLabels.test.mjs
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const { serviceTypeLabel, labelOf } = require('../miniapp/constants/profileLabels.js')
let passed = 0
function check(name, actual, expected) {
assert.equal(actual, expected, `${name}: 期望 "${expected}",实际 "${actual}"`)
passed++
}
// ===== 红娘服务类型映射(本次修复点:matchmaker-workbench 卡片曾直渲枚举码)=====
check('recommend_partner', serviceTypeLabel('recommend_partner'), '推荐对象')
check('review_preference', serviceTypeLabel('review_preference'), '择偶指导')
check('contact_intention', serviceTypeLabel('contact_intention'), '牵线意向')
check('未知码回退原值', serviceTypeLabel('mystery_code'), 'mystery_code')
check('空串返回空', serviceTypeLabel(''), '')
check('null 返回空', serviceTypeLabel(null), '')
// ===== 通用 labelOf(既有字典,回归不退化)=====
check('labelOf education', labelOf('educationCode', 'bachelor'), '本科')
check('labelOf marital', labelOf('maritalStatus', 'never_married'), '未婚')
check('labelOf 未知码回退', labelOf('maritalStatus', 'xxx'), 'xxx')
console.log(`✅ profileLabels 回归测试全部通过(${passed} 项)`)