Phase0
This commit is contained in:
16
packages/contracts/src/error.test.ts
Normal file
16
packages/contracts/src/error.test.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { problemDetailsSchema } from "./error";
|
||||
|
||||
describe("problemDetailsSchema", () => {
|
||||
it("accepts RFC 7807 problem details", () => {
|
||||
const result = problemDetailsSchema.safeParse({
|
||||
type: "https://example.com/errors/validation",
|
||||
title: "Validation failed",
|
||||
status: 400,
|
||||
detail: "Invalid input",
|
||||
instance: "/api/v1/servers",
|
||||
});
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
});
|
||||
23
packages/contracts/src/health.test.ts
Normal file
23
packages/contracts/src/health.test.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { healthResponseSchema } from "./health";
|
||||
|
||||
describe("healthResponseSchema", () => {
|
||||
it("accepts a valid liveness response", () => {
|
||||
const result = healthResponseSchema.safeParse({
|
||||
status: "ok",
|
||||
service: "api",
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects invalid status values", () => {
|
||||
const result = healthResponseSchema.safeParse({
|
||||
status: "unknown",
|
||||
service: "api",
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user