forked from longtao.wu/droboticflow
20 lines
933 B
JavaScript
20 lines
933 B
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { getActionErrorMessage } from "../../src/lib/action-errors.js";
|
|
|
|
test("action error message prefers non-empty Error messages", () => {
|
|
assert.equal(getActionErrorMessage(new Error(" forbidden "), "保存失败"), "forbidden");
|
|
});
|
|
|
|
test("action error message accepts plain string and object messages", () => {
|
|
assert.equal(getActionErrorMessage(" request timed out ", "操作失败"), "request timed out");
|
|
assert.equal(getActionErrorMessage({ message: " invalid payload " }, "操作失败"), "invalid payload");
|
|
});
|
|
|
|
test("action error message falls back for empty or unsupported errors", () => {
|
|
assert.equal(getActionErrorMessage(new Error(" "), "保存失败"), "保存失败");
|
|
assert.equal(getActionErrorMessage(null, " 删除失败 "), "删除失败");
|
|
assert.equal(getActionErrorMessage(undefined, ""), "操作失败");
|
|
});
|