-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathhttpErrors.test.ts
More file actions
28 lines (24 loc) · 786 Bytes
/
Copy pathhttpErrors.test.ts
File metadata and controls
28 lines (24 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { describe, expect, it } from "vitest";
import { throwNotFound } from "~/utils/httpErrors";
describe("throwNotFound", () => {
it("throws a Response with status 404 and the provided statusText", () => {
let thrown: unknown;
try {
throwNotFound("Environment not found");
} catch (e) {
thrown = e;
}
expect(thrown).toBeInstanceOf(Response);
expect((thrown as Response).status).toBe(404);
expect((thrown as Response).statusText).toBe("Environment not found");
});
it("passes through whatever statusText the caller provides", () => {
let thrown: unknown;
try {
throwNotFound("Project not found");
} catch (e) {
thrown = e;
}
expect((thrown as Response).statusText).toBe("Project not found");
});
});