Add Client Tests

This commit is contained in:
Vylpes 2021-02-13 16:56:18 +00:00
parent 15b4a168df
commit 893c0e1675

View file

@ -1,5 +1,6 @@
const { client } = require('../../../src'); const { client } = require('../../../src');
const { readFileSync } = require('fs'); const { readFileSync } = require('fs');
const { expect } = require('@jest/globals');
// Mocks // Mocks
jest.mock('discord.js'); jest.mock('discord.js');
@ -18,10 +19,27 @@ describe('Client Tests', () => {
instance = new client(config, commandConfig); instance = new client(config, commandConfig);
expect(instance.config).toBe(config); expect(instance.config).toBe(config);
expect(instance.commandConfig).toBe(commandConfig);
expect(instance.events).toBeDefined(); expect(instance.events).toBeDefined();
expect(instance.util).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)', () => { test('Configure Client (Incorrect parameters: token)', () => {
expect(() => { expect(() => {
delete config.token; delete config.token;
@ -51,7 +69,9 @@ describe('Client Tests', () => {
}); });
test('Start Client', () => { test('Start Client', () => {
expect(() => {
instance = new client(config, commandConfig); instance = new client(config, commandConfig);
instance.start(); instance.start();
}).not.toThrow();
}); });
}); });