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.

Delete get-workspace-for-stripe-account.test.ts

Kiran K1b4ae6ab16bb
diff --git a/apps/web/tests/stripe/get-workspace-for-stripe-account.test.ts b/apps/web/tests/stripe/get-workspace-for-stripe-account.test.ts
deleted file mode 100644
index b20b9df953..0000000000
--- a/apps/web/tests/stripe/get-workspace-for-stripe-account.test.ts
+++ /dev/null
@@ -1,81 +0,0 @@
-import { beforeEach, describe, expect, test, vi } from "vitest";
-import { getWorkspaceForStripeAccount } from "../../app/(ee)/api/stripe/integration/webhook/utils/get-workspace-for-stripe-account";
-
-const mocks = vi.hoisted(() => ({
- findMany: vi.fn(),
-}));
-
-vi.mock("@/lib/prisma", () => ({
- prisma: {
- project: {
- findMany: mocks.findMany,
- },
- },
-}));
-
-const stripeAccountId = "acct_test";
-
-const liveWorkspace = {
- id: "ws_live",
- stripeConnectId: stripeAccountId,
- stripeConnectMode: "live",
- defaultProgramId: null,
- webhookEnabled: false,
- environment: "production",
-};
-
-const testWorkspace = {
- ...liveWorkspace,
- id: "ws_test",
- stripeConnectMode: "test",
- environment: "staging",
-};
-
-describe("getWorkspaceForStripeAccount", () => {
- beforeEach(() => {
- mocks.findMany.mockReset();
- });
-
- test("returns the workspace connected in the event's mode", async () => {
- mocks.findMany.mockResolvedValue([liveWorkspace, testWorkspace]);
-
- await expect(
- getWorkspaceForStripeAccount({ stripeAccountId, mode: "live" }),
- ).resolves.toBe(liveWorkspace);
- await expect(
- getWorkspaceForStripeAccount({ stripeAccountId, mode: "test" }),
- ).resolves.toBe(testWorkspace);
-
- expect(mocks.findMany).toHaveBeenCalledWith(
- expect.objectContaining({
- where: {
- stripeConnectId: stripeAccountId,
- },
- }),
- );
- });
-
- test("falls back to the only workspace connected to the account", async () => {
- mocks.findMany.mockResolvedValue([liveWorkspace]);
-
- await expect(
- getWorkspaceForStripeAccount({ stripeAccountId, mode: "test" }),
- ).resolves.toBe(liveWorkspace);
- });
-
- test("returns null when several workspaces share the account and none match the mode", async () => {
- mocks.findMany.mockResolvedValue([liveWorkspace, testWorkspace]);
-
- await expect(
- getWorkspaceForStripeAccount({ stripeAccountId, mode: "sandbox" }),
- ).resolves.toBeNull();
- });
-
- test("returns null when no workspace is connected to the account", async () => {
- mocks.findMany.mockResolvedValue([]);
-
- await expect(
- getWorkspaceForStripeAccount({ stripeAccountId, mode: "live" }),
- ).resolves.toBeNull();
- });
-});