fix: 补齐候选诊断环境与证据保护(09-06-release-gate-integrity)
这个提交包含在:
@@ -0,0 +1,31 @@
|
||||
const { ensureNonNegativeAmount } = require("../../../src/routes/reimbursements").__testables;
|
||||
const { AppError } = require("../../../src/utils/AppError");
|
||||
|
||||
describe("reimbursement total amount defense", () => {
|
||||
function assertRejected(value, detail, reasonCode) {
|
||||
let caught;
|
||||
try {
|
||||
ensureNonNegativeAmount(value);
|
||||
} catch (error) {
|
||||
caught = error;
|
||||
}
|
||||
expect(caught).toBeInstanceOf(AppError);
|
||||
expect(caught).toMatchObject({
|
||||
code: "VALID_001",
|
||||
statusCode: 400,
|
||||
details: { total_amount: detail, reasonCode },
|
||||
});
|
||||
}
|
||||
|
||||
it.each([-1, "-0.01", -Number.MIN_VALUE])("directly rejects negative total %s", (value) => {
|
||||
assertRejected(value, "negative_not_allowed", "reimbursement.total_amount_negative_not_allowed");
|
||||
});
|
||||
|
||||
it.each([NaN, Infinity, -Infinity, "not-a-number", undefined])("directly rejects non-finite total %s", (value) => {
|
||||
assertRejected(value, "invalid", "reimbursement.total_amount_invalid");
|
||||
});
|
||||
|
||||
it.each([0, "0.00", 1, "188.80"])("preserves acceptance of finite nonnegative total %s", (value) => {
|
||||
expect(() => ensureNonNegativeAmount(value)).not.toThrow();
|
||||
});
|
||||
});
|
||||
在新工单中引用
屏蔽一个用户