1 |
rakinar2 |
577 |
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 |
|
|
} |