From 6373a8601133e27b3e6b5221585f871a95835d8d Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Sun, 1 Sep 2024 01:13:37 -0700 Subject: [PATCH] Fix tests --- src/test/daily_mode.test.ts | 76 +++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/src/test/daily_mode.test.ts b/src/test/daily_mode.test.ts index 5947e010cbb..ecbb756ca0e 100644 --- a/src/test/daily_mode.test.ts +++ b/src/test/daily_mode.test.ts @@ -1,10 +1,11 @@ +import { Abilities } from "#app/enums/abilities"; +import { Moves } from "#app/enums/moves"; +import { MapModifier } from "#app/modifier/modifier"; +import { poolHasBlackHole, poolHasEviolite } from "#app/modifier/modifier-type"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import GameManager from "./utils/gameManager"; -import { MapModifier } from "#app/modifier/modifier.js"; -import { SelectModifierPhase } from "../phases/select-modifier-phase"; -import { Moves } from "#app/enums/moves.js"; -import { Abilities } from "#app/enums/abilities.js"; -import { poolHasEviolite, poolHasBlackHole } from "#app/modifier/modifier-type.js"; + +const TIMEOUT = 20 * 1000; describe("Daily Mode", () => { let phaserGame: Phaser.Game; @@ -35,35 +36,46 @@ describe("Daily Mode", () => { }); expect(game.scene.getModifiers(MapModifier).length).toBeGreaterThan(0); }); +}); - describe("Shop modifications", async () => { - beforeEach(() => { - game = new GameManager(phaserGame); +describe("Shop modifications", async () => { + let phaserGame: Phaser.Game; + let game: GameManager; - game.override - .battleType("single") - .startingLevel(200) - .moveset([Moves.SURF]) - .enemyAbility(Abilities.BALL_FETCH); - }); - afterEach(() => { - game.phaseInterceptor.restoreOg(); - }); - it("should only allow Mini Black Hole and Eviolite outside of Daily if unlocked", async () => { - await game.classicMode.startBattle(); - - game.move.select(Moves.SURF); - await game.phaseInterceptor.to(SelectModifierPhase, false); - expect(poolHasEviolite).toBeFalsy(); - expect(poolHasBlackHole).toBeFalsy(); - }); - it("should allow Eviolite and Mini Black Hole in shop when in Daily Run", async () => { - await game.dailyMode.startBattle(); - - game.move.select(Moves.SURF); - await game.phaseInterceptor.to(SelectModifierPhase, false); - expect(poolHasEviolite).toBeTruthy(); - expect(poolHasBlackHole).toBeTruthy(); + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, }); }); + beforeEach(() => { + game = new GameManager(phaserGame); + + game.override + .battleType("single") + .startingLevel(200) + .moveset([Moves.SURF]) + .enemyAbility(Abilities.BALL_FETCH); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + it("should only allow Mini Black Hole and Eviolite outside of Daily if unlocked", async () => { + await game.classicMode.startBattle(); + + game.move.select(Moves.SURF); + await game.phaseInterceptor.to("SelectModifierPhase", false); + expect(poolHasEviolite).toBeFalsy(); + expect(poolHasBlackHole).toBeFalsy(); + }, TIMEOUT); + + it("should allow Eviolite and Mini Black Hole in shop when in Daily Run", async () => { + await game.dailyMode.startBattle(); + + game.move.select(Moves.SURF); + await game.phaseInterceptor.to("SelectModifierPhase", false); + expect(poolHasEviolite).toBeTruthy(); + expect(poolHasBlackHole).toBeTruthy(); + }, TIMEOUT); });