GuDingZiChan/frontend/scripts/test-borrow-anomaly.ts
WuYongJie 0dc3c09315 feat(资产与打印): 提交近期借还盘点与打印助手源码
- 提交借用单缺失异常处理、扫码借还搜索与站内消息快捷处理源码
- 提交盘点范围、多终端打印、组织同步与认证模式相关源码
- 提交 .NET/Node 打印助手及版本清单源码
2026-03-27 20:18:31 +08:00

39 lines
836 B
TypeScript

import assert from 'node:assert/strict'
import test from 'node:test'
import { canHandleBorrowAnomaly } from '../src/utils/borrowAnomaly.ts'
test('支持后端返回的 camelCase canHandle 字段', () => {
const result = canHandleBorrowAnomaly({
borrow_anomaly: {
state: 'borrow_record_missing',
canHandle: true
}
})
assert.equal(result, true)
})
test('兼容旧的 snake_case can_handle 字段', () => {
const result = canHandleBorrowAnomaly({
borrow_anomaly: {
state: 'borrow_record_missing',
can_handle: true
}
})
assert.equal(result, true)
})
test('非借用单缺失状态时不可处理', () => {
const result = canHandleBorrowAnomaly({
borrow_anomaly: {
state: 'none',
canHandle: true,
can_handle: true
}
})
assert.equal(result, false)
})