mirror of
https://github.com/jarvis2f/vortex.git
synced 2024-11-16 03:32:41 +08:00
22 lines
666 B
TypeScript
22 lines
666 B
TypeScript
import { PrismaClient } from "@prisma/client";
|
|
import { DeepMockProxy, mockDeep, mockReset } from "jest-mock-extended";
|
|
import { db, redis, subRedis } from "../src/server/db";
|
|
import Redis from "ioredis";
|
|
|
|
jest.mock("../src/server/db", () => ({
|
|
__esModule: true,
|
|
db: mockDeep<PrismaClient>(),
|
|
redis: mockDeep<Redis>(),
|
|
subRedis: mockDeep<Redis>(),
|
|
}));
|
|
|
|
beforeEach(() => {
|
|
mockReset(dbMock);
|
|
mockReset(redisMock);
|
|
mockReset(subRedisMock);
|
|
});
|
|
|
|
export const dbMock = db as unknown as DeepMockProxy<PrismaClient>;
|
|
export const redisMock = redis as unknown as DeepMockProxy<Redis>;
|
|
export const subRedisMock = subRedis as unknown as DeepMockProxy<Redis>;
|