21 lines
788 B
TypeScript
21 lines
788 B
TypeScript
import assert from "node:assert/strict";
|
|
import { describe, it } from "node:test";
|
|
|
|
import { formatOperatorError } from "./operatorError.ts";
|
|
|
|
describe("formatOperatorError", () => {
|
|
it("turns an HTML or JSON parser response into operator copy", () => {
|
|
const result = formatOperatorError(
|
|
new Error("Unexpected token '<', \"<!doctype html>\" is not valid JSON"),
|
|
"Operations map laden mislukt.",
|
|
);
|
|
|
|
assert.equal(result, "Operations map laden mislukt. De backendbron gaf geen geldige API-respons.");
|
|
assert.doesNotMatch(result, /doctype|unexpected token/i);
|
|
});
|
|
|
|
it("keeps a concise backend message", () => {
|
|
assert.equal(formatOperatorError(new Error("Portainer is niet bereikbaar."), "Laden mislukt."), "Portainer is niet bereikbaar.");
|
|
});
|
|
});
|