From 893c0e1675d65796ca7890493d96cf0b50647be6 Mon Sep 17 00:00:00 2001 From: Vylpes Date: Sat, 13 Feb 2021 16:56:18 +0000 Subject: [PATCH] Add Client Tests --- tests/src/client/client.test.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tests/src/client/client.test.js b/tests/src/client/client.test.js index 735c1e8..33b18bf 100644 --- a/tests/src/client/client.test.js +++ b/tests/src/client/client.test.js @@ -1,5 +1,6 @@ const { client } = require('../../../src'); const { readFileSync } = require('fs'); +const { expect } = require('@jest/globals'); // Mocks jest.mock('discord.js'); @@ -18,10 +19,27 @@ describe('Client Tests', () => { instance = new client(config, commandConfig); expect(instance.config).toBe(config); + expect(instance.commandConfig).toBe(commandConfig); expect(instance.events).toBeDefined(); expect(instance.util).toBeDefined(); }); + test('Configure Client (Undefined: config)', () => { + expect(() => { + instance = new client(config, commandConfig); + instance._config = undefined; + instance.start(); + }).toThrow("Config has not been set"); + }); + + test('Configure Client (Undefined: Command Config)', () => { + expect(() => { + instance = new client(config, commandConfig); + instance._commandConfig = undefined; + instance.start(); + }).toThrow("Command Config has not been set"); + }); + test('Configure Client (Incorrect parameters: token)', () => { expect(() => { delete config.token; @@ -51,7 +69,9 @@ describe('Client Tests', () => { }); test('Start Client', () => { - instance = new client(config, commandConfig); - instance.start(); + expect(() => { + instance = new client(config, commandConfig); + instance.start(); + }).not.toThrow(); }); }); \ No newline at end of file