mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-01 05:52:17 +02:00
Removed unneeded mockRestore
calls
We call `restoreAllMocks` after each test runs anyhow
This commit is contained in:
parent
0ff7cdd7e8
commit
98fa1b342e
@ -88,8 +88,7 @@ describe("Abilities - Flower Veil", () => {
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.move.selectEnemyMove(Moves.THUNDER_WAVE);
|
||||
await game.toNextTurn();
|
||||
expect(game.scene.getPlayerPokemon()!.status).toBeUndefined();
|
||||
vi.spyOn(allMoves[Moves.THUNDER_WAVE], "accuracy", "get").mockClear();
|
||||
expect(game.scene.getPlayerPokemon()?.status).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should not prevent status conditions for a non-grass user and its non-grass allies", async () => {
|
||||
|
@ -4,7 +4,7 @@ import { Species } from "#enums/species";
|
||||
import { StatusEffect } from "#enums/status-effect";
|
||||
import GameManager from "#test/testUtils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi, type MockInstance } from "vitest";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { isNullOrUndefined } from "#app/utils/common";
|
||||
import { PostTurnResetStatusAbAttr } from "#app/data/abilities/ability";
|
||||
import { allAbilities } from "#app/data/data-lists";
|
||||
@ -13,8 +13,6 @@ import type Pokemon from "#app/field/pokemon";
|
||||
describe("Abilities - Healer", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
let healerAttrSpy: MockInstance;
|
||||
let healerAttr: PostTurnResetStatusAbAttr;
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phaser.Game({
|
||||
@ -24,7 +22,6 @@ describe("Abilities - Healer", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
healerAttrSpy.mockRestore();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
@ -38,13 +35,14 @@ describe("Abilities - Healer", () => {
|
||||
.enemyAbility(Abilities.BALL_FETCH)
|
||||
.enemyMoveset(Moves.SPLASH);
|
||||
|
||||
healerAttr = allAbilities[Abilities.HEALER].getAttrs(PostTurnResetStatusAbAttr)[0];
|
||||
healerAttrSpy = vi
|
||||
.spyOn(healerAttr, "getCondition")
|
||||
.mockReturnValue((pokemon: Pokemon) => !isNullOrUndefined(pokemon.getAlly()));
|
||||
// Mock healer to have a 100% chance of healing its ally
|
||||
vi.spyOn(allAbilities[Abilities.HEALER].getAttrs(PostTurnResetStatusAbAttr)[0], "getCondition").mockReturnValue(
|
||||
(pokemon: Pokemon) => !isNullOrUndefined(pokemon.getAlly()),
|
||||
);
|
||||
});
|
||||
|
||||
it("should not queue a message phase for healing if the ally has fainted", async () => {
|
||||
const abSpy = vi.spyOn(PostTurnResetStatusAbAttr.prototype, "canApplyPostTurn");
|
||||
game.override.moveset([Moves.SPLASH, Moves.LUNAR_DANCE]);
|
||||
await game.classicMode.startBattle([Species.MAGIKARP, Species.MAGIKARP]);
|
||||
const user = game.scene.getPlayerPokemon()!;
|
||||
@ -53,15 +51,11 @@ describe("Abilities - Healer", () => {
|
||||
game.move.select(Moves.SPLASH);
|
||||
// faint the ally
|
||||
game.move.select(Moves.LUNAR_DANCE, 1);
|
||||
const abSpy = vi.spyOn(healerAttr, "canApplyPostTurn");
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
|
||||
// It's not enough to just test that the ally still has its status.
|
||||
// We need to ensure that the ability failed to meet its condition
|
||||
expect(abSpy).toHaveReturnedWith(false);
|
||||
|
||||
// Explicitly restore the mock to ensure pollution doesn't happen
|
||||
abSpy.mockRestore();
|
||||
});
|
||||
|
||||
it("should heal the status of an ally if the ally has a status", async () => {
|
||||
|
@ -173,13 +173,12 @@ describe("Abilities - Magic Bounce", () => {
|
||||
it("should not cause encore to be interrupted after bouncing", async () => {
|
||||
game.override.moveset([Moves.SPLASH, Moves.GROWL, Moves.ENCORE]);
|
||||
game.override.enemyMoveset([Moves.TACKLE, Moves.GROWL]);
|
||||
// game.override.ability(Abilities.MOLD_BREAKER);
|
||||
await game.classicMode.startBattle([Species.MAGIKARP]);
|
||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
|
||||
// Give the player MOLD_BREAKER for this turn to bypass Magic Bounce.
|
||||
vi.spyOn(playerPokemon, "getAbility").mockReturnValue(allAbilities[Abilities.MOLD_BREAKER]);
|
||||
game.field.mockAbility(playerPokemon, Abilities.MOLD_BREAKER);
|
||||
|
||||
// turn 1
|
||||
game.move.select(Moves.ENCORE);
|
||||
@ -189,7 +188,7 @@ describe("Abilities - Magic Bounce", () => {
|
||||
expect(enemyPokemon.getTag(BattlerTagType.ENCORE)!["moveId"]).toBe(Moves.TACKLE);
|
||||
|
||||
// turn 2
|
||||
vi.spyOn(playerPokemon, "getAbility").mockRestore();
|
||||
game.field.mockAbility(playerPokemon, Abilities.MAGIC_BOUNCE);
|
||||
game.move.select(Moves.GROWL);
|
||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
|
@ -30,13 +30,13 @@ describe("Abilities - Super Luck", () => {
|
||||
.enemyMoveset(Moves.SPLASH);
|
||||
});
|
||||
|
||||
it("should increase the crit stage of a user by 1", async () => {
|
||||
it("should increase the user's crit stage by 1", async () => {
|
||||
await game.classicMode.startBattle([Species.MAGIKARP]);
|
||||
const enemy = game.scene.getEnemyPokemon()!;
|
||||
const fn = vi.spyOn(enemy, "getCritStage");
|
||||
const critSpy = vi.spyOn(enemy, "getCritStage"); // crit stage is called on enemy
|
||||
|
||||
game.move.select(Moves.TACKLE);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
expect(fn).toHaveReturnedWith(1);
|
||||
fn.mockRestore();
|
||||
expect(critSpy).toHaveReturnedWith(1);
|
||||
});
|
||||
});
|
||||
|
@ -93,8 +93,6 @@ describe("Abilities - Tera Shell", () => {
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(spy).toHaveLastReturnedWith(1);
|
||||
expect(playerPokemon.hp).toBe(playerPokemon.getMaxHp() - 40);
|
||||
|
||||
spy.mockRestore();
|
||||
});
|
||||
|
||||
it("should change the effectiveness of all strikes of a multi-strike move", async () => {
|
||||
@ -114,6 +112,5 @@ describe("Abilities - Tera Shell", () => {
|
||||
expect(spy).toHaveLastReturnedWith(0.5);
|
||||
}
|
||||
expect(spy).toHaveReturnedTimes(2);
|
||||
spy.mockRestore();
|
||||
});
|
||||
});
|
||||
|
@ -13,7 +13,7 @@ import { Species } from "#enums/species";
|
||||
import { StatusEffect } from "#enums/status-effect";
|
||||
import GameManager from "#test/testUtils/gameManager";
|
||||
import { mockI18next } from "#test/testUtils/testUtils";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
|
||||
const pokemonName = "PKM";
|
||||
const sourceText = "SOURCE";
|
||||
@ -295,9 +295,7 @@ describe("Status Effect Messages", () => {
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
afterEach(() => {});
|
||||
});
|
||||
|
||||
describe("Status Effects", () => {
|
||||
|
@ -25,7 +25,6 @@ describe("Egg Generation Tests", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
|
@ -21,7 +21,6 @@ describe("Manaphy Eggs", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
|
@ -14,8 +14,6 @@ describe("game-mode", () => {
|
||||
});
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
|
@ -43,8 +43,6 @@ describe("Moves - Struggle", () => {
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
|
||||
expect(stabSpy).toHaveReturnedWith(1);
|
||||
|
||||
stabSpy.mockRestore();
|
||||
});
|
||||
|
||||
it("should ignore type effectiveness", async () => {
|
||||
@ -55,11 +53,8 @@ describe("Moves - Struggle", () => {
|
||||
game.move.select(Moves.STRUGGLE);
|
||||
|
||||
const moveEffectivenessSpy = vi.spyOn(enemy, "getMoveEffectiveness");
|
||||
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
|
||||
expect(moveEffectivenessSpy).toHaveReturnedWith(1);
|
||||
|
||||
moveEffectivenessSpy.mockRestore();
|
||||
});
|
||||
});
|
||||
|
@ -54,8 +54,6 @@ describe("A Trainer's Test - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -53,8 +53,6 @@ describe("Absolute Avarice - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -56,8 +56,6 @@ describe("An Offer You Can't Refuse - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -57,8 +57,6 @@ describe("Berries Abound - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -172,8 +172,6 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -67,8 +67,6 @@ describe("Clowning Around - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -56,8 +56,6 @@ describe("Dancing Lessons - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -58,8 +58,6 @@ describe("Delibird-y - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -48,8 +48,6 @@ describe("Department Store Sale - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -46,8 +46,6 @@ describe("Field Trip - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -66,8 +66,6 @@ describe("Fiery Fallout - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -52,8 +52,6 @@ describe("Fight or Flight - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -56,8 +56,6 @@ describe("Fun And Games! - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -53,8 +53,6 @@ describe("Global Trade System - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -49,8 +49,6 @@ describe("Lost at Sea - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -57,8 +57,6 @@ describe("Mysterious Challengers - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -52,8 +52,6 @@ describe("Part-Timer - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -54,8 +54,6 @@ describe("Safari Zone - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -57,8 +57,6 @@ describe("Teleporting Hijinks - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -54,8 +54,6 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -55,8 +55,6 @@ describe("The Pokemon Salesman - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -65,8 +65,6 @@ describe("The Strong Stuff - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -58,8 +58,6 @@ describe("The Winstrate Challenge - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -62,8 +62,6 @@ describe("Trash to Treasure - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -62,8 +62,6 @@ describe("Uncommon Breed - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -53,8 +53,6 @@ describe("Weird Dream - Mystery Encounter", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
|
@ -41,8 +41,6 @@ describe("SelectModifierPhase", () => {
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it("should start a select modifier phase", async () => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import GameManager from "#test/testUtils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, type MockInstance, vi } from "vitest";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import PokedexUiHandler from "#app/ui/pokedex-ui-handler";
|
||||
import { FilterTextRow } from "#app/ui/filter-text";
|
||||
import { allAbilities } from "#app/data/data-lists";
|
||||
@ -46,7 +46,6 @@ function permutations<T>(array: T[], length: number): T[][] {
|
||||
describe("UI - Pokedex", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
const mocks: MockInstance[] = [];
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phaser.Game({
|
||||
@ -55,9 +54,6 @@ describe("UI - Pokedex", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
while (mocks.length > 0) {
|
||||
mocks.pop()?.mockRestore();
|
||||
}
|
||||
game.phaseInterceptor.restoreOg();
|
||||
});
|
||||
|
||||
@ -185,10 +181,10 @@ describe("UI - Pokedex", () => {
|
||||
checks.push(...pokemon.forms);
|
||||
}
|
||||
for (const p of checks) {
|
||||
mocks.push(vi.spyOn(p, "ability1", "get").mockReturnValue(ability));
|
||||
mocks.push(vi.spyOn(p, "ability2", "get").mockReturnValue(ability2));
|
||||
mocks.push(vi.spyOn(p, "abilityHidden", "get").mockReturnValue(hidden));
|
||||
mocks.push(vi.spyOn(p, "getPassiveAbility").mockReturnValue(passive));
|
||||
vi.spyOn(p, "ability1", "get").mockReturnValue(ability);
|
||||
vi.spyOn(p, "ability2", "get").mockReturnValue(ability2);
|
||||
vi.spyOn(p, "abilityHidden", "get").mockReturnValue(hidden);
|
||||
vi.spyOn(p, "getPassiveAbility").mockReturnValue(passive);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user