From aaa6618fa5fb65d8c26e69d6057d7d405ab36d0d Mon Sep 17 00:00:00 2001 From: Sam Gaus Date: Wed, 22 May 2024 16:32:41 +0100 Subject: [PATCH] Maybe fix up mocked imports --- packages/oaf/src/commands/kol/announcement.ts | 2 +- packages/oaf/src/commands/kol/leaderboard.ts | 2 +- packages/oaf/src/greenbox.ts | 2 +- packages/oaf/src/things/Effect.test.ts | 10 +++++----- packages/oaf/src/things/Familiar.test.ts | 10 +++++----- packages/oaf/src/things/Item.test.ts | 14 +++++++------- packages/oaf/src/things/Skill.test.ts | 11 +++++------ 7 files changed, 25 insertions(+), 26 deletions(-) diff --git a/packages/oaf/src/commands/kol/announcement.ts b/packages/oaf/src/commands/kol/announcement.ts index e6eebb5..72456b1 100644 --- a/packages/oaf/src/commands/kol/announcement.ts +++ b/packages/oaf/src/commands/kol/announcement.ts @@ -1,5 +1,5 @@ import { Events, ThreadAutoArchiveDuration, blockQuote } from "discord.js"; -import { KoLMessage } from "kol.js"; +import { type KoLMessage } from "kol.js"; import { dedent } from "ts-dedent"; import { discordClient } from "../../clients/discord.js"; diff --git a/packages/oaf/src/commands/kol/leaderboard.ts b/packages/oaf/src/commands/kol/leaderboard.ts index 9b02553..f627ea7 100644 --- a/packages/oaf/src/commands/kol/leaderboard.ts +++ b/packages/oaf/src/commands/kol/leaderboard.ts @@ -5,7 +5,7 @@ import { TimestampStyles, time, } from "discord.js"; -import { SubboardInfo } from "kol.js"; +import { type SubboardInfo } from "kol.js"; import { createEmbed } from "../../clients/discord.js"; import { kolClient } from "../../clients/kol.js"; diff --git a/packages/oaf/src/greenbox.ts b/packages/oaf/src/greenbox.ts index 3f7ff6f..8c9d860 100644 --- a/packages/oaf/src/greenbox.ts +++ b/packages/oaf/src/greenbox.ts @@ -1,4 +1,4 @@ -import { KoLMessage } from "kol.js"; +import { type KoLMessage } from "kol.js"; import { isRecordNotFoundError, prisma } from "./clients/database.js"; import { kolClient } from "./clients/kol.js"; diff --git a/packages/oaf/src/things/Effect.test.ts b/packages/oaf/src/things/Effect.test.ts index ff194cb..332b0d6 100644 --- a/packages/oaf/src/things/Effect.test.ts +++ b/packages/oaf/src/things/Effect.test.ts @@ -6,11 +6,11 @@ import { Monster } from "./Monster.js"; const blueText = vi.hoisted(() => vi.fn().mockResolvedValue({ blueText: "" })); -vi.mock("kol.js", async () => ({ - Client: class { - getEffectDescription = blueText; - }, -})); +vi.mock("kol.js", async (importOriginal) => { + const koljs = await importOriginal(); + koljs.Client.prototype.getEffectDescription = blueText; + return koljs; +}); describe("Effect descriptions", () => { test("Can describe an Effect", async () => { diff --git a/packages/oaf/src/things/Familiar.test.ts b/packages/oaf/src/things/Familiar.test.ts index c56242a..c54978b 100644 --- a/packages/oaf/src/things/Familiar.test.ts +++ b/packages/oaf/src/things/Familiar.test.ts @@ -6,11 +6,11 @@ import { Item } from "./Item.js"; const blueText = vi.hoisted(() => vi.fn().mockResolvedValue({ blueText: "" })); -vi.mock("kol.js", async () => ({ - Client: class { - getItemDescription = blueText; - }, -})); +vi.mock("kol.js", async (importOriginal) => { + const koljs = await importOriginal(); + koljs.Client.prototype.getItemDescription = blueText; + return koljs; +}); test("Can describe a Familiar", async () => { const familiar = Familiar.from( diff --git a/packages/oaf/src/things/Item.test.ts b/packages/oaf/src/things/Item.test.ts index 482a11b..bc53296 100644 --- a/packages/oaf/src/things/Item.test.ts +++ b/packages/oaf/src/things/Item.test.ts @@ -15,13 +15,13 @@ const { mallPrice, blueText } = vi.hoisted(() => ({ }), })); -vi.mock("kol.js", async () => ({ - Client: class { - getItemDescription = blueText; - getMallPrice = mallPrice; - isRollover = () => false; - }, -})); +vi.mock("kol.js", async (importOriginal) => { + const koljs = await importOriginal(); + koljs.Client.prototype.getItemDescription = blueText; + koljs.Client.prototype.getMallPrice = mallPrice; + koljs.Client.prototype.isRollover = () => false; + return koljs; +}); describe("Food", () => { test("Can describe a food with a range of adventures", async () => { diff --git a/packages/oaf/src/things/Skill.test.ts b/packages/oaf/src/things/Skill.test.ts index 807a451..8c6dc99 100644 --- a/packages/oaf/src/things/Skill.test.ts +++ b/packages/oaf/src/things/Skill.test.ts @@ -5,12 +5,11 @@ import { Skill } from "./Skill.js"; const blueText = vi.hoisted(() => vi.fn().mockResolvedValue({ blueText: "" })); -vi.mock("kol.js", async () => ({ - Client: class { - getSkillDescription = blueText; - }, -})); - +vi.mock("kol.js", async (importOriginal) => { + const koljs = await importOriginal(); + koljs.Client.prototype.getSkillDescription = blueText; + return koljs; +}); test("Can describe a Skill with no bluetext", async () => { const skill = Skill.from( "7017 Overload Discarded Refrigerator littlefridge.gif 5 100 0",