47 lines
2.0 KiB
TypeScript
47 lines
2.0 KiB
TypeScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { readSource } from './helpers.ts'
|
|
import { historyEmptyText, historyErrorText } from '../src/pages/records/history-feedback.ts'
|
|
|
|
test('test_task_125_history_feedback_normal_primary_path', () => {
|
|
// 正常主路径:无数据空态统一「暂无记录」(对齐 admin.js:2866)。
|
|
assert.equal(historyEmptyText({ hasFilter: true, total: 0 }), '暂无记录')
|
|
})
|
|
|
|
test('test_task_125_history_feedback_normal_variant_input', () => {
|
|
// 正常变体:无筛选空态同文案。
|
|
assert.equal(historyEmptyText({ hasFilter: false, total: 0 }), '暂无记录')
|
|
})
|
|
|
|
test('test_task_125_history_feedback_repeated_is_idempotent', () => {
|
|
// 正常重复:文案稳定。
|
|
assert.equal(historyEmptyText({ hasFilter: false, total: 0 }), historyEmptyText({ hasFilter: false, total: 0 }))
|
|
})
|
|
|
|
test('test_task_125_history_feedback_boundary_empty_input', () => {
|
|
// 边界空值:有数据不显示空态。
|
|
assert.equal(historyEmptyText({ hasFilter: false, total: 2 }), '')
|
|
})
|
|
|
|
test('test_task_125_history_feedback_boundary_single_item', () => {
|
|
// 边界单元素:错误对象取 message。
|
|
assert.equal(historyErrorText({ message: '无权访问生成记录模块' }), '无权访问生成记录模块')
|
|
})
|
|
|
|
test('test_task_125_history_feedback_boundary_limit_or_missing_field', () => {
|
|
// 边界上限/缺字段:空错误回兜底。
|
|
const fallback = historyErrorText(undefined)
|
|
assert.ok(fallback.length > 0)
|
|
})
|
|
|
|
test('test_task_125_history_feedback_invalid_input_rejected', () => {
|
|
// 异常输入:Error 归一。
|
|
assert.match(historyErrorText(new Error('网络异常')), /网络异常/)
|
|
})
|
|
|
|
test('test_task_125_history_feedback_dependency_failure_returns_actionable_message', () => {
|
|
// 依赖失败/可操作:反馈纯逻辑、无框架/http。
|
|
const mod = readSource('src/pages/records/history-feedback.ts')
|
|
assert.equal(/axios|http\.|vue/.test(mod), false, '反馈模块保持纯逻辑')
|
|
})
|