From dbaa70203521587507a348b5747181f89dc23b49 Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Sun, 21 Sep 2025 17:23:08 -0400 Subject: [PATCH] foo --- test/abilities/stall.test.ts | 7 +++++-- test/moves/delayed-attack.test.ts | 6 ++++-- test/test-utils/game-manager.ts | 7 ++----- test/test-utils/helpers/field-helper.ts | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/test/abilities/stall.test.ts b/test/abilities/stall.test.ts index b6a88964e09..df522867722 100644 --- a/test/abilities/stall.test.ts +++ b/test/abilities/stall.test.ts @@ -1,4 +1,5 @@ import { AbilityId } from "#enums/ability-id"; +import { BattlerIndex } from "#enums/battler-index"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { GameManager } from "#test/test-utils/game-manager"; @@ -24,7 +25,7 @@ describe("Abilities - Stall", () => { game.override .battleStyle("single") .criticalHits(false) - .enemySpecies(SpeciesId.REGIELEKI) + .enemySpecies(SpeciesId.SHUCKLE) .enemyAbility(AbilityId.STALL) .enemyMoveset(MoveId.QUICK_ATTACK) .moveset([MoveId.QUICK_ATTACK, MoveId.TACKLE]); @@ -42,7 +43,7 @@ describe("Abilities - Stall", () => { const player = game.field.getPlayerPokemon(); game.move.select(MoveId.QUICK_ATTACK); - + game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("MoveEndPhase", false); // The player Pokemon (without Stall) goes first despite having lower speed than the opponent. // The opponent Pokemon (with Stall) goes last despite having higher speed than the player Pokemon. @@ -55,6 +56,7 @@ describe("Abilities - Stall", () => { const player = game.field.getPlayerPokemon(); game.move.select(MoveId.TACKLE); + game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("MoveEndPhase", false); // The opponent Pokemon (with Stall) goes first because its move is still within a higher priority bracket than its opponent. @@ -69,6 +71,7 @@ describe("Abilities - Stall", () => { const player = game.field.getPlayerPokemon(); game.move.select(MoveId.TACKLE); + game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("MoveEndPhase", false); diff --git a/test/moves/delayed-attack.test.ts b/test/moves/delayed-attack.test.ts index db3c8bb17a3..5079e471dda 100644 --- a/test/moves/delayed-attack.test.ts +++ b/test/moves/delayed-attack.test.ts @@ -165,9 +165,11 @@ describe("Moves - Delayed Attacks", () => { it("should trigger multiple pending attacks in order of creation, even if that order changes later on", async () => { game.override.battleStyle("double"); - await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.FEEBAS]); + await game.classicMode.startBattle([SpeciesId.ALOMOMOLA, SpeciesId.BLISSEY]); - const [alomomola, blissey] = game.scene.getPlayerField(); + const [alomomola, blissey, karp1, karp2] = game.scene.getField(); + vi.spyOn(karp1, "getNameToRender").mockReturnValue("Karp 1"); + vi.spyOn(karp2, "getNameToRender").mockReturnValue("Karp 2"); const oldOrder = game.field.getSpeedOrder(true); diff --git a/test/test-utils/game-manager.ts b/test/test-utils/game-manager.ts index 55cb74e461c..be7fb1579ad 100644 --- a/test/test-utils/game-manager.ts +++ b/test/test-utils/game-manager.ts @@ -52,13 +52,11 @@ import type { ModifierSelectUiHandler } from "#ui/modifier-select-ui-handler"; import type { PartyUiHandler } from "#ui/party-ui-handler"; import type { StarterSelectUiHandler } from "#ui/starter-select-ui-handler"; import type { TargetSelectUiHandler } from "#ui/target-select-ui-handler"; -import { sortInSpeedOrder } from "#utils/speed-order"; +import * as speedOrderUtils from "#utils/speed-order"; import fs from "node:fs"; import { AES, enc } from "crypto-js"; import { expect, vi } from "vitest"; -vi.mock(import("#utils/speed-order"), { spy: true }); - /** * Class to manage the game state and transitions between phases. */ @@ -557,8 +555,7 @@ export class GameManager { this.scene.getField(true).map(p => p.getBattlerIndex() as Exclude), ); - expect(vi.isMockFunction(sortInSpeedOrder)).toBe(true); - vi.mocked(sortInSpeedOrder).mockImplementation(list => { + vi.spyOn(speedOrderUtils, "sortInSpeedOrder").mockImplementation(list => { list.sort((a, b) => { const aBattlerIndex = (a instanceof Pokemon ? a : a.getPokemon()).getBattlerIndex() as Exclude< BattlerIndex, diff --git a/test/test-utils/helpers/field-helper.ts b/test/test-utils/helpers/field-helper.ts index db48e411d5e..6e52a9e3dde 100644 --- a/test/test-utils/helpers/field-helper.ts +++ b/test/test-utils/helpers/field-helper.ts @@ -61,7 +61,7 @@ export class FieldHelper extends GameManagerHelper { * Helper function to return all on-field {@linkcode Pokemon} in speed order (fastest first). * @param indices - Whether to only return {@linkcode BattlerIndex}es instead of full Pokemon objects * (such as for comparison with other speed order-related mechanisms); default `false` - * @returns An array containing the {@linkcode BattlerIndex}es of all on-field {@linkcode Pokemon} on the field in order of descending Speed. \ + * @returns An array containing the {@linkcode BattlerIndex}es of all on-field `Pokemon` on the field in order of **descending** Speed. \ * Speed ties are returned in increasing order of index. * * @remarks