mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-05 21:32:02 -06:00
Co-authored-by: Johannes <johannes@formbricks.com> Co-authored-by: Matti Nannt <mail@matthiasnannt.com>
31 lines
776 B
TypeScript
31 lines
776 B
TypeScript
// mock these globally used functions
|
|
import { afterEach, beforeEach, expect, it, vi } from "vitest";
|
|
import { ValidationError } from "@formbricks/types/errors";
|
|
|
|
vi.mock("next/cache", () => ({
|
|
__esModule: true,
|
|
unstable_cache: (fn: (params: unknown[]) => {}) => {
|
|
return async (params: unknown[]) => fn(params);
|
|
},
|
|
revalidateTag: vi.fn(),
|
|
}));
|
|
|
|
vi.mock("server-only", () => {
|
|
return {};
|
|
});
|
|
|
|
beforeEach(() => {
|
|
vi.resetModules();
|
|
vi.resetAllMocks();
|
|
});
|
|
|
|
afterEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
export const testInputValidation = async (service: Function, ...args: any[]): Promise<void> => {
|
|
it("it should throw a ValidationError if the inputs are invalid", async () => {
|
|
await expect(service(...args)).rejects.toThrow(ValidationError);
|
|
});
|
|
};
|