mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-29 03:13:19 -05:00
056e572a31
Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import { beforeEach, describe, expect, test, vi } from "vitest";
|
|
import { TOrganizationBillingPlan } from "@formbricks/types/organizations";
|
|
import * as constants from "@/lib/constants";
|
|
import { getSurveyFollowUpsPermission } from "./utils";
|
|
|
|
vi.mock("@/lib/constants", async () => {
|
|
const actual = (await vi.importActual("@/lib/constants")) as any;
|
|
return {
|
|
...actual,
|
|
IS_FORMBRICKS_CLOUD: true,
|
|
PROJECT_FEATURE_KEYS: {
|
|
FREE: "free",
|
|
STARTUP: "startup",
|
|
CUSTOM: "custom",
|
|
},
|
|
};
|
|
});
|
|
|
|
describe("getSurveyFollowUpsPermission", () => {
|
|
beforeEach(() => {
|
|
vi.spyOn(constants, "IS_FORMBRICKS_CLOUD", "get").mockReturnValue(true);
|
|
});
|
|
|
|
test("should return false for free plan on Formbricks Cloud", async () => {
|
|
const result = await getSurveyFollowUpsPermission("free" as TOrganizationBillingPlan);
|
|
expect(result).toBe(false);
|
|
});
|
|
|
|
test("should return false for startup plan on Formbricks Cloud", async () => {
|
|
const result = await getSurveyFollowUpsPermission("startup" as TOrganizationBillingPlan);
|
|
expect(result).toBe(false);
|
|
});
|
|
|
|
test("should return true for custom plan on Formbricks Cloud", async () => {
|
|
const result = await getSurveyFollowUpsPermission("custom" as TOrganizationBillingPlan);
|
|
expect(result).toBe(true);
|
|
});
|
|
|
|
test("should return true for any plan when not on Formbricks Cloud", async () => {
|
|
vi.spyOn(constants, "IS_FORMBRICKS_CLOUD", "get").mockReturnValue(false);
|
|
const result = await getSurveyFollowUpsPermission("free" as TOrganizationBillingPlan);
|
|
expect(result).toBe(true);
|
|
});
|
|
});
|