This commit is contained in:
parent
983195c477
commit
2bf961d1e5
32 changed files with 88 additions and 106 deletions
|
@ -1,8 +1,8 @@
|
|||
import { CommandInteraction } from "../../__types__/discord.js";
|
||||
import { ChatInputCommandInteraction } from "../../__types__/discord.js";
|
||||
|
||||
export default function GenerateCommandInteractionMock(options?: {
|
||||
subcommand?: string,
|
||||
}): CommandInteraction {
|
||||
}): ChatInputCommandInteraction{
|
||||
return {
|
||||
deferReply: jest.fn(),
|
||||
editReply: jest.fn(),
|
||||
|
|
|
@ -18,7 +18,7 @@ export type ButtonInteraction = {
|
|||
reply: jest.Func,
|
||||
}
|
||||
|
||||
export type CommandInteraction = {
|
||||
export type ChatInputCommandInteraction = {
|
||||
deferReply: jest.Func,
|
||||
editReply: jest.Func,
|
||||
isChatInputCommand: jest.Func,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { CommandInteraction } from "discord.js";
|
||||
import { ChatInputCommandInteraction } from "discord.js";
|
||||
import Drop from "../../src/commands/drop";
|
||||
import GenerateCommandInteractionMock from "../__functions__/discord.js/GenerateCommandInteractionMock";
|
||||
import { CommandInteraction as CommandInteractionMock } from "../__types__/discord.js";
|
||||
import { ChatInputCommandInteraction as ChatInputCommandInteractionMock } from "../__types__/discord.js";
|
||||
import { CoreClient } from "../../src/client/client";
|
||||
import Config from "../../src/database/entities/app/Config";
|
||||
import User from "../../src/database/entities/app/User";
|
||||
|
@ -25,7 +25,7 @@ beforeEach(() => {
|
|||
|
||||
describe("execute", () => {
|
||||
describe("GIVEN user is in the database", () => {
|
||||
let interaction: CommandInteractionMock;
|
||||
let interaction: ChatInputCommandInteractionMock;
|
||||
let user: User;
|
||||
const randomCard = {
|
||||
card: {
|
||||
|
@ -62,7 +62,7 @@ describe("execute", () => {
|
|||
|
||||
// Act
|
||||
const drop = new Drop();
|
||||
await drop.execute(interaction as unknown as CommandInteraction);
|
||||
await drop.execute(interaction as unknown as ChatInputCommandInteraction);
|
||||
});
|
||||
|
||||
test("EXPECT user to be fetched", () => {
|
||||
|
|
|
@ -4,7 +4,7 @@ import Use from "../../src/commands/effects/Use";
|
|||
import Buy from "../../src/commands/effects/Buy";
|
||||
import AppLogger from "../../src/client/appLogger";
|
||||
import GenerateCommandInteractionMock from "../__functions__/discord.js/GenerateCommandInteractionMock";
|
||||
import { CommandInteraction } from "discord.js";
|
||||
import { ChatInputCommandInteraction } from "discord.js";
|
||||
|
||||
jest.mock("../../src/commands/effects/List");
|
||||
jest.mock("../../src/commands/effects/Use");
|
||||
|
@ -32,7 +32,7 @@ describe("execute", () => {
|
|||
|
||||
// Act
|
||||
const effects = new Effects();
|
||||
await effects.execute(interaction as unknown as CommandInteraction);
|
||||
await effects.execute(interaction as unknown as ChatInputCommandInteraction);
|
||||
|
||||
// Assert
|
||||
expect(List).toHaveBeenCalledTimes(1);
|
||||
|
@ -52,7 +52,7 @@ describe("execute", () => {
|
|||
|
||||
// Act
|
||||
const effects = new Effects();
|
||||
await effects.execute(interaction as unknown as CommandInteraction);
|
||||
await effects.execute(interaction as unknown as ChatInputCommandInteraction);
|
||||
|
||||
// Assert
|
||||
expect(Use).toHaveBeenCalledTimes(1);
|
||||
|
@ -72,7 +72,7 @@ describe("execute", () => {
|
|||
|
||||
// Act
|
||||
const effects = new Effects();
|
||||
await effects.execute(interaction as unknown as CommandInteraction);
|
||||
await effects.execute(interaction as unknown as ChatInputCommandInteraction);
|
||||
|
||||
// Assert
|
||||
expect(Buy).toHaveBeenCalledTimes(1);
|
||||
|
@ -92,7 +92,7 @@ describe("execute", () => {
|
|||
|
||||
// Act
|
||||
const effects = new Effects();
|
||||
await effects.execute(interaction as unknown as CommandInteraction);
|
||||
await effects.execute(interaction as unknown as ChatInputCommandInteraction);
|
||||
|
||||
// Assert
|
||||
expect(AppLogger.LogError).toHaveBeenCalledTimes(1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue