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 { 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', () => {
|
||||||
instance = new client(config, commandConfig);
|
expect(() => {
|
||||||
instance.start();
|
instance = new client(config, commandConfig);
|
||||||
|
instance.start();
|
||||||
|
}).not.toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
Reference in a new issue