Files
FileCodeBoxFronted2026/tests/historyStatus.test.mjs
T

14 lines
1.1 KiB
JavaScript

import {test} from 'node:test'
import assert from 'node:assert/strict'
import {getHistoryStatusLabel} from '../src/utils/history-status.ts'
test('history labels follow trash and purge before expiry/current flags',()=>{
for(const [value,want] of [[{current:true},'现存'],[{status:'trashed',current:false,expired:true},'回收站中'],[{status:'purged',deleted:true},'已清理'],[{status:'active',current:true},'现存'],[{status:'expired',current:true},'现存'],[{deleted:true,current:false},'已删除'],[{current:false},'历史']])assert.equal(getHistoryStatusLabel(value),want)
})
test('restored history is distinct and recoverable reasons match trash labels',()=>{
assert.equal(getHistoryStatusLabel({status:'active',current:true,was_restored:true}),'现存,已从回收站恢复')
assert.equal(getHistoryStatusLabel({status:'trashed',trash_reason:'expired_count'}),'次数用尽')
assert.equal(getHistoryStatusLabel({status:'trashed',trash_reason:'expired_time'}),'保存到期')
assert.equal(getHistoryStatusLabel({status:'trashed',trash_reason:'manual'}),'手动删除')
})