The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
add tests
Kiran K7a4f2d354417
diff --git a/apps/web/tests/links/bulk-delete-link.test.ts b/apps/web/tests/links/bulk-delete-link.test.tsnew file mode 100644index 0000000000..4140c1fcf4--- /dev/null+++ b/apps/web/tests/links/bulk-delete-link.test.ts@@ -0,0 +1,44 @@+import { Link } from "@prisma/client";+import { expect, test } from "vitest";+import { randomId } from "../utils/helpers";+import { IntegrationHarness } from "../utils/integration";+import { link } from "../utils/resource";++const { domain } = link;++test("DELETE /links/bulk", async (ctx) => {+ const h = new IntegrationHarness(ctx);+ const { http } = await h.init();++ const bulkLinks = Array.from({ length: 2 }, () => ({+ url: `https://example.com/${randomId()}`,+ domain,+ }));++ const { data: links } = await http.post<Link[]>({+ path: "/links/bulk",+ body: bulkLinks,+ });++ const linkIds = links.map((l) => l.id);+ linkIds.push("some-random-id-that-does-not-exist");++ const { status, data } = await http.delete<{+ deletedCount: number;+ }>({+ path: "/links/bulk",+ query: {+ linkIds: linkIds.join(","),+ },+ });++ expect(status).toEqual(200);+ expect(data.deletedCount).toEqual(2);++ // Verify that the links are deleted+ const fetchedLinks = await Promise.all(+ linkIds.map((id) => http.get<Link>({ path: `/links/${id}` })),+ );++ expect(fetchedLinks.every((l) => l.status === 404)).toBeTruthy();+});