mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-11 02:42:19 +02:00
Fix test runner error
This commit is contained in:
parent
1df7a1dd72
commit
4988d6eb6d
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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 = () => ({
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user