Update about tests
This commit is contained in:
parent
5b2c4191da
commit
12168b52c4
4 changed files with 136 additions and 88 deletions
|
@ -4,6 +4,10 @@ import About from "../../src/commands/about";
|
|||
import { ICommandContext } from "../../src/contracts/ICommandContext";
|
||||
import PublicEmbed from "../../src/helpers/embeds/PublicEmbed";
|
||||
|
||||
beforeEach(() => {
|
||||
process.env = {};
|
||||
});
|
||||
|
||||
describe('Constructor', () => {
|
||||
test('Expect values set', () => {
|
||||
const about = new About();
|
||||
|
@ -13,14 +17,15 @@ describe('Constructor', () => {
|
|||
});
|
||||
|
||||
describe('Execute', () => {
|
||||
test('Expect embed to be made and sent to the current channel', (done) => {
|
||||
const message = mock<Message>();
|
||||
message.channel.send = jest.fn().mockImplementation((embed: PublicEmbed) => {
|
||||
expect(embed.title).toBe('About');
|
||||
expect(embed.description).toBe('');
|
||||
test('Expect embed to be made and sent to the current channel', async () => {
|
||||
process.env = {
|
||||
BOT_VER: "BOT_VER",
|
||||
BOT_AUTHOR: "BOT_AUTHOR",
|
||||
BOT_DATE: "BOT_DATE"
|
||||
};
|
||||
|
||||
done();
|
||||
});
|
||||
const message = mock<Message>();
|
||||
message.channel.send = jest.fn();
|
||||
|
||||
const context: ICommandContext = {
|
||||
name: "about",
|
||||
|
@ -29,6 +34,119 @@ describe('Execute', () => {
|
|||
};
|
||||
|
||||
const about = new About();
|
||||
about.execute(context);
|
||||
|
||||
const result = await about.execute(context);
|
||||
|
||||
expect(message.channel.send).toBeCalledTimes(1);
|
||||
});
|
||||
|
||||
test('Expect embed send to have values', async () => {
|
||||
process.env = {
|
||||
BOT_VER: "BOT_VER",
|
||||
BOT_AUTHOR: "BOT_AUTHOR",
|
||||
BOT_DATE: "BOT_DATE"
|
||||
};
|
||||
|
||||
const message = mock<Message>();
|
||||
message.channel.send = jest.fn();
|
||||
|
||||
const context: ICommandContext = {
|
||||
name: "about",
|
||||
args: [],
|
||||
message: message
|
||||
};
|
||||
|
||||
const about = new About();
|
||||
|
||||
const result = await about.execute(context);
|
||||
|
||||
expect(result.embeds.length).toBe(1);
|
||||
|
||||
const embed = result.embeds[0];
|
||||
|
||||
expect(embed.title).toBe('About');
|
||||
expect(embed.description).toBe('');
|
||||
expect(embed.fields.length).toBe(3);
|
||||
});
|
||||
|
||||
test('Expect version field to have values', async () => {
|
||||
process.env = {
|
||||
BOT_VER: "BOT_VER",
|
||||
BOT_AUTHOR: "BOT_AUTHOR",
|
||||
BOT_DATE: "BOT_DATE"
|
||||
};
|
||||
|
||||
const message = mock<Message>();
|
||||
message.channel.send = jest.fn();
|
||||
|
||||
const context: ICommandContext = {
|
||||
name: "about",
|
||||
args: [],
|
||||
message: message
|
||||
};
|
||||
|
||||
const about = new About();
|
||||
|
||||
const result = await about.execute(context);
|
||||
|
||||
const embed = result.embeds[0];
|
||||
const field = embed.fields[0];
|
||||
|
||||
expect(field.name).toBe('Version');
|
||||
expect(field.value).toBe('BOT_VER');
|
||||
});
|
||||
|
||||
test('Expect author field to have values', async () => {
|
||||
process.env = {
|
||||
BOT_VER: "BOT_VER",
|
||||
BOT_AUTHOR: "BOT_AUTHOR",
|
||||
BOT_DATE: "BOT_DATE"
|
||||
};
|
||||
|
||||
const message = mock<Message>();
|
||||
message.channel.send = jest.fn();
|
||||
|
||||
const context: ICommandContext = {
|
||||
name: "about",
|
||||
args: [],
|
||||
message: message
|
||||
};
|
||||
|
||||
const about = new About();
|
||||
|
||||
const result = await about.execute(context);
|
||||
|
||||
const embed = result.embeds[0];
|
||||
const field = embed.fields[1];
|
||||
|
||||
expect(field.name).toBe('Author');
|
||||
expect(field.value).toBe('BOT_AUTHOR');
|
||||
});
|
||||
|
||||
test('Expect version field to have values', async () => {
|
||||
process.env = {
|
||||
BOT_VER: "BOT_VER",
|
||||
BOT_AUTHOR: "BOT_AUTHOR",
|
||||
BOT_DATE: "BOT_DATE"
|
||||
};
|
||||
|
||||
const message = mock<Message>();
|
||||
message.channel.send = jest.fn();
|
||||
|
||||
const context: ICommandContext = {
|
||||
name: "about",
|
||||
args: [],
|
||||
message: message
|
||||
};
|
||||
|
||||
const about = new About();
|
||||
|
||||
const result = await about.execute(context);
|
||||
|
||||
const embed = result.embeds[0];
|
||||
const field = embed.fields[2];
|
||||
|
||||
expect(field.name).toBe('Date');
|
||||
expect(field.value).toBe('BOT_DATE');
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue