From 4cd9399681a6c47594d6720494a25c44cabce8c8 Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Sat, 21 Jun 2025 22:12:59 -0400 Subject: [PATCH] Fixed test --- test/moves/recovery-moves.test.ts | 98 +++++++++++-------------------- 1 file changed, 35 insertions(+), 63 deletions(-) diff --git a/test/moves/recovery-moves.test.ts b/test/moves/recovery-moves.test.ts index b9a7bb4523d..6b3b84c5539 100644 --- a/test/moves/recovery-moves.test.ts +++ b/test/moves/recovery-moves.test.ts @@ -2,6 +2,7 @@ import { getPokemonNameWithAffix } from "#app/messages"; import { getEnumValues, toReadableString } from "#app/utils/common"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; +import { MoveResult } from "#enums/move-result"; import { SpeciesId } from "#enums/species-id"; import { WeatherType } from "#enums/weather-type"; import GameManager from "#test/testUtils/gameManager"; @@ -9,7 +10,7 @@ import i18next from "i18next"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -describe("Moves - Recovery Moves", () => { +describe("Moves - Recovery Moves - ", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -19,30 +20,33 @@ describe("Moves - Recovery Moves", () => { }); }); + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + game.override + .ability(AbilityId.BALL_FETCH) + .battleStyle("single") + .criticalHits(false) + .enemySpecies(SpeciesId.MAGIKARP) + .enemyAbility(AbilityId.BALL_FETCH) + .enemyMoveset(MoveId.SPLASH) + .startingLevel(100) + .enemyLevel(100); + }); + + describe.each<{ name: string; move: MoveId }>([ { name: "Recover", move: MoveId.RECOVER }, { name: "Soft-Boiled", move: MoveId.SOFT_BOILED }, { name: "Milk Drink", move: MoveId.MILK_DRINK }, { name: "Slack Off", move: MoveId.SLACK_OFF }, { name: "Roost", move: MoveId.ROOST }, - ])("Normal Recovery Moves - $name", ({ move }) => { - afterEach(() => { - game.phaseInterceptor.restoreOg(); - }); - - beforeEach(() => { - game = new GameManager(phaserGame); - game.override - .ability(AbilityId.BALL_FETCH) - .battleStyle("single") - .criticalHits(false) - .enemySpecies(SpeciesId.MAGIKARP) - .enemyAbility(AbilityId.BALL_FETCH) - .enemyMoveset(MoveId.SPLASH) - .startingLevel(100) - .enemyLevel(100); - }); - + { name: "Weather-based Healing Moves", move: MoveId.SYNTHESIS }, + { name: "Shore Up", move: MoveId.SHORE_UP }, + ])("$name", ({ move }) => { it("should heal 50% of the user's maximum HP", async () => { await game.classicMode.startBattle([SpeciesId.BLISSEY]); @@ -56,7 +60,7 @@ describe("Moves - Recovery Moves", () => { expect(game.phaseInterceptor.log).toContain("PokemonHealPhase"); }); - it("should display message and fail if used at full HP", async () => { + it("should display message without adding phase if used at full HP", async () => { await game.classicMode.startBattle([SpeciesId.BLISSEY]); game.move.use(move); @@ -73,29 +77,12 @@ describe("Moves - Recovery Moves", () => { }); }); - describe("Weather-based Healing moves", () => { - afterEach(() => { - game.phaseInterceptor.restoreOg(); - }); - - beforeEach(() => { - game = new GameManager(phaserGame); - game.override - .ability(AbilityId.BALL_FETCH) - .battleStyle("single") - .criticalHits(false) - .enemySpecies(SpeciesId.MAGIKARP) - .enemyAbility(AbilityId.BALL_FETCH) - .enemyMoveset(MoveId.SPLASH) - .startingLevel(100) - .enemyLevel(100); - }); - + describe("Weather-based Healing Moves", () => { it.each([ - { name: "Harsh Sunlight", ability: AbilityId.DROUGHT }, - { name: "Extremely Harsh Sunlight", ability: AbilityId.DESOLATE_LAND }, - ])("should heal 66% of the user's maximum HP under $name", async ({ ability }) => { - game.override.passiveAbility(ability); + { name: "Harsh Sunlight", weather: WeatherType.SUNNY }, + { name: "Extremely Harsh Sunlight", weather: WeatherType.HARSH_SUN }, + ])("should heal 66% of the user's maximum HP under $name", async ({ weather }) => { + game.override.weather(weather); await game.classicMode.startBattle([SpeciesId.BLISSEY]); const blissey = game.field.getPlayerPokemon(); @@ -107,8 +94,10 @@ describe("Moves - Recovery Moves", () => { expect(blissey.getHpRatio()).toBeCloseTo(0.66, 1); }); - const nonSunWTs = getEnumValues(WeatherType) - .filter(wt => ![WeatherType.NONE, WeatherType.STRONG_WINDS].includes(wt)) + const nonSunWTs = (getEnumValues(WeatherType) as WeatherType[]) + .filter( + wt => ![WeatherType.SUNNY, WeatherType.HARSH_SUN, WeatherType.NONE, WeatherType.STRONG_WINDS].includes(wt), + ) .map(wt => ({ name: toReadableString(WeatherType[wt]), weather: wt, @@ -142,25 +131,8 @@ describe("Moves - Recovery Moves", () => { }); describe("Shore Up", () => { - afterEach(() => { - game.phaseInterceptor.restoreOg(); - }); - - beforeEach(() => { - game = new GameManager(phaserGame); - game.override - .ability(AbilityId.BALL_FETCH) - .battleStyle("single") - .criticalHits(false) - .enemySpecies(SpeciesId.MAGIKARP) - .enemyAbility(AbilityId.BALL_FETCH) - .enemyMoveset(MoveId.SPLASH) - .startingLevel(100) - .enemyLevel(100); - }); - - it("should heal 66% of the user's maximum HP under sandstorm", async () => { - game.override.ability(AbilityId.SAND_STREAM); + it("should heal 66% of the user's maximum HP in a sandstorm", async () => { + game.override.weather(WeatherType.SANDSTORM); await game.classicMode.startBattle([SpeciesId.BLISSEY]); const blissey = game.field.getPlayerPokemon();