WIP: EFfects List Button Event tests
All checks were successful
Test / build (push) Successful in 30s

This commit is contained in:
Ethan Lane 2025-01-13 17:57:20 +00:00
parent d794b30bb5
commit 6c0b7c6899

View file

@ -1,3 +1,50 @@
test.todo("GIVEN pageOption is NOT a number, EXPECT error");
import { ActionRowBuilder, ButtonBuilder, ButtonInteraction, EmbedBuilder } from "discord.js";
import List from "../../../src/buttonEvents/Effects/List";
import EffectHelper from "../../../src/helpers/EffectHelper";
import { mock } from "jest-mock-extended";
test.todo("GIVEN pageOption is a number, EXPECT interaction updated");
jest.mock("../../../src/helpers/EffectHelper");
let interaction: ReturnType<typeof mock<ButtonInteraction>>;
beforeEach(() => {
jest.resetAllMocks();
(EffectHelper.GenerateEffectEmbed as jest.Mock).mockResolvedValue({
embed: mock<EmbedBuilder>(),
row: mock<ActionRowBuilder<ButtonBuilder>>(),
});
interaction = mock<ButtonInteraction>();
interaction.user.id = "userId";
interaction.customId = "effects list 1";
});
test("GIVEN pageOption is NOT a number, EXPECT error", async () => {
// Arrange
interaction.customId = "effects list invalid";
// Act
await List(interaction);
// Assert
expect(interaction.reply).toHaveBeenCalledTimes(1);
expect(interaction.reply).toHaveBeenCalledWith("Page option is not a valid number")
expect(EffectHelper.GenerateEffectEmbed).not.toHaveBeenCalled();
expect(interaction.update).not.toHaveBeenCalled();
});
test("GIVEN pageOption is a number, EXPECT interaction updated", async () => {
// Arrange
interaction.customId = "effects list 1";
// Act
await List(interaction);
// Assert
expect(EffectHelper.GenerateEffectEmbed).toHaveBeenCalledTimes(1);
expect(EffectHelper.GenerateEffectEmbed).toHaveBeenCalledWith("userId", 1);
expect(interaction.update).toHaveBeenCalledTimes(1);
});