Create timeout command #302

Merged
Vylpes merged 16 commits from feature/98-timeout-command into develop 2023-06-16 18:01:46 +01:00
Showing only changes of commit ef18449794 - Show all commits

View file

@ -1,4 +1,4 @@
import { APIEmbed, CommandInteraction, CommandInteractionOption, Embed, Guild, GuildChannel, GuildMember, InteractionReplyOptions, JSONEncodable, SlashCommandBuilder, TextChannel, User } from "discord.js"; import { APIEmbed, CommandInteraction, CommandInteractionOption, Embed, EmbedBuilder, Guild, GuildChannel, GuildMember, InteractionReplyOptions, JSONEncodable, SlashCommandBuilder, TextChannel, User } from "discord.js";
import { mock } from "jest-mock-extended"; import { mock } from "jest-mock-extended";
import Timeout from "../../src/commands/timeout"; import Timeout from "../../src/commands/timeout";
import SettingsHelper from "../../src/helpers/SettingsHelper"; import SettingsHelper from "../../src/helpers/SettingsHelper";
@ -29,7 +29,6 @@ describe('execute', () => {
embeds = options.embeds as APIEmbed[]; embeds = options.embeds as APIEmbed[];
}); });
// SettingsHelper.GetSetting = jest.fn().mockResolvedValue('mod-logs');
const getSetting = jest.spyOn(SettingsHelper, 'GetSetting').mockResolvedValue('mod-logs'); const getSetting = jest.spyOn(SettingsHelper, 'GetSetting').mockResolvedValue('mod-logs');
const auditSave = jest.spyOn(Audit.prototype, 'Save').mockImplementation(); const auditSave = jest.spyOn(Audit.prototype, 'Save').mockImplementation();
@ -91,19 +90,18 @@ describe('execute', () => {
expect(embeds!.length).toBe(1); expect(embeds!.length).toBe(1);
// EXPECT resultEmbed to be correctly configured // EXPECT resultEmbed to be correctly configured
const resultEmbed = embeds![0]; const resultEmbed = embeds![0] as EmbedBuilder;
expect(resultEmbed.description).toBe('<@userId> has been timed out'); expect(resultEmbed.data.description).toBe('<@userId> has been timed out');
expect(resultEmbed.fields).toBeDefined(); expect(resultEmbed.data.fields).toBeDefined();
expect(resultEmbed.fields!.length).toBe(1); expect(resultEmbed.data.fields!.length).toBe(1);
// EXPECT DM field to be configured // EXPECT DM field to be configured
const resultEmbedDMField = resultEmbed.fields![0]; const resultEmbedDMField = resultEmbed.data.fields![0];
expect(resultEmbedDMField.name).toBe("DM Sent"); expect(resultEmbedDMField.name).toBe("DM Sent");
expect(resultEmbedDMField.value).toBe("true"); expect(resultEmbedDMField.value).toBe("true");
// TODO: User was timed out
// TODO: DM Embed check // TODO: DM Embed check
// TODO: Log Embed check // TODO: Log Embed check
// TODO: Audit check // TODO: Audit check