From ef18449794f515000886bf825b48ed3e412fd197 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sun, 2 Apr 2023 15:32:58 +0100 Subject: [PATCH] Fix test not detecting embed description --- tests/commands/timeout.test.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/commands/timeout.test.ts b/tests/commands/timeout.test.ts index 966ddf2..721b257 100644 --- a/tests/commands/timeout.test.ts +++ b/tests/commands/timeout.test.ts @@ -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 Timeout from "../../src/commands/timeout"; import SettingsHelper from "../../src/helpers/SettingsHelper"; @@ -29,7 +29,6 @@ describe('execute', () => { embeds = options.embeds as APIEmbed[]; }); - // SettingsHelper.GetSetting = jest.fn().mockResolvedValue('mod-logs'); const getSetting = jest.spyOn(SettingsHelper, 'GetSetting').mockResolvedValue('mod-logs'); const auditSave = jest.spyOn(Audit.prototype, 'Save').mockImplementation(); @@ -91,19 +90,18 @@ describe('execute', () => { expect(embeds!.length).toBe(1); // 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.fields).toBeDefined(); - expect(resultEmbed.fields!.length).toBe(1); + expect(resultEmbed.data.description).toBe('<@userId> has been timed out'); + expect(resultEmbed.data.fields).toBeDefined(); + expect(resultEmbed.data.fields!.length).toBe(1); // 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.value).toBe("true"); - // TODO: User was timed out // TODO: DM Embed check // TODO: Log Embed check // TODO: Audit check