Files
watchman/web/apps/console/src/health.spec.ts
T
unknownandCursor 8fb16f4a4a feat(infra): 落地 M01 基础框架与本机开发环境
交付 FastAPI/Celery/Vue 薄壳、FORCE RLS、Compose 回环与 review 修复证据,关闭 M01 DONE_LOCAL。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-17 15:00:39 +08:00

40 lines
1022 B
TypeScript

import { describe, expect, it } from "vitest";
import { BusinessError } from "@watchman/api";
import { healthFailureView, healthSuccessView } from "./health";
describe("health view mapping", () => {
it("maps success payload", () => {
const view = healthSuccessView({
status: "ok",
app: "watchman",
version: "0.1.0",
});
expect(view).toEqual({
state: "success",
detail: "watchman 0.1.0",
});
});
it("maps BusinessError failure", () => {
const view = healthFailureView(
new BusinessError({
code: 50000,
message: "Service error",
status: 500,
requestId: "req-1",
}),
);
expect(view.state).toBe("failure");
expect(view.detail).toContain("50000");
expect(view.detail).toContain("Service error");
});
it("maps unknown failure", () => {
const view = healthFailureView(new Error("network down"));
expect(view).toEqual({
state: "failure",
detail: "Error: network down",
});
});
});