Files
calendar/tests/libs/__mocks__/prisma.ts
T
VijayandGitHub e3abd35ba7 fix: upgrade prismock to 1.33.4 (#17735)
* upgrade prismock, removed 2 hacks, update 3 tests

* yarnlock changes
2024-11-19 23:20:27 +00:00

41 lines
1.1 KiB
TypeScript

import { PrismockClient } from "prismock";
import { beforeEach, vi } from "vitest";
import logger from "@calcom/lib/logger";
import * as selects from "@calcom/prisma/selects";
vi.mock("@calcom/prisma", () => ({
default: prisma,
prisma,
readonlyPrisma: prisma,
...selects,
}));
const handlePrismockBugs = () => {
const __findManyWebhook = prismock.webhook.findMany;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
prismock.webhook.findMany = (...rest: any[]) => {
// There is some bug in prismock where it can't handle complex where clauses
if (rest[0].where?.OR && rest[0].where.AND) {
rest[0].where = undefined;
logger.silly("Fixed Prismock bug-2");
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return __findManyWebhook(...rest);
};
};
beforeEach(() => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
prismock.reset();
handlePrismockBugs();
});
const prismock = new PrismockClient();
const prisma = prismock;
export default prisma;