Add Client Tests
This commit is contained in:
parent
15b4a168df
commit
893c0e1675
1 changed files with 22 additions and 2 deletions
|
@ -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();
|
||||
});
|
||||
});
|
Reference in a new issue