Tests and CI #44
|
@ -10,126 +10,130 @@ jest.mock("dotenv");
|
|||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
jest.mock("../../src/client/events");
|
||||
jest.mock("../../src/client/util");
|
||||
|
||||
test('Constructor_ExpectSuccessfulInitialisation', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(coreClient).toBeInstanceOf(Client);
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(dotenv.config).toBeCalledTimes(1);
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(Events).toBeCalledTimes(1);
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(Util).toBeCalledTimes(1);
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
describe('Constructor', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
test('Constructor_ExpectSuccessfulInitialisation', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(coreClient).toBeInstanceOf(Client);
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(dotenv.config).toBeCalledTimes(1);
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(Events).toBeCalledTimes(1);
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(Util).toBeCalledTimes(1);
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
|
||||
test('Start_GivenEnvIsValid_ExpectSuccessfulStart', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
process.env = {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_PREFIX: '!',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_EVENTS: 'events',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
}
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
describe('Start', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
test('Given Env Is Valid, Expect Successful Start', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
process.env = {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_PREFIX: '!',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_EVENTS: 'events',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
}
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
expect(() => coreClient.start()).not.toThrow();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(coreClient.on).toBeCalledWith("message", expect.any(Function));
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(coreClient.on).toBeCalledWith("ready", expect.any(Function));
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
test('Start_GivenBotTokenIsNull_ExpectFailure', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
process.env = {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_PREFIX: '!',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_EVENTS: 'events',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
}
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(() => coreClient.start()).not.toThrow();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(coreClient.on).toBeCalledWith("message", expect.any(Function));
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(coreClient.on).toBeCalledWith("ready", expect.any(Function));
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
expect(() => coreClient.start()).toThrow("BOT_TOKEN is not defined in .env");
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
test('Start_GivenBotTokenIsEmpty_ExpectFailure', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
process.env = {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_TOKEN: '',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_PREFIX: '!',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_EVENTS: 'events',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
}
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
test('Given BOT_TOKEN Is Null, Expect Failure', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
process.env = {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_PREFIX: '!',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_EVENTS: 'events',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
}
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
expect(() => coreClient.start()).toThrow("BOT_TOKEN is not defined in .env");
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
test('Start_GivenBotPrefixIsNull_ExpectFailure', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
process.env = {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_EVENTS: 'events',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
}
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(() => coreClient.start()).toThrow("BOT_TOKEN is not defined in .env");
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
expect(() => coreClient.start()).toThrow("BOT_PREFIX is not defined in .env");
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
test('Start_GivenBotPrefixIsEmpty_ExpectFailure', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
process.env = {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_PREFIX: '',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_EVENTS: 'events',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
}
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
test('Given BOT_TOKEN Is Empty, Expect Failure', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
process.env = {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_TOKEN: '',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_PREFIX: '!',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_EVENTS: 'events',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
}
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
expect(() => coreClient.start()).toThrow("BOT_PREFIX is not defined in .env");
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
test('Start_GivenFoldersCommandsIsNull_ExpectFailure', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
process.env = {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_PREFIX: '!',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_EVENTS: 'events',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
}
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(() => coreClient.start()).toThrow("BOT_TOKEN is not defined in .env");
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
expect(() => coreClient.start()).toThrow("FOLDERS_COMMANDS is not defined in .env");
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
test('Start_GivenFoldersCommandsIsEmpty_ExpectFailure', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
process.env = {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_PREFIX: '!',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_COMMANDS: '',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_EVENTS: 'events',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
}
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
test('Given BOT_PREFIX Is Null, Expect Failure', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
process.env = {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_EVENTS: 'events',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
}
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
expect(() => coreClient.start()).toThrow("FOLDERS_COMMANDS is not defined in .env");
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
test('Start_GivenFoldersEventsIsNull_ExpectFailure', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
process.env = {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_PREFIX: '!',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
}
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(() => coreClient.start()).toThrow("BOT_PREFIX is not defined in .env");
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
expect(() => coreClient.start()).toThrow("FOLDERS_EVENTS is not defined in .env");
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
test('Start_GivenFoldersCommandsIsEmpty_ExpectFailure', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
process.env = {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_PREFIX: '!',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_EVENTS: '',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
}
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
test('Given BOT_PREFIX Is Empty, Expect Failure', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
process.env = {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_PREFIX: '',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_EVENTS: 'events',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
}
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
expect(() => coreClient.start()).toThrow("FOLDERS_EVENTS is not defined in .env");
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(() => coreClient.start()).toThrow("BOT_PREFIX is not defined in .env");
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
test('Given FOLDERS_COMMANDS Is Null, Expect Failure', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
process.env = {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_PREFIX: '!',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_EVENTS: 'events',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
}
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(() => coreClient.start()).toThrow("FOLDERS_COMMANDS is not defined in .env");
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
test('Given FOLDERS_COMMANDS Is Empty, Expect Failure', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
process.env = {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_PREFIX: '!',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_COMMANDS: '',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_EVENTS: 'events',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
}
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(() => coreClient.start()).toThrow("FOLDERS_COMMANDS is not defined in .env");
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
test('Given FOLDERS_EVENTS Is Null, Expect Failure', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
process.env = {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_PREFIX: '!',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
}
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(() => coreClient.start()).toThrow("FOLDERS_EVENTS is not defined in .env");
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
test('Given FOLDERS_EVENTS Is Empty, Expect Failure', () => {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
process.env = {
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
BOT_PREFIX: '!',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
FOLDERS_EVENTS: '',
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
}
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
const coreClient = new CoreClient();
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
expect(() => coreClient.start()).toThrow("FOLDERS_EVENTS is not defined in .env");
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
||||
Should these be put into a describe group? Should these be put into a describe group?
This would apply to all other tests also This would apply to all other tests also
|
||||
});
|
|
@ -9,173 +9,177 @@ beforeEach(() => {
|
|||
Util.prototype.loadCommand = jest.fn();
|
||||
});
|
||||
|
||||
test('OnMessage_GivenMessageIsValid_ExpectMessageSent', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
};
|
||||
|
||||
Util.prototype.loadCommand = jest.fn().mockReturnValue({ valid: true });
|
||||
|
||||
const message = {
|
||||
guild: {},
|
||||
author: {
|
||||
bot: false,
|
||||
},
|
||||
content: "!test first",
|
||||
} as unknown as Message;
|
||||
|
||||
const events = new Events();
|
||||
|
||||
const result = events.onMessage(message);
|
||||
|
||||
expect(result.valid).toBeTruthy();
|
||||
|
||||
expect(result.context?.prefix).toBe('!');
|
||||
expect(result.context?.name).toBe('test');
|
||||
expect(result.context?.args.length).toBe(1);
|
||||
expect(result.context?.args[0]).toBe('first');
|
||||
expect(result.context?.message).toBe(message);
|
||||
describe('OnMessage', () => {
|
||||
test('Given Message Is Valid Expect Message Sent', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
};
|
||||
|
||||
Util.prototype.loadCommand = jest.fn().mockReturnValue({ valid: true });
|
||||
|
||||
const message = {
|
||||
guild: {},
|
||||
author: {
|
||||
bot: false,
|
||||
},
|
||||
content: "!test first",
|
||||
} as unknown as Message;
|
||||
|
||||
const events = new Events();
|
||||
|
||||
const result = events.onMessage(message);
|
||||
|
||||
expect(result.valid).toBeTruthy();
|
||||
|
||||
expect(result.context?.prefix).toBe('!');
|
||||
expect(result.context?.name).toBe('test');
|
||||
expect(result.context?.args.length).toBe(1);
|
||||
expect(result.context?.args[0]).toBe('first');
|
||||
expect(result.context?.message).toBe(message);
|
||||
});
|
||||
|
||||
test('Given Guild Is Null, Expect Failed Result', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
Util.prototype.loadCommand = jest.fn().mockReturnValue({ valid: true });
|
||||
|
||||
const message = {
|
||||
guild: null,
|
||||
author: {
|
||||
bot: false,
|
||||
},
|
||||
content: "!test first",
|
||||
} as unknown as Message;
|
||||
|
||||
const events = new Events();
|
||||
|
||||
const result = 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', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
Util.prototype.loadCommand = jest.fn().mockReturnValue({ valid: true });
|
||||
|
||||
const message = {
|
||||
guild: {},
|
||||
author: {
|
||||
bot: true,
|
||||
},
|
||||
content: "!test first",
|
||||
} as unknown as Message;
|
||||
|
||||
const events = new Events();
|
||||
|
||||
const result = 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', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
Util.prototype.loadCommand = jest.fn().mockReturnValue({ valid: true });
|
||||
|
||||
const message = {
|
||||
guild: {},
|
||||
author: {
|
||||
bot: false,
|
||||
},
|
||||
content: "This is a standard message",
|
||||
} as unknown as Message;
|
||||
|
||||
const events = new Events();
|
||||
|
||||
const result = 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', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
Util.prototype.loadCommand = jest.fn().mockReturnValue({ valid: true });
|
||||
|
||||
const message = {
|
||||
guild: {},
|
||||
author: {
|
||||
bot: false,
|
||||
},
|
||||
content: "!",
|
||||
} as unknown as Message;
|
||||
|
||||
const events = new Events();
|
||||
|
||||
const result = 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', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
Util.prototype.loadCommand = jest.fn().mockReturnValue({ valid: false, message: "Command failed" });
|
||||
|
||||
const message = {
|
||||
guild: {},
|
||||
author: {
|
||||
bot: false,
|
||||
},
|
||||
content: "!test first",
|
||||
} as unknown as Message;
|
||||
|
||||
const events = new Events();
|
||||
|
||||
const result = events.onMessage(message);
|
||||
|
||||
expect(result.valid).toBeFalsy();
|
||||
expect(result.message).toBe("Command failed");
|
||||
});
|
||||
});
|
||||
|
||||
test('OnMessage_GivenGuildIsNull_ExpectFailedResult', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
Util.prototype.loadCommand = jest.fn().mockReturnValue({ valid: true });
|
||||
|
||||
const message = {
|
||||
guild: null,
|
||||
author: {
|
||||
bot: false,
|
||||
},
|
||||
content: "!test first",
|
||||
} as unknown as Message;
|
||||
|
||||
const events = new Events();
|
||||
|
||||
const result = events.onMessage(message);
|
||||
|
||||
expect(result.valid).toBeFalsy();
|
||||
expect(result.message).toBe("Message was not sent in a guild, ignoring.");
|
||||
});
|
||||
|
||||
test('OnMessage_GivenAuthorIsBot_ExpectFailedResult', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
Util.prototype.loadCommand = jest.fn().mockReturnValue({ valid: true });
|
||||
|
||||
const message = {
|
||||
guild: {},
|
||||
author: {
|
||||
bot: true,
|
||||
},
|
||||
content: "!test first",
|
||||
} as unknown as Message;
|
||||
|
||||
const events = new Events();
|
||||
|
||||
const result = events.onMessage(message);
|
||||
|
||||
expect(result.valid).toBeFalsy();
|
||||
expect(result.message).toBe("Message was sent by a bot, ignoring.");
|
||||
});
|
||||
|
||||
test('OnMessage_GivenMessageContentsWasNotACommand_ExpectFailedResult', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
Util.prototype.loadCommand = jest.fn().mockReturnValue({ valid: true });
|
||||
|
||||
const message = {
|
||||
guild: {},
|
||||
author: {
|
||||
bot: false,
|
||||
},
|
||||
content: "This is a standard message",
|
||||
} as unknown as Message;
|
||||
|
||||
const events = new Events();
|
||||
|
||||
const result = events.onMessage(message);
|
||||
|
||||
expect(result.valid).toBeFalsy();
|
||||
expect(result.message).toBe("Message was not a command, ignoring.");
|
||||
});
|
||||
|
||||
test('OnMessage_GivenMessageHadNoCommandName_ExpectFailedResult', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
Util.prototype.loadCommand = jest.fn().mockReturnValue({ valid: true });
|
||||
|
||||
const message = {
|
||||
guild: {},
|
||||
author: {
|
||||
bot: false,
|
||||
},
|
||||
content: "!",
|
||||
} as unknown as Message;
|
||||
|
||||
const events = new Events();
|
||||
|
||||
const result = events.onMessage(message);
|
||||
|
||||
expect(result.valid).toBeFalsy();
|
||||
expect(result.message).toBe("Command name was not found");
|
||||
});
|
||||
|
||||
test('OnMessage_GivenCommandFailedToExecute_ExpectFailedResult', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
Util.prototype.loadCommand = jest.fn().mockReturnValue({ valid: false, message: "Command failed" });
|
||||
|
||||
const message = {
|
||||
guild: {},
|
||||
author: {
|
||||
bot: false,
|
||||
},
|
||||
content: "!test first",
|
||||
} as unknown as Message;
|
||||
|
||||
const events = new Events();
|
||||
|
||||
const result = events.onMessage(message);
|
||||
|
||||
expect(result.valid).toBeFalsy();
|
||||
expect(result.message).toBe("Command failed");
|
||||
});
|
||||
|
||||
test('OnReady_ExpectConsoleLog', () => {
|
||||
console.log = jest.fn();
|
||||
|
||||
const events = new Events();
|
||||
|
||||
events.onReady();
|
||||
|
||||
expect(console.log).toBeCalledWith("Ready");
|
||||
describe('OnReady', () => {
|
||||
test('Expect Console Log', () => {
|
||||
console.log = jest.fn();
|
||||
|
||||
const events = new Events();
|
||||
|
||||
events.onReady();
|
||||
|
||||
expect(console.log).toBeCalledWith("Ready");
|
||||
});
|
||||
});
|
|
@ -9,100 +9,18 @@ beforeEach(() => {
|
|||
fs.existsSync = jest.fn();
|
||||
});
|
||||
|
||||
test('LoadCommand_GivenSuccessfulExection_ExpectSuccessfulResult', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
describe('LoadCommand', () => {
|
||||
test('Given Successful Exection, Expect Successful Result', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValue(true);
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValue(true);
|
||||
|
||||
const message = {
|
||||
member: {
|
||||
roles: {
|
||||
cache: {
|
||||
find: jest.fn().mockReturnValue(true),
|
||||
}
|
||||
},
|
||||
},
|
||||
reply: jest.fn(),
|
||||
} as unknown as Message;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = util.loadCommand("normal", [ "first" ], message);
|
||||
|
||||
expect(result.valid).toBeTruthy();
|
||||
});
|
||||
|
||||
test('LoadCommand_GivenMemberIsNull_ExpectFailedResult', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValue(true);
|
||||
|
||||
const message = {
|
||||
member: null
|
||||
} as unknown as Message;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = util.loadCommand("normal", [ "first" ], message);
|
||||
|
||||
expect(result.valid).toBeFalsy();
|
||||
expect(result.message).toBe("Member is not part of message");
|
||||
});
|
||||
|
||||
test('LoadCommand_GivenFolderDoesNotExist_ExpectFailedResult', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValue(false);
|
||||
|
||||
const message = {
|
||||
member: {
|
||||
roles: {
|
||||
cache: {
|
||||
find: jest.fn().mockReturnValue(true),
|
||||
}
|
||||
},
|
||||
},
|
||||
reply: jest.fn(),
|
||||
} as unknown as Message;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = util.loadCommand("normal", [ "first" ], message);
|
||||
|
||||
expect(result.valid).toBeFalsy();
|
||||
expect(result.message).toBe("Command folder does not exist");
|
||||
});
|
||||
|
||||
test('LoadCommand_GivenFileDoesNotExist_ExpectFailedResult', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValueOnce(true)
|
||||
.mockReturnValue(false);
|
||||
|
||||
const message = {
|
||||
member: {
|
||||
roles: {
|
||||
|
@ -113,175 +31,261 @@ test('LoadCommand_GivenFileDoesNotExist_ExpectFailedResult', () => {
|
|||
},
|
||||
reply: jest.fn(),
|
||||
} as unknown as Message;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = util.loadCommand("normal", [ "first" ], message);
|
||||
|
||||
expect(result.valid).toBeFalsy();
|
||||
expect(result.message).toBe("File does not exist");
|
||||
});
|
||||
|
||||
test('LoadCommand_GivenUserDoesHaveRole_ExpectSuccessfulResult', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValue(true);
|
||||
|
||||
const message = {
|
||||
member: {
|
||||
roles: {
|
||||
cache: {
|
||||
find: jest.fn().mockReturnValue(true),
|
||||
}
|
||||
},
|
||||
},
|
||||
reply: jest.fn(),
|
||||
} as unknown as Message;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = util.loadCommand("roles", [ "first" ], message);
|
||||
|
||||
expect(result.valid).toBeTruthy();
|
||||
});
|
||||
|
||||
test('LoadCommand_GivenUserDoesNotHaveRole_ExpectFailedResult', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
const util = new Util();
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValue(true);
|
||||
|
||||
const message = {
|
||||
member: {
|
||||
roles: {
|
||||
cache: {
|
||||
find: jest.fn().mockReturnValue(false),
|
||||
}
|
||||
},
|
||||
},
|
||||
reply: jest.fn(),
|
||||
} as unknown as Message;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = util.loadCommand("roles", [ "first" ], message);
|
||||
|
||||
expect(result.valid).toBeFalsy();
|
||||
expect(result.message).toBe("You require the `Moderator` role to run this command");
|
||||
});
|
||||
|
||||
test('LoadCommand_GivenCommandCategoryIsNull_ExpectSuccessfulResultStill', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
const result = util.loadCommand("normal", [ "first" ], message);
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValue(true);
|
||||
|
||||
const message = {
|
||||
member: {
|
||||
roles: {
|
||||
cache: {
|
||||
find: jest.fn().mockReturnValue(true),
|
||||
}
|
||||
expect(result.valid).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Given Member Is Null, Expect Failed Result', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValue(true);
|
||||
|
||||
const message = {
|
||||
member: null
|
||||
} as unknown as Message;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = 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', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValue(false);
|
||||
|
||||
const message = {
|
||||
member: {
|
||||
roles: {
|
||||
cache: {
|
||||
find: jest.fn().mockReturnValue(true),
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
reply: jest.fn(),
|
||||
} as unknown as Message;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = util.loadCommand("noCategory", [ "first" ], message);
|
||||
|
||||
expect(result.valid).toBeTruthy();
|
||||
reply: jest.fn(),
|
||||
} as unknown as Message;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = 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', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValueOnce(true)
|
||||
.mockReturnValue(false);
|
||||
|
||||
const message = {
|
||||
member: {
|
||||
roles: {
|
||||
cache: {
|
||||
find: jest.fn().mockReturnValue(true),
|
||||
}
|
||||
},
|
||||
},
|
||||
reply: jest.fn(),
|
||||
} as unknown as Message;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = 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', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValue(true);
|
||||
|
||||
const message = {
|
||||
member: {
|
||||
roles: {
|
||||
cache: {
|
||||
find: jest.fn().mockReturnValue(true),
|
||||
}
|
||||
},
|
||||
},
|
||||
reply: jest.fn(),
|
||||
} as unknown as Message;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = util.loadCommand("roles", [ "first" ], message);
|
||||
|
||||
expect(result.valid).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Given User Does Not Have Role, Expect Failed Result', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValue(true);
|
||||
|
||||
const message = {
|
||||
member: {
|
||||
roles: {
|
||||
cache: {
|
||||
find: jest.fn().mockReturnValue(false),
|
||||
}
|
||||
},
|
||||
},
|
||||
reply: jest.fn(),
|
||||
} as unknown as Message;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = 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', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValue(true);
|
||||
|
||||
const message = {
|
||||
member: {
|
||||
roles: {
|
||||
cache: {
|
||||
find: jest.fn().mockReturnValue(true),
|
||||
}
|
||||
},
|
||||
},
|
||||
reply: jest.fn(),
|
||||
} as unknown as Message;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = util.loadCommand("noCategory", [ "first" ], message);
|
||||
|
||||
expect(result.valid).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
test('LoadEvents_GivenEventsAreLoaded_ExpectSuccessfulResult', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValue(true);
|
||||
fs.readdirSync = jest.fn().mockReturnValue(["normal.ts"]);
|
||||
|
||||
const client = {
|
||||
on: jest.fn(),
|
||||
} as unknown as Client;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = util.loadEvents(client);
|
||||
|
||||
const clientOn = jest.spyOn(client, 'on');
|
||||
|
||||
expect(result.valid).toBeTruthy();
|
||||
expect(clientOn).toBeCalledTimes(13);
|
||||
});
|
||||
|
||||
test('LoadEvents_GivenNoEventsFound_ExpectSuccessfulResultStill', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValue(true);
|
||||
fs.readdirSync = jest.fn().mockReturnValue(["normal"]);
|
||||
|
||||
const client = {
|
||||
on: jest.fn(),
|
||||
} as unknown as Client;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = util.loadEvents(client);
|
||||
|
||||
const clientOn = jest.spyOn(client, 'on');
|
||||
|
||||
expect(result.valid).toBeTruthy();
|
||||
expect(clientOn).toBeCalledTimes(0);
|
||||
});
|
||||
|
||||
test('LoadEvents_GivenEventFolderDoesNotExist_FailedResult', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValue(false);
|
||||
fs.readdirSync = jest.fn().mockReturnValue(["normal.ts"]);
|
||||
|
||||
const client = {
|
||||
on: jest.fn(),
|
||||
} as unknown as Client;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = util.loadEvents(client);
|
||||
|
||||
expect(result.valid).toBeFalsy();
|
||||
expect(result.message).toBe("Event folder does not exist");
|
||||
describe('LoadEvents', () => {
|
||||
test('Given Events Are Loaded, Expect Successful Result', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValue(true);
|
||||
fs.readdirSync = jest.fn().mockReturnValue(["normal.ts"]);
|
||||
|
||||
const client = {
|
||||
on: jest.fn(),
|
||||
} as unknown as Client;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = util.loadEvents(client);
|
||||
|
||||
const clientOn = jest.spyOn(client, 'on');
|
||||
|
||||
expect(result.valid).toBeTruthy();
|
||||
expect(clientOn).toBeCalledTimes(13);
|
||||
});
|
||||
|
||||
test('Given No Events Found, Expect Successful Result', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValue(true);
|
||||
fs.readdirSync = jest.fn().mockReturnValue(["normal"]);
|
||||
|
||||
const client = {
|
||||
on: jest.fn(),
|
||||
} as unknown as Client;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = util.loadEvents(client);
|
||||
|
||||
const clientOn = jest.spyOn(client, 'on');
|
||||
|
||||
expect(result.valid).toBeTruthy();
|
||||
expect(clientOn).toBeCalledTimes(0);
|
||||
});
|
||||
|
||||
test('Given Event Folder Does Not Exist, Expect Failed Result', () => {
|
||||
process.env = {
|
||||
BOT_TOKEN: 'TOKEN',
|
||||
BOT_PREFIX: '!',
|
||||
FOLDERS_COMMANDS: 'commands',
|
||||
FOLDERS_EVENTS: 'events',
|
||||
}
|
||||
|
||||
process.cwd = jest.fn().mockReturnValue("../../tests/__mocks");
|
||||
fs.existsSync = jest.fn().mockReturnValue(false);
|
||||
fs.readdirSync = jest.fn().mockReturnValue(["normal.ts"]);
|
||||
|
||||
const client = {
|
||||
on: jest.fn(),
|
||||
} as unknown as Client;
|
||||
|
||||
const util = new Util();
|
||||
|
||||
const result = util.loadEvents(client);
|
||||
|
||||
expect(result.valid).toBeFalsy();
|
||||
expect(result.message).toBe("Event folder does not exist");
|
||||
});
|
||||
});
|
Should these be put into a describe group?
This would apply to all other tests also