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("GIVEN action in custom id is list", () => {
let interaction = {
const interaction = {
customId: "effects list",
} as unknown as ButtonInteraction;
let listSpy: any;
let listSpy: jest.SpyInstance;
beforeAll(async () => {
const effects = new Effects();
listSpy = jest.spyOn(effects as any, "List")
.mockImplementation(() => {});
listSpy = jest.spyOn(effects as unknown as {"List": () => object}, "List")
.mockImplementation();
await effects.execute(interaction);
});
@ -27,7 +27,7 @@ describe("execute", () => {
});
describe("List", () => {
let interaction: any;
let interaction: ButtonInteraction;
const embed = {
name: "Embed",
@ -45,7 +45,7 @@ describe("List", () => {
},
update: jest.fn(),
reply: jest.fn(),
};
} as unknown as ButtonInteraction;
});
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 EffectHelper from "../../src/helpers/EffectHelper";
@ -15,18 +16,18 @@ describe("constructor", () => {
describe("execute", () => {
describe("GIVEN interaction is not a chat input command", () => {
let interaction: any;
let interaction: ChatInputCommandInteraction;
let listSpy: any;
let listSpy: jest.SpyInstance;
beforeEach(async () => {
interaction = {
isChatInputCommand: jest.fn().mockReturnValue(false),
};
} as unknown as ChatInputCommandInteraction;
const effects = new Effects();
listSpy = jest.spyOn(effects as any, "List")
listSpy = jest.spyOn(effects as unknown as {"List": () => object}, "List")
.mockImplementation();
await effects.execute(interaction);
@ -42,9 +43,9 @@ describe("execute", () => {
});
describe("GIVEN subcommand is list", () => {
let interaction: any;
let interaction: ChatInputCommandInteraction;
let listSpy: any;
let listSpy: jest.SpyInstance;
beforeEach(async () => {
interaction = {
@ -52,11 +53,11 @@ describe("execute", () => {
options: {
getSubcommand: jest.fn().mockReturnValue("list"),
},
};
} as unknown as ChatInputCommandInteraction;
const effects = new Effects();
listSpy = jest.spyOn(effects as any, "List")
listSpy = jest.spyOn(effects as unknown as {"List": () => object}, "List")
.mockImplementation();
await effects.execute(interaction);
@ -74,8 +75,8 @@ describe("execute", () => {
});
describe("List", () => {
let effects: Effects = new Effects();
let interaction: any;
const effects: Effects = new Effects();
let interaction: ChatInputCommandInteraction;
const embed = {
name: "embed",
@ -95,7 +96,7 @@ describe("List", () => {
user: {
id: "userId",
},
};
} as unknown as ChatInputCommandInteraction;
const effects = new Effects();
@ -104,7 +105,7 @@ describe("List", () => {
row,
});
jest.spyOn(effects as any, "List")
jest.spyOn(effects as unknown as {"List": () => object}, "List")
.mockImplementation();
});

View file

@ -1,3 +1,4 @@
import {ActionRowBuilder, ButtonBuilder, EmbedBuilder} from "discord.js";
import UserEffect from "../../src/database/entities/app/UserEffect";
import EffectHelper from "../../src/helpers/EffectHelper";
@ -297,7 +298,10 @@ describe("GenerateEffectEmbed", () => {
});
describe("GIVEN there are no effects returned", () => {
let result: any;
let result: {
embed: EmbedBuilder,
row: ActionRowBuilder<ButtonBuilder>,
};
beforeEach(async () => {
UserEffect.FetchAllByUserIdPaginated = jest.fn()
@ -315,7 +319,10 @@ describe("GenerateEffectEmbed", () => {
});
describe("GIVEN there are effects returned", () => {
let result: any;
let result: {
embed: EmbedBuilder,
row: ActionRowBuilder<ButtonBuilder>,
};
beforeEach(async () => {
UserEffect.FetchAllByUserIdPaginated = jest.fn()
@ -342,7 +349,10 @@ describe("GenerateEffectEmbed", () => {
});
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.label).toBe("Previous");
@ -356,7 +366,10 @@ describe("GenerateEffectEmbed", () => {
});
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.label).toBe("Next");