20 lines
721 B
TypeScript
20 lines
721 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { statusForHttp } from "./http-status";
|
|
|
|
describe("HTTP status semantics", () => {
|
|
it.each([
|
|
[100, "Informational response", "muted"],
|
|
[200, "Healthy response", "green"],
|
|
[302, "Redirect response", "muted"],
|
|
[404, "Client error", "amber"],
|
|
[503, "Server error", "red"],
|
|
] as const)("classifies %s without misleading status colors", (status, label, tone) => {
|
|
expect(statusForHttp(status)).toEqual({ label, tone });
|
|
});
|
|
|
|
it.each([null, undefined, 99, 600, 200.5, "200"])("treats %s as incomplete", (status) => {
|
|
expect(statusForHttp(status).label).toBe("Incomplete");
|
|
expect(statusForHttp(status).tone).toBe("muted");
|
|
});
|
|
});
|