交付 FastAPI/Celery/Vue 薄壳、FORCE RLS、Compose 回环与 review 修复证据,关闭 M01 DONE_LOCAL。 Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
1022 B
TypeScript
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",
|
|
});
|
|
});
|
|
});
|