Fix linting
All checks were successful
Test / build (push) Successful in 15s

This commit is contained in:
Ethan Lane 2024-12-06 18:08:15 +00:00
parent 0584d0304b
commit 7429500540
3 changed files with 36 additions and 22 deletions

View file

@ -4,17 +4,17 @@ import EffectHelper from "../../src/helpers/EffectHelper";
describe("execute", () => { describe("execute", () => {
describe("GIVEN action in custom id is list", () => { describe("GIVEN action in custom id is list", () => {
let interaction = { const interaction = {
customId: "effects list", customId: "effects list",
} as unknown as ButtonInteraction; } as unknown as ButtonInteraction;
let listSpy: any; let listSpy: jest.SpyInstance;
beforeAll(async () => { beforeAll(async () => {
const effects = new Effects(); const effects = new Effects();
listSpy = jest.spyOn(effects as any, "List") listSpy = jest.spyOn(effects as unknown as {"List": () => object}, "List")
.mockImplementation(() => {}); .mockImplementation();
await effects.execute(interaction); await effects.execute(interaction);
}); });
@ -27,7 +27,7 @@ describe("execute", () => {
}); });
describe("List", () => { describe("List", () => {
let interaction: any; let interaction: ButtonInteraction;
const embed = { const embed = {
name: "Embed", name: "Embed",
@ -45,7 +45,7 @@ describe("List", () => {
}, },
update: jest.fn(), update: jest.fn(),
reply: jest.fn(), reply: jest.fn(),
}; } as unknown as ButtonInteraction;
}); });
describe("GIVEN page is a valid number", () => { describe("GIVEN page is a valid number", () => {

View file

@ -1,3 +1,4 @@
import {ChatInputCommandInteraction} from "discord.js";
import Effects from "../../src/commands/effects"; import Effects from "../../src/commands/effects";
import EffectHelper from "../../src/helpers/EffectHelper"; import EffectHelper from "../../src/helpers/EffectHelper";
@ -15,18 +16,18 @@ describe("constructor", () => {
describe("execute", () => { describe("execute", () => {
describe("GIVEN interaction is not a chat input command", () => { describe("GIVEN interaction is not a chat input command", () => {
let interaction: any; let interaction: ChatInputCommandInteraction;
let listSpy: any; let listSpy: jest.SpyInstance;
beforeEach(async () => { beforeEach(async () => {
interaction = { interaction = {
isChatInputCommand: jest.fn().mockReturnValue(false), isChatInputCommand: jest.fn().mockReturnValue(false),
}; } as unknown as ChatInputCommandInteraction;
const effects = new Effects(); const effects = new Effects();
listSpy = jest.spyOn(effects as any, "List") listSpy = jest.spyOn(effects as unknown as {"List": () => object}, "List")
.mockImplementation(); .mockImplementation();
await effects.execute(interaction); await effects.execute(interaction);
@ -42,9 +43,9 @@ describe("execute", () => {
}); });
describe("GIVEN subcommand is list", () => { describe("GIVEN subcommand is list", () => {
let interaction: any; let interaction: ChatInputCommandInteraction;
let listSpy: any; let listSpy: jest.SpyInstance;
beforeEach(async () => { beforeEach(async () => {
interaction = { interaction = {
@ -52,11 +53,11 @@ describe("execute", () => {
options: { options: {
getSubcommand: jest.fn().mockReturnValue("list"), getSubcommand: jest.fn().mockReturnValue("list"),
}, },
}; } as unknown as ChatInputCommandInteraction;
const effects = new Effects(); const effects = new Effects();
listSpy = jest.spyOn(effects as any, "List") listSpy = jest.spyOn(effects as unknown as {"List": () => object}, "List")
.mockImplementation(); .mockImplementation();
await effects.execute(interaction); await effects.execute(interaction);
@ -74,8 +75,8 @@ describe("execute", () => {
}); });
describe("List", () => { describe("List", () => {
let effects: Effects = new Effects(); const effects: Effects = new Effects();
let interaction: any; let interaction: ChatInputCommandInteraction;
const embed = { const embed = {
name: "embed", name: "embed",
@ -95,7 +96,7 @@ describe("List", () => {
user: { user: {
id: "userId", id: "userId",
}, },
}; } as unknown as ChatInputCommandInteraction;
const effects = new Effects(); const effects = new Effects();
@ -104,7 +105,7 @@ describe("List", () => {
row, row,
}); });
jest.spyOn(effects as any, "List") jest.spyOn(effects as unknown as {"List": () => object}, "List")
.mockImplementation(); .mockImplementation();
}); });

View file

@ -1,3 +1,4 @@
import {ActionRowBuilder, ButtonBuilder, EmbedBuilder} from "discord.js";
import UserEffect from "../../src/database/entities/app/UserEffect"; import UserEffect from "../../src/database/entities/app/UserEffect";
import EffectHelper from "../../src/helpers/EffectHelper"; import EffectHelper from "../../src/helpers/EffectHelper";
@ -297,7 +298,10 @@ describe("GenerateEffectEmbed", () => {
}); });
describe("GIVEN there are no effects returned", () => { describe("GIVEN there are no effects returned", () => {
let result: any; let result: {
embed: EmbedBuilder,
row: ActionRowBuilder<ButtonBuilder>,
};
beforeEach(async () => { beforeEach(async () => {
UserEffect.FetchAllByUserIdPaginated = jest.fn() UserEffect.FetchAllByUserIdPaginated = jest.fn()
@ -315,7 +319,10 @@ describe("GenerateEffectEmbed", () => {
}); });
describe("GIVEN there are effects returned", () => { describe("GIVEN there are effects returned", () => {
let result: any; let result: {
embed: EmbedBuilder,
row: ActionRowBuilder<ButtonBuilder>,
};
beforeEach(async () => { beforeEach(async () => {
UserEffect.FetchAllByUserIdPaginated = jest.fn() UserEffect.FetchAllByUserIdPaginated = jest.fn()
@ -342,7 +349,10 @@ describe("GenerateEffectEmbed", () => {
}); });
test("EXPECT Previous button to be disabled", () => { test("EXPECT Previous button to be disabled", () => {
const button = result.row.components[0].data; const button = result.row.components[0].data as unknown as {
label: string,
disabled: boolean
};
expect(button).toBeDefined(); expect(button).toBeDefined();
expect(button.label).toBe("Previous"); expect(button.label).toBe("Previous");
@ -356,7 +366,10 @@ describe("GenerateEffectEmbed", () => {
}); });
test("EXPECT Next button to be disabled", () => { test("EXPECT Next button to be disabled", () => {
const button = result.row.components[1].data; const button = result.row.components[1].data as unknown as {
label: string,
disabled: boolean
};
expect(button).toBeDefined(); expect(button).toBeDefined();
expect(button.label).toBe("Next"); expect(button.label).toBe("Next");