vylbot-app/tests/helpers/embeds/ErrorEmbed.test.ts
Vylpes f61c4c728a
Feature/12 create tests (#102)
* Fix tests

* Update coverage

* Remove unrequired mock files

* Add about command test

* Update about tests

* Ban command tests

* eval command tests

* Start help command tests

* Add help command tests

* Add kick command tests

* Mute command tests

* Poll command tests

* Add role command tests

Signed-off-by: Ethan Lane <ethan@vylpes.com>

* Add rules command tests

* Add unmute command tests

* Add warn command tests

* Add MemberEvents tests

* Add GuildMemberUpdate tests

Signed-off-by: Ethan Lane <ethan@vylpes.com>

* Add MessageEvents tests

* Add StringTools test

Signed-off-by: Ethan Lane <ethan@vylpes.com>

* Add embed tests

Signed-off-by: Ethan Lane <ethan@vylpes.com>

* Add GitHub Actions

Signed-off-by: Ethan Lane <ethan@vylpes.com>

* Move to tslint

Signed-off-by: Ethan Lane <ethan@vylpes.com>

* Remove tslint

Signed-off-by: Ethan Lane <ethan@vylpes.com>

* Remove linting script

Signed-off-by: Ethan Lane <ethan@vylpes.com>
2022-01-30 17:03:36 +00:00

57 lines
1.5 KiB
TypeScript

import { Message } from "discord.js";
import { ICommandContext } from "../../../src/contracts/ICommandContext";
import ErrorEmbed from "../../../src/helpers/embeds/ErrorEmbed";
beforeEach(() => {
process.env = {};
});
describe('Constructor', () => {
test('Expect properties to be set', () => {
process.env = {
EMBED_COLOUR_ERROR: '0xd52803'
}
const message = {} as unknown as Message;
const context: ICommandContext = {
name: 'command',
args: [],
message: message
};
const errorEmbed = new ErrorEmbed(context, 'Error Message');
expect(errorEmbed.color?.toString()).toBe('13969411'); // 0xd52803 in decimal
expect(errorEmbed.description).toBe('Error Message');
expect(errorEmbed.context).toBe(context);
});
});
describe('SendToCurrentChannel', () => {
test('Expect embed to be sent to the current channel in context', () => {
process.env = {
EMBED_COLOUR_ERROR: '0xd52803'
}
const messageChannelSend = jest.fn();
const message = {
channel: {
send: messageChannelSend
}
} as unknown as Message;
const context: ICommandContext = {
name: 'command',
args: [],
message: message
};
const errorEmbed = new ErrorEmbed(context, 'Error Message');
errorEmbed.SendToCurrentChannel();
expect(messageChannelSend).toBeCalledWith(errorEmbed);
});
});