diff --git a/src/data/balance/pokemon-evolutions.ts b/src/data/balance/pokemon-evolutions.ts index 21e5cea01d7..64409c3c989 100644 --- a/src/data/balance/pokemon-evolutions.ts +++ b/src/data/balance/pokemon-evolutions.ts @@ -14,6 +14,7 @@ import { DamageMoneyRewardModifier, ExtraModifierModifier, MoneyMultiplierModifi import { SpeciesFormKey } from "#enums/species-form-key"; import { speciesStarterCosts } from "./starters"; import i18next from "i18next"; +import { initI18n } from "#app/plugins/i18n"; export enum SpeciesWildEvolutionDelay { @@ -95,6 +96,9 @@ export class SpeciesFormEvolution { public description = ""; constructor(speciesId: Species, preFormKey: string | null, evoFormKey: string | null, level: number, item: EvolutionItem | null, condition: SpeciesEvolutionCondition | null, wildDelay?: SpeciesWildEvolutionDelay) { + if (!i18next.isInitialized) { + initI18n(); + } this.speciesId = speciesId; this.preFormKey = preFormKey; this.evoFormKey = evoFormKey; diff --git a/test/account.test.ts b/test/account.test.ts index 3f6b9f3f80b..77368b0b64c 100644 --- a/test/account.test.ts +++ b/test/account.test.ts @@ -1,4 +1,4 @@ -import * as battleScene from "#app/battle-scene"; +import * as bypassLogin from "#app/global-vars/bypass-login"; import { pokerogueApi } from "#app/plugins/api/pokerogue-api"; import { describe, expect, it, vi } from "vitest"; import { initLoggedInUser, loggedInUser, updateUserInfo } from "#app/account"; @@ -15,7 +15,7 @@ describe("account", () => { describe("updateUserInfo", () => { it("should set loggedInUser! to Guest if bypassLogin is true", async () => { - vi.spyOn(battleScene, "bypassLogin", "get").mockReturnValue(true); + vi.spyOn(bypassLogin, "bypassLogin", "get").mockReturnValue(true); const [success, status] = await updateUserInfo(); @@ -26,7 +26,7 @@ describe("account", () => { }); it("should fetch user info from the API if bypassLogin is false", async () => { - vi.spyOn(battleScene, "bypassLogin", "get").mockReturnValue(false); + vi.spyOn(bypassLogin, "bypassLogin", "get").mockReturnValue(false); vi.spyOn(pokerogueApi.account, "getInfo").mockResolvedValue([ { username: "test", @@ -47,7 +47,7 @@ describe("account", () => { }); it("should handle resolved API errors", async () => { - vi.spyOn(battleScene, "bypassLogin", "get").mockReturnValue(false); + vi.spyOn(bypassLogin, "bypassLogin", "get").mockReturnValue(false); vi.spyOn(pokerogueApi.account, "getInfo").mockResolvedValue([null, 401]); const [success, status] = await updateUserInfo(); @@ -57,7 +57,7 @@ describe("account", () => { }); it("should handle 500 API errors", async () => { - vi.spyOn(battleScene, "bypassLogin", "get").mockReturnValue(false); + vi.spyOn(bypassLogin, "bypassLogin", "get").mockReturnValue(false); vi.spyOn(pokerogueApi.account, "getInfo").mockResolvedValue([null, 500]); const [success, status] = await updateUserInfo(); diff --git a/test/testUtils/gameWrapper.ts b/test/testUtils/gameWrapper.ts index 42f1baf7287..050e9f13257 100644 --- a/test/testUtils/gameWrapper.ts +++ b/test/testUtils/gameWrapper.ts @@ -1,5 +1,5 @@ // @ts-nocheck - TODO: remove this -import BattleScene, * as battleScene from "#app/battle-scene"; +import BattleScene from "#app/battle-scene"; import { MoveAnim } from "#app/data/battle-anims"; import Pokemon from "#app/field/pokemon"; import { sessionIdKey } from "#app/utils/common"; @@ -21,6 +21,8 @@ import KeyboardPlugin = Phaser.Input.Keyboard.KeyboardPlugin; import GamepadPlugin = Phaser.Input.Gamepad.GamepadPlugin; import EventEmitter = Phaser.Events.EventEmitter; import UpdateList = Phaser.GameObjects.UpdateList; +// biome-ignore lint/style/noNamespaceImport: Necessary in order to mock the var +import * as bypassLoginModule from "#app/global-vars/bypass-login"; window.URL.createObjectURL = (blob: Blob) => { blobToString(blob).then((data: string) => { @@ -44,7 +46,7 @@ export default class GameWrapper { Phaser.Math.RND.sow(["test"]); // vi.spyOn(Utils, "apiFetch", "get").mockReturnValue(fetch); if (bypassLogin) { - vi.spyOn(battleScene, "bypassLogin", "get").mockReturnValue(true); + vi.spyOn(bypassLoginModule, "bypassLogin", "get").mockReturnValue(true); } this.game = phaserGame; MoveAnim.prototype.getAnim = () => ({ diff --git a/test/testUtils/testFileInitialization.ts b/test/testUtils/testFileInitialization.ts index b2ef7e0ccd6..414e34e024b 100644 --- a/test/testUtils/testFileInitialization.ts +++ b/test/testUtils/testFileInitialization.ts @@ -21,6 +21,7 @@ import Phaser from "phaser"; import InputText from "phaser3-rex-plugins/plugins/inputtext"; import BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext"; import { manageListeners } from "./listenersManager"; +import { initI18n } from "#app/plugins/i18n"; let wasInitialized = false; /** @@ -87,6 +88,7 @@ export function initTestFile() { // initSpecies(); if (!wasInitialized) { wasInitialized = true; + initI18n(); initVouchers(); initAchievements(); initStatsKeys();