/[sudobot]/branches/9.x-dev/tests/mocks/client.mock.ts
ViewVC logotype

Contents of /branches/9.x-dev/tests/mocks/client.mock.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (show annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 1070 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 import "reflect-metadata";
2
3 import Client from "@/core/Client";
4 import { ClientUser } from "discord.js";
5 import { vi } from "vitest";
6 import { randomSnowflake } from "./snowflakes";
7
8 vi.mock("@prisma/client", () => {
9 return {
10 __esModule: true,
11 PrismaClient: vi.fn().mockImplementation(() => {
12 return {
13 user: {
14 findUnique: vi.fn(),
15 create: vi.fn(),
16 findMany: vi.fn(),
17 update: vi.fn(),
18 delete: vi.fn()
19 }
20 };
21 })
22 };
23 });
24
25 export function createClient() {
26 const client = new Client({
27 intents: []
28 });
29
30 const id = randomSnowflake();
31
32 client.user = {
33 id,
34 username: "SudoBot",
35 discriminator: "0000",
36 tag: "SudoBot#0000",
37 avatar: "avatar",
38 bot: true,
39 system: false,
40 client,
41 toString() {
42 return `<@${id}>`;
43 }
44 } as unknown as ClientUser;
45
46 return client as Client<true>;
47 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26