From 799b04e936c0f6fe7df9e0eda5feecf05d143d52 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sun, 26 Sep 2021 14:32:56 +0100 Subject: [PATCH] Update tests --- tests/__mocks/commands/noCategory.ts | 4 +-- tests/__mocks/commands/normal.ts | 4 +-- tests/__mocks/commands/roles.ts | 4 +-- tests/client/events.test.ts | 26 ++++++++-------- tests/client/util.test.ts | 46 ++++++++++++++-------------- 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/tests/__mocks/commands/noCategory.ts b/tests/__mocks/commands/noCategory.ts index 9d6d973..e71cd53 100644 --- a/tests/__mocks/commands/noCategory.ts +++ b/tests/__mocks/commands/noCategory.ts @@ -1,7 +1,7 @@ import { Command } from "../../../src/type/command"; -export class noCategory extends Command { +export default class noCategory extends Command { constructor() { super(); } -} \ No newline at end of file +} diff --git a/tests/__mocks/commands/normal.ts b/tests/__mocks/commands/normal.ts index 03695f4..3e3a74f 100644 --- a/tests/__mocks/commands/normal.ts +++ b/tests/__mocks/commands/normal.ts @@ -1,8 +1,8 @@ import { Command } from "../../../src/type/command"; -export class normal extends Command { +export default class normal extends Command { constructor() { super(); this._category = "General"; } -} \ No newline at end of file +} diff --git a/tests/__mocks/commands/roles.ts b/tests/__mocks/commands/roles.ts index d9343c7..1e0321e 100644 --- a/tests/__mocks/commands/roles.ts +++ b/tests/__mocks/commands/roles.ts @@ -1,8 +1,8 @@ import { Command } from "../../../src/type/command"; -export class roles extends Command { +export default class roles extends Command { constructor() { super(); this._roles = [ "Moderator" ]; } -} \ No newline at end of file +} diff --git a/tests/client/events.test.ts b/tests/client/events.test.ts index 2c9ad44..69baac9 100644 --- a/tests/client/events.test.ts +++ b/tests/client/events.test.ts @@ -10,7 +10,7 @@ beforeEach(() => { }); describe('OnMessage', () => { - test('Given Message Is Valid Expect Message Sent', () => { + test('Given Message Is Valid Expect Message Sent', async () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -30,7 +30,7 @@ describe('OnMessage', () => { const events = new Events(); - const result = events.onMessage(message); + const result = await events.onMessage(message); expect(result.valid).toBeTruthy(); @@ -41,7 +41,7 @@ describe('OnMessage', () => { expect(result.context?.message).toBe(message); }); - test('Given Guild Is Null, Expect Failed Result', () => { + test('Given Guild Is Null, Expect Failed Result', async () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -61,13 +61,13 @@ describe('OnMessage', () => { const events = new Events(); - const result = events.onMessage(message); + const result = await events.onMessage(message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("Message was not sent in a guild, ignoring."); }); - test('Given Author Is A Bot, Expect Failed Result', () => { + test('Given Author Is A Bot, Expect Failed Result', async () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -87,13 +87,13 @@ describe('OnMessage', () => { const events = new Events(); - const result = events.onMessage(message); + const result = await events.onMessage(message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("Message was sent by a bot, ignoring."); }); - test('Given Message Content Was Not A Command, Expect Failed Result', () => { + test('Given Message Content Was Not A Command, Expect Failed Result', async () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -113,13 +113,13 @@ describe('OnMessage', () => { const events = new Events(); - const result = events.onMessage(message); + const result = await events.onMessage(message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("Message was not a command, ignoring."); }); - test('Given Message Had No Command Name, Expect Failed Result', () => { + test('Given Message Had No Command Name, Expect Failed Result', async () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -139,13 +139,13 @@ describe('OnMessage', () => { const events = new Events(); - const result = events.onMessage(message); + const result = await events.onMessage(message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("Command name was not found"); }); - test('Given Command Failed To Execute, Expect Failed Result', () => { + test('Given Command Failed To Execute, Expect Failed Result', async () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -165,7 +165,7 @@ describe('OnMessage', () => { const events = new Events(); - const result = events.onMessage(message); + const result = await events.onMessage(message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("Command failed"); @@ -182,4 +182,4 @@ describe('OnReady', () => { expect(console.log).toBeCalledWith("Ready"); }); -}); \ No newline at end of file +}); diff --git a/tests/client/util.test.ts b/tests/client/util.test.ts index 9787ed4..c79e15d 100644 --- a/tests/client/util.test.ts +++ b/tests/client/util.test.ts @@ -10,7 +10,7 @@ beforeEach(() => { }); describe('LoadCommand', () => { - test('Given Successful Exection, Expect Successful Result', () => { + test('Given Successful Exection, Expect Successful Result', async () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -34,12 +34,12 @@ describe('LoadCommand', () => { const util = new Util(); - const result = util.loadCommand("normal", [ "first" ], message); + const result = await util.loadCommand("normal", [ "first" ], message); expect(result.valid).toBeTruthy(); }); - test('Given Member Is Null, Expect Failed Result', () => { + test('Given Member Is Null, Expect Failed Result', async () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -56,13 +56,13 @@ describe('LoadCommand', () => { const util = new Util(); - const result = util.loadCommand("normal", [ "first" ], message); + const result = await util.loadCommand("normal", [ "first" ], message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("Member is not part of message"); }); - test('Given Folder Does Not Exist, Expect Failed Result', () => { + test('Given Folder Does Not Exist, Expect Failed Result', async () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -86,13 +86,13 @@ describe('LoadCommand', () => { const util = new Util(); - const result = util.loadCommand("normal", [ "first" ], message); + const result = await util.loadCommand("normal", [ "first" ], message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("Command folder does not exist"); }); - test('Given File Does Not Exist, Expect Failed Result', () => { + test('Given File Does Not Exist, Expect Failed Result', async () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -117,13 +117,13 @@ describe('LoadCommand', () => { const util = new Util(); - const result = util.loadCommand("normal", [ "first" ], message); + const result = await util.loadCommand("normal", [ "first" ], message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("File does not exist"); }); - test('Given User Does Have Role, Expect Successful Result', () => { + test('Given User Does Have Role, Expect Successful Result', async () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -147,12 +147,12 @@ describe('LoadCommand', () => { const util = new Util(); - const result = util.loadCommand("roles", [ "first" ], message); + const result = await util.loadCommand("roles", [ "first" ], message); expect(result.valid).toBeTruthy(); }); - test('Given User Does Not Have Role, Expect Failed Result', () => { + test('Given User Does Not Have Role, Expect Failed Result', async () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -176,13 +176,13 @@ describe('LoadCommand', () => { const util = new Util(); - const result = util.loadCommand("roles", [ "first" ], message); + const result = await util.loadCommand("roles", [ "first" ], message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("You require the `Moderator` role to run this command"); }); - test('Given Command Category Is Null, Expect Successful Result', () => { + test('Given Command Category Is Null, Expect Successful Result', async () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -206,12 +206,12 @@ describe('LoadCommand', () => { const util = new Util(); - const result = util.loadCommand("noCategory", [ "first" ], message); + const result = await util.loadCommand("noCategory", [ "first" ], message); expect(result.valid).toBeTruthy(); }); - test('Given command is set to disabled, Expect command to not fire', () => { + test('Given command is set to disabled, Expect command to not fire', async () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -239,14 +239,14 @@ describe('LoadCommand', () => { const util = new Util(); - const result = util.loadCommand("normal", [ "first" ], message); + const result = await util.loadCommand("normal", [ "first" ], message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("Command is disabled"); expect(messageReply).toBeCalledWith("disabled"); }); - test('Given command COMMANDS_DISABLED_MESSAGE is empty, Expect default message sent', () => { + test('Given command COMMANDS_DISABLED_MESSAGE is empty, Expect default message sent', async () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -273,14 +273,14 @@ describe('LoadCommand', () => { const util = new Util(); - const result = util.loadCommand("normal", [ "first" ], message); + const result = await util.loadCommand("normal", [ "first" ], message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("Command is disabled"); expect(messageReply).toBeCalledWith("This command is disabled."); }); - test('Given a different command is disabled, Expect command to still fire', () => { + test('Given a different command is disabled, Expect command to still fire', async () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -305,12 +305,12 @@ describe('LoadCommand', () => { const util = new Util(); - const result = util.loadCommand("normal", [ "first" ], message); + const result = await util.loadCommand("normal", [ "first" ], message); expect(result.valid).toBeTruthy(); }); - test('Given a different command is disabled with this one, Expect command to not fire', () => { + test('Given a different command is disabled with this one, Expect command to not fire', async () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -335,7 +335,7 @@ describe('LoadCommand', () => { const util = new Util(); - const result = util.loadCommand("normal", [ "first" ], message); + const result = await util.loadCommand("normal", [ "first" ], message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("Command is disabled"); @@ -418,4 +418,4 @@ describe('LoadEvents', () => { expect(result.valid).toBeFalsy(); expect(result.message).toBe("Event folder does not exist"); }); -}); \ No newline at end of file +});