From a7676fd33c89e9c184bd602c42e267c493bb7cab Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Tue, 24 Jun 2025 19:35:22 -0400 Subject: [PATCH] mauybe fixed tests --- test/moves/instruct.test.ts | 9 ++++----- test/moves/metronome.test.ts | 17 ++++++++--------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/test/moves/instruct.test.ts b/test/moves/instruct.test.ts index f62ef72097f..4b97536f580 100644 --- a/test/moves/instruct.test.ts +++ b/test/moves/instruct.test.ts @@ -126,21 +126,20 @@ describe("Moves - Instruct", () => { expect(game.scene.getPlayerPokemon()!.turnData.attacksReceived.length).toBe(2); }); - it("should add moves to move queue for copycat", async () => { - game.override.battleStyle("double").moveset(MoveId.INSTRUCT).enemyLevel(5); + it("should be considered as the last move used for copycat", async () => { + game.override.battleStyle("double").enemyLevel(5); await game.classicMode.startBattle([SpeciesId.AMOONGUSS]); const [enemy1, enemy2] = game.scene.getEnemyField()!; game.move.changeMoveset(enemy1, MoveId.WATER_GUN); game.move.changeMoveset(enemy2, MoveId.COPYCAT); - game.move.select(MoveId.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY); + game.move.use(MoveId.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("BerryPhase"); instructSuccess(enemy1, MoveId.WATER_GUN); - // amoonguss gets hit by water gun thrice; once by original attack, once by instructed use and once by copycat - expect(game.scene.getPlayerPokemon()!.turnData.attacksReceived.length).toBe(3); + expect(enemy2.getLastXMoves()[0].move).toBe(MoveId.WATER_GUN); }); it("should fail on metronomed moves, even if also in moveset", async () => { diff --git a/test/moves/metronome.test.ts b/test/moves/metronome.test.ts index 15eb41b0df4..0695ff88407 100644 --- a/test/moves/metronome.test.ts +++ b/test/moves/metronome.test.ts @@ -11,13 +11,12 @@ import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, it, expect, vi } from "vitest"; +import { RandomMoveAttr } from "#app/data/moves/move"; describe("Moves - Metronome", () => { let phaserGame: Phaser.Game; let game: GameManager; - const randomMoveAttr = allMoves[MoveId.METRONOME].getAttrs("RandomMoveAttr")[0]; - beforeAll(() => { phaserGame = new Phaser.Game({ type: Phaser.HEADLESS, @@ -55,7 +54,7 @@ describe("Moves - Metronome", () => { }); it("should become semi-invulnerable when using phasing moves", async () => { - vi.spyOn(randomMoveAttr, "getMove").mockReturnValue(MoveId.DIVE); + vi.spyOn(RandomMoveAttr.prototype, "getMove").mockReturnValue(MoveId.DIVE); await game.classicMode.startBattle([SpeciesId.REGIELEKI]); const player = game.field.getPlayerPokemon(); @@ -77,7 +76,7 @@ describe("Moves - Metronome", () => { }); it("should apply secondary effects of the called move", async () => { - vi.spyOn(randomMoveAttr, "getMove").mockReturnValue(MoveId.WOOD_HAMMER); + vi.spyOn(RandomMoveAttr.prototype, "getMove").mockReturnValue(MoveId.WOOD_HAMMER); await game.classicMode.startBattle([SpeciesId.REGIELEKI]); game.move.select(MoveId.METRONOME); @@ -91,7 +90,7 @@ describe("Moves - Metronome", () => { }); it("should count as last move used for Copycat/Mirror Move", async () => { - vi.spyOn(randomMoveAttr, "getMove").mockReturnValue(MoveId.ABSORB); + vi.spyOn(RandomMoveAttr.prototype, "getMove").mockReturnValue(MoveId.ABSORB); await game.classicMode.startBattle([SpeciesId.REGIELEKI]); game.move.select(MoveId.METRONOME); @@ -110,7 +109,7 @@ describe("Moves - Metronome", () => { it("should recharge after using recharge moves", async () => { await game.classicMode.startBattle([SpeciesId.REGIELEKI]); const player = game.field.getPlayerPokemon(); - vi.spyOn(randomMoveAttr, "getMove").mockReturnValue(MoveId.HYPER_BEAM); + vi.spyOn(RandomMoveAttr.prototype, "getMove").mockReturnValue(MoveId.HYPER_BEAM); vi.spyOn(allMoves[MoveId.HYPER_BEAM], "accuracy", "get").mockReturnValue(100); game.move.select(MoveId.METRONOME); @@ -121,7 +120,7 @@ describe("Moves - Metronome", () => { it("should charge for charging moves while still maintaining follow-up status", async () => { game.override.moveset([]).enemyMoveset(MoveId.SPITE); - vi.spyOn(randomMoveAttr, "getMove").mockReturnValue(MoveId.SOLAR_BEAM); + vi.spyOn(RandomMoveAttr.prototype, "getMove").mockReturnValue(MoveId.SOLAR_BEAM); await game.classicMode.startBattle([SpeciesId.REGIELEKI]); const player = game.field.getPlayerPokemon(); @@ -160,7 +159,7 @@ describe("Moves - Metronome", () => { const [leftPlayer, rightPlayer] = game.scene.getPlayerField(); const [leftOpp, rightOpp] = game.scene.getEnemyField(); - vi.spyOn(randomMoveAttr, "getMove").mockReturnValue(MoveId.AROMATIC_MIST); + vi.spyOn(RandomMoveAttr.prototype, "getMove").mockReturnValue(MoveId.AROMATIC_MIST); game.move.select(MoveId.METRONOME, 0); game.move.select(MoveId.SPLASH, 1); @@ -174,7 +173,7 @@ describe("Moves - Metronome", () => { it("should cause opponent to flee when using Roar", async () => { await game.classicMode.startBattle([SpeciesId.REGIELEKI]); - vi.spyOn(randomMoveAttr, "getMove").mockReturnValue(MoveId.ROAR); + vi.spyOn(RandomMoveAttr.prototype, "getMove").mockReturnValue(MoveId.ROAR); const enemyPokemon = game.field.getEnemyPokemon();