From 03afffb07f0ef18ed4df405e41ec5a5c865380d0 Mon Sep 17 00:00:00 2001 From: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Date: Tue, 17 Jun 2025 12:59:19 -0500 Subject: [PATCH] Fix some tests to mock proper methods --- test/abilities/harvest.test.ts | 2 +- test/abilities/healer.test.ts | 2 +- test/abilities/moody.test.ts | 2 +- test/abilities/neutralizing_gas.test.ts | 4 ++-- test/abilities/sand_veil.test.ts | 17 ++++++++--------- test/abilities/unburden.test.ts | 2 +- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/test/abilities/harvest.test.ts b/test/abilities/harvest.test.ts index 662eeed6dd0..42c9772bd10 100644 --- a/test/abilities/harvest.test.ts +++ b/test/abilities/harvest.test.ts @@ -95,7 +95,7 @@ describe("Abilities - Harvest", () => { // Give ourselves harvest and disable enemy neut gas, // but force our roll to fail so we don't accidentally recover anything - vi.spyOn(PostTurnRestoreBerryAbAttr.prototype, "canApplyPostTurn").mockReturnValueOnce(false); + vi.spyOn(PostTurnRestoreBerryAbAttr.prototype, "canApply").mockReturnValueOnce(false); game.override.ability(AbilityId.HARVEST); game.move.select(MoveId.GASTRO_ACID); await game.move.selectEnemyMove(MoveId.NUZZLE); diff --git a/test/abilities/healer.test.ts b/test/abilities/healer.test.ts index b37c9effeb0..b21b04531ec 100644 --- a/test/abilities/healer.test.ts +++ b/test/abilities/healer.test.ts @@ -42,7 +42,7 @@ describe("Abilities - Healer", () => { }); it("should not queue a message phase for healing if the ally has fainted", async () => { - const abSpy = vi.spyOn(PostTurnResetStatusAbAttr.prototype, "canApplyPostTurn"); + const abSpy = vi.spyOn(PostTurnResetStatusAbAttr.prototype, "canApply"); game.override.moveset([MoveId.SPLASH, MoveId.LUNAR_DANCE]); await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.MAGIKARP]); diff --git a/test/abilities/moody.test.ts b/test/abilities/moody.test.ts index a3e321928b8..bca3d57a70a 100644 --- a/test/abilities/moody.test.ts +++ b/test/abilities/moody.test.ts @@ -68,7 +68,7 @@ describe("Abilities - Moody", () => { }); it("should only decrease one stat stage by 1 stage if all stat stages are at 6", async () => { - await game.classicMode.startBattle(); + await game.classicMode.startBattle([SpeciesId.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; diff --git a/test/abilities/neutralizing_gas.test.ts b/test/abilities/neutralizing_gas.test.ts index 2408a78f11d..f153e71587e 100644 --- a/test/abilities/neutralizing_gas.test.ts +++ b/test/abilities/neutralizing_gas.test.ts @@ -178,7 +178,7 @@ describe("Abilities - Neutralizing Gas", () => { const enemy = game.scene.getEnemyPokemon()!; const weatherChangeAttr = enemy.getAbilityAttrs("PostSummonWeatherChangeAbAttr", false)[0]; - vi.spyOn(weatherChangeAttr, "applyPostSummon"); + const weatherChangeSpy = vi.spyOn(weatherChangeAttr, "apply"); expect(game.scene.arena.getTag(ArenaTagType.NEUTRALIZING_GAS)).toBeDefined(); @@ -187,6 +187,6 @@ describe("Abilities - Neutralizing Gas", () => { await game.killPokemon(game.scene.getPlayerPokemon()!); expect(game.scene.arena.getTag(ArenaTagType.NEUTRALIZING_GAS)).toBeUndefined(); - expect(weatherChangeAttr.applyPostSummon).not.toHaveBeenCalled(); + expect(weatherChangeSpy).not.toHaveBeenCalled(); }); }); diff --git a/test/abilities/sand_veil.test.ts b/test/abilities/sand_veil.test.ts index 35a0a3347ff..035b37d85a8 100644 --- a/test/abilities/sand_veil.test.ts +++ b/test/abilities/sand_veil.test.ts @@ -1,3 +1,4 @@ +import type { StatMultiplierAbAttrParams } from "#app/@types/ability-types"; import { allAbilities } from "#app/data/data-lists"; import { CommandPhase } from "#app/phases/command-phase"; import { MoveEffectPhase } from "#app/phases/move-effect-phase"; @@ -46,15 +47,13 @@ describe("Abilities - Sand Veil", () => { vi.spyOn(leadPokemon[0], "getAbility").mockReturnValue(allAbilities[AbilityId.SAND_VEIL]); const sandVeilAttr = allAbilities[AbilityId.SAND_VEIL].getAttrs("StatMultiplierAbAttr")[0]; - vi.spyOn(sandVeilAttr, "applyStatStage").mockImplementation( - (_pokemon, _passive, _simulated, stat, statValue, _args) => { - if (stat === Stat.EVA && game.scene.arena.weather?.weatherType === WeatherType.SANDSTORM) { - statValue.value *= -1; // will make all attacks miss - return true; - } - return false; - }, - ); + vi.spyOn(sandVeilAttr, "apply").mockImplementation(({ stat, statVal }: StatMultiplierAbAttrParams) => { + if (stat === Stat.EVA && game.scene.arena.weather?.weatherType === WeatherType.SANDSTORM) { + statVal.value *= -1; // will make all attacks miss + return true; + } + return false; + }); expect(leadPokemon[0].hasAbility(AbilityId.SAND_VEIL)).toBe(true); expect(leadPokemon[1].hasAbility(AbilityId.SAND_VEIL)).toBe(false); diff --git a/test/abilities/unburden.test.ts b/test/abilities/unburden.test.ts index fd7f8e9c662..c81675c6b90 100644 --- a/test/abilities/unburden.test.ts +++ b/test/abilities/unburden.test.ts @@ -277,7 +277,7 @@ describe("Abilities - Unburden", () => { const initialTreeckoSpeed = treecko.getStat(Stat.SPD); const initialPurrloinSpeed = purrloin.getStat(Stat.SPD); const unburdenAttr = treecko.getAbilityAttrs("PostItemLostAbAttr")[0]; - vi.spyOn(unburdenAttr, "applyPostItemLost"); + vi.spyOn(unburdenAttr, "apply"); // Player uses Baton Pass, which also passes the Baton item game.move.select(MoveId.BATON_PASS);