From c4ecd12faabd9f2a928ca7ef10ece551b8b8083a Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Thu, 5 Sep 2024 18:22:58 -0700 Subject: [PATCH] Update tests --- src/test/abilities/aftermath.test.ts | 42 +++++++-------- src/test/abilities/damp.test.ts | 79 ++++++++++------------------ 2 files changed, 45 insertions(+), 76 deletions(-) diff --git a/src/test/abilities/aftermath.test.ts b/src/test/abilities/aftermath.test.ts index 888f7b8b3ee..6385cab958b 100644 --- a/src/test/abilities/aftermath.test.ts +++ b/src/test/abilities/aftermath.test.ts @@ -1,11 +1,9 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { Moves } from "#enums/moves"; import { Abilities } from "#enums/abilities"; +import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; -import { TurnEndPhase } from "#app/phases.js"; -import { SPLASH_ONLY } from "../utils/testUtils"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; const TIMEOUT = 20 * 1000; @@ -25,27 +23,26 @@ describe("Abilities - Aftermath", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.battleType("single"); - game.override.ability(Abilities.NONE); - game.override.enemyAbility(Abilities.AFTERMATH); - game.override.enemyMoveset(SPLASH_ONLY); - game.override.enemySpecies(Species.BIDOOF); + game.override + .battleType("single") + .ability(Abilities.BALL_FETCH) + .moveset([Moves.TACKLE, Moves.WATER_GUN]) + .enemyAbility(Abilities.AFTERMATH) + .enemyMoveset(SPLASH_ONLY) + .enemySpecies(Species.BIDOOF); }); it("deals 25% of attacker's HP as damage to attacker when defeated by contact move", async () => { - const moveToUse = Moves.TACKLE; - game.override.moveset(Array(4).fill(moveToUse)); - - await game.startBattle(); + await game.classicMode.startBattle(); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; enemy.hp = 1; - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); + game.move.select(Moves.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.phaseInterceptor.log).toContain("FaintPhase"); expect(game.phaseInterceptor.log).toContain("ShowAbilityPhase"); @@ -53,22 +50,19 @@ describe("Abilities - Aftermath", () => { }, TIMEOUT); it("does not activate on non-contact moves", async () => { - const moveToUse = Moves.WATER_GUN; - game.override.moveset(Array(4).fill(moveToUse)); - - await game.startBattle(); + await game.classicMode.startBattle(); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; enemy.hp = 1; - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); + game.move.select(Moves.WATER_GUN); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.phaseInterceptor.log).toContain("FaintPhase"); expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase"); - expect(player.getHpRatio()).toBeCloseTo(1); + expect(player.isFullHp()).toBe(true); }, TIMEOUT); }); diff --git a/src/test/abilities/damp.test.ts b/src/test/abilities/damp.test.ts index c78cfb40393..51a94dddf1e 100644 --- a/src/test/abilities/damp.test.ts +++ b/src/test/abilities/damp.test.ts @@ -1,12 +1,10 @@ -import { Abilities } from "#app/enums/abilities.js"; +import { Abilities } from "#app/enums/abilities"; import { Moves } from "#app/enums/moves"; import { Species } from "#app/enums/species"; -import { TurnEndPhase } from "#app/phases"; import GameManager from "#app/test/utils/gameManager"; -import { getMovePosition } from "#app/test/utils/gameManagerUtils"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { SPLASH_ONLY } from "../utils/testUtils"; const TIMEOUT = 20 * 1000; @@ -26,45 +24,37 @@ describe("Abilities - Damp", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.battleType("single"); - game.override.disableCrits(); - game.override.enemySpecies(Species.BIDOOF); + game.override + .battleType("single") + .disableCrits() + .enemySpecies(Species.BIDOOF) + .enemyMoveset(SPLASH_ONLY) + .enemyAbility(Abilities.BALL_FETCH) + .ability(Abilities.DAMP) + .moveset([Moves.EXPLOSION, Moves.TACKLE, Moves.SPLASH]); }); it("prevents explosive attacks used by others", async() => { - const moveToUse = Moves.EXPLOSION; - const enemyAbility = Abilities.DAMP; + game.override + .ability(Abilities.BALL_FETCH) + .enemyAbility(Abilities.DAMP); - game.override.ability(Abilities.NONE); - game.override.moveset(Array(4).fill(moveToUse)); - game.override.enemyMoveset(SPLASH_ONLY); - game.override.enemyAbility(enemyAbility); + await game.classicMode.startBattle(); - await game.startBattle(); + game.move.select(Moves.EXPLOSION); - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); - - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.phaseInterceptor.log).toContain("ShowAbilityPhase"); expect(game.phaseInterceptor.log).not.toContain("FaintPhase"); }, TIMEOUT); it("prevents explosive attacks used by the battler with Damp", async() => { - const moveToUse = Moves.EXPLOSION; - const playerAbility = Abilities.DAMP; + await game.classicMode.startBattle(); - game.override.ability(playerAbility); - game.override.moveset(Array(4).fill(moveToUse)); - game.override.enemyMoveset(SPLASH_ONLY); - game.override.enemySpecies(Species.BIDOOF); - game.override.enemyAbility(Abilities.NONE); + game.move.select(Moves.EXPLOSION); - await game.startBattle(); - - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); - - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.phaseInterceptor.log).toContain("ShowAbilityPhase"); expect(game.phaseInterceptor.log).not.toContain("FaintPhase"); @@ -72,45 +62,30 @@ describe("Abilities - Damp", () => { // Invalid if aftermath.test.ts has a failure. it("silently prevents Aftermath from triggering", async() => { - const moveToUse = Moves.TACKLE; - const playerAbility = Abilities.DAMP; - const enemyAbility = Abilities.AFTERMATH; + game.override.enemyAbility(Abilities.AFTERMATH); - game.override.ability(playerAbility); - game.override.moveset(Array(4).fill(moveToUse)); - game.override.enemyAbility(enemyAbility); - game.override.enemyMoveset(SPLASH_ONLY); - game.override.enemySpecies(Species.BIDOOF); - - await game.startBattle(); + await game.classicMode.startBattle(); game.scene.getEnemyParty()[0].hp = 1; - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); + game.move.select(Moves.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.phaseInterceptor.log).toContain("FaintPhase"); expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase"); - expect(game.scene.getParty()[0].getHpRatio()).toBe(1); + expect(game.scene.getParty()[0].isFullHp()).toBe(true); }, TIMEOUT); - // Ensures fix of #1476. it("does not show ability popup during AI calculations", async() => { - const moveToUse = Moves.SPLASH; - const playerAbility = Abilities.DAMP; - - game.override.ability(playerAbility); - game.override.moveset(Array(4).fill(moveToUse)); - game.override.enemyAbility(Abilities.NONE); game.override.enemyMoveset([Moves.EXPLOSION, Moves.SELF_DESTRUCT, Moves.MIND_BLOWN, Moves.MISTY_EXPLOSION]); - await game.startBattle(); + await game.classicMode.startBattle(); - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); + game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase"); }, TIMEOUT);