Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

add tests

Kiran Kf6df64026b31
diff --git a/apps/web/tests/domains/index.test.ts b/apps/web/tests/domains/index.test.ts
index e017a119a7..1c2b1c0ebc 100644
--- a/apps/web/tests/domains/index.test.ts
+++ b/apps/web/tests/domains/index.test.ts
@@ -1,5 +1,7 @@
+import { DomainStatusSchema } from "@/lib/zod/schemas/domains";
import { Domain } from "@dub/prisma/client";
import { describe, expect, onTestFinished, test } from "vitest";
+import { z } from "zod";
import { randomId } from "../utils/helpers";
import { IntegrationHarness } from "../utils/integration";
@@ -103,4 +105,34 @@ describe.sequential("/domains/**", async () => {
...toUpdate,
});
});
+
+ test("GET /domains/status", async () => {
+ const domains = [
+ "getacme.link", // existing one
+ `acme${randomId(3)}.link`, // expected to be available
+ ];
+
+ const { status, data: domainStatuses } = await http.get<
+ z.infer<typeof DomainStatusSchema>[]
+ >({
+ path: `/domains/status?domains=${domains.join(",")}`,
+ query: { workspaceId: workspace.id },
+ });
+
+ expect(status).toEqual(200);
+ expect(domainStatuses).toContainEqual([
+ {
+ domain: domains[0],
+ available: false,
+ price: null,
+ premium: null,
+ },
+ {
+ domain: domains[1],
+ available: true,
+ price: expect.any(String),
+ premium: expect.any(Boolean),
+ },
+ ]);
+ });
});
diff --git a/apps/web/tests/utils/helpers.ts b/apps/web/tests/utils/helpers.ts
index 0615a43155..d544b07d40 100644
--- a/apps/web/tests/utils/helpers.ts
+++ b/apps/web/tests/utils/helpers.ts
@@ -1,7 +1,7 @@
import { generateRandomName } from "@/lib/names";
import { OG_AVATAR_URL, nanoid } from "@dub/utils";
-export const randomId = () => nanoid(24);
+export const randomId = (length = 24) => nanoid(length);
// Generate random customer data
export const randomCustomer = () => {