39 lines
836 B
TypeScript
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)
|
|
})
|