Fixed test

This commit is contained in:
Bertie690 2025-06-21 22:12:59 -04:00
parent c06c1bfbaf
commit 4cd9399681

View File

@ -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();