Skip to content

Commit b8b9a1e

Browse files
committed
Fixed jest tests
1 parent 374e47e commit b8b9a1e

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const client = new Client({
5252
});
5353

5454
const shoukaku = new Shoukaku(new Connectors.DiscordJS(client), nodes);
55-
const laurentina = new Laurentina(client, shoukaku, nodes);
55+
const laurentina = new Laurentina(shoukaku, nodes);
5656

5757
// Bind shoukaku and laurentina to client
5858
client.shoukaku = shoukaku;

src/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,10 @@ class AudioController extends EventEmitter {
351351
}
352352
}
353353

354-
export type { AudioController };
355-
356354
class Laurentina {
357-
private client: discord.Client;
358355
shoukaku: shoukaku.Shoukaku;
359356
private audioController: Map<string, AudioController>;
360-
constructor(client: discord.Client, shoukaku: shoukaku.Shoukaku, lavalinkNodes: LavalinkNode[]) {
361-
this.client = client as discord.Client;
357+
constructor(shoukaku: shoukaku.Shoukaku, lavalinkNodes: LavalinkNode[]) {
362358
this.shoukaku = shoukaku;
363359
this.audioController = new Map<string, AudioController>();
364360
}
@@ -413,4 +409,4 @@ class Laurentina {
413409

414410
export * from "./types/track";
415411

416-
export { Laurentina, PlaybackState, LoopMode, ShuffleMode };
412+
export { Laurentina, AudioController, PlaybackState, LoopMode, ShuffleMode };

tests/index.test.ts

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
import { Client, TextChannel } from "discord.js";
2-
import { Player, Shoukaku } from "shoukaku";
1+
import { Client } from "discord.js";
2+
import { Shoukaku } from "shoukaku";
33
import { Laurentina } from "../src";
44

5-
// Mocks
6-
// const mockGuildID = '1234567890';
7-
// const mockChannelID = '0987654321';
8-
// const mockTextChannel = {} as TextChannel;
9-
// const mockPlayer = {} as Player;
5+
const mockGuildID = '1234567890';
6+
const mockChannelID = '0987654321';
7+
const mockTextChannel = '1234567890'
108

11-
interface CustomClient extends Client {
12-
shoukaku: Shoukaku;
13-
laurentina: Laurentina;
9+
declare module "discord.js" {
10+
interface Client {
11+
laurentina: Laurentina;
12+
shoukaku: Shoukaku;
13+
}
1414
}
1515

16-
const client = {} as CustomClient;
17-
const mockShoukaku = {} as Shoukaku;
16+
const client = {} as Client;
1817
const mockLavalinkNodes = {} as { name: string; url: string; auth: string }[];
18+
const mockShoukaku = {} as Shoukaku;
1919

20-
const laurentina = new Laurentina(client, mockShoukaku, mockLavalinkNodes);
20+
const laurentina = new Laurentina(mockShoukaku, mockLavalinkNodes);
2121

2222
client.shoukaku = mockShoukaku;
2323
client.laurentina = laurentina;
@@ -28,14 +28,19 @@ describe("Laurentina", () => {
2828
});
2929

3030
it("should be an instance of Laurentina", () => {
31-
expect(laurentina).toBeInstanceOf(Laurentina);
31+
expect(client.laurentina).toBeInstanceOf(Laurentina);
32+
});
33+
34+
it("should have a property 'shoukaku'", () => {
35+
expect(client.laurentina.shoukaku).toBe(mockShoukaku);
3236
});
3337

34-
it("should have a property 'client'", () => {
35-
expect(laurentina.client).toBe(client);
38+
it("should return 'false' if the guild ID for 'removeController' is not found", () => {
39+
expect(client.laurentina.removeController(mockGuildID)).toBeFalsy();
3640
});
3741

38-
it("should have a property 'shoukaku'", () => {
39-
expect(laurentina.shoukaku).toBe(mockShoukaku);
42+
it("should return 'undefined' if the guild ID for 'AudioController' is not found", () => {
43+
const audioController = laurentina.getController(mockGuildID);
44+
expect(audioController).toBeUndefined();
4045
});
4146
});

0 commit comments

Comments
 (0)