Skip to content
File

Blob: tests/worker/api/domains.test.ts

typescript33 lines
1import { beforeEach, describe, expect, it } from "vitest";
2import { apiRequest, resetWorkerState, seedDomain } from "./helpers";
3 
4describe("worker api /api/public/domains", () => {
5 beforeEach(async () => {
6 await resetWorkerState();
7 });
8 
9 it("returns only active domains", async () => {
10 await seedDomain("mail.test", true);
11 await seedDomain("inactive.test", false);
12 await seedDomain("alpha.test", true);
13 
14 const response = await apiRequest("/api/public/domains");
15 
16 expect(response.status).toBe(200);
17 await expect(response.json()).resolves.toEqual({
18 domains: ["alpha.test", "mail.test"],
19 });
20 });
21 
22 it("returns an empty list when there are no active domains", async () => {
23 await seedDomain("inactive.test", false);
24 
25 const response = await apiRequest("/api/public/domains");
26 
27 expect(response.status).toBe(200);
28 await expect(response.json()).resolves.toEqual({
29 domains: [],
30 });
31 });
32});