Skip to content

Commit

Permalink
Maybe fix up mocked imports
Browse files Browse the repository at this point in the history
  • Loading branch information
gausie committed May 22, 2024
1 parent 7338da2 commit aaa6618
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 26 deletions.
2 changes: 1 addition & 1 deletion packages/oaf/src/commands/kol/announcement.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion packages/oaf/src/commands/kol/leaderboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion packages/oaf/src/greenbox.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
10 changes: 5 additions & 5 deletions packages/oaf/src/things/Effect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof import("kol.js")>();
koljs.Client.prototype.getEffectDescription = blueText;
return koljs;
});

describe("Effect descriptions", () => {
test("Can describe an Effect", async () => {
Expand Down
10 changes: 5 additions & 5 deletions packages/oaf/src/things/Familiar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof import("kol.js")>();
koljs.Client.prototype.getItemDescription = blueText;
return koljs;
});

test("Can describe a Familiar", async () => {
const familiar = Familiar.from(
Expand Down
14 changes: 7 additions & 7 deletions packages/oaf/src/things/Item.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof import("kol.js")>();
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 () => {
Expand Down
11 changes: 5 additions & 6 deletions packages/oaf/src/things/Skill.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof import("kol.js")>();
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",
Expand Down

0 comments on commit aaa6618

Please sign in to comment.