From d3e516b496791ee090176f0ee06d619824a91836 Mon Sep 17 00:00:00 2001 From: Adrian T <68144167+torranx@users.noreply.github.com> Date: Fri, 21 Jun 2024 22:59:10 +0800 Subject: [PATCH] [Bug][Unit Test] fix and optimize sturdy unit tests (#2455) * fix and optimize sturdy unit tests * re-add timeout --- src/test/abilities/sturdy.test.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/test/abilities/sturdy.test.ts b/src/test/abilities/sturdy.test.ts index 7bfac5e8f18..b9d764971f0 100644 --- a/src/test/abilities/sturdy.test.ts +++ b/src/test/abilities/sturdy.test.ts @@ -3,7 +3,8 @@ import Phaser from "phaser"; import GameManager from "#app/test/utils/gameManager"; import * as overrides from "#app/overrides"; import { - TurnEndPhase, + DamagePhase, + MoveEndPhase, } from "#app/phases"; import {getMovePosition} from "#app/test/utils/gameManagerUtils"; import { Abilities } from "#enums/abilities"; @@ -45,7 +46,7 @@ describe("Abilities - Sturdy", () => { async () => { await game.startBattle(); game.doAttack(getMovePosition(game.scene, 0, Moves.CLOSE_COMBAT)); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(MoveEndPhase); expect(game.scene.getEnemyParty()[0].hp).toBe(1); }, TIMEOUT @@ -55,10 +56,13 @@ describe("Abilities - Sturdy", () => { "Sturdy doesn't activate when user is not at full HP", async () => { await game.startBattle(); + const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; enemyPokemon.hp = enemyPokemon.getMaxHp() - 1; + game.doAttack(getMovePosition(game.scene, 0, Moves.CLOSE_COMBAT)); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(DamagePhase); + expect(enemyPokemon.hp).toBe(0); expect(enemyPokemon.isFainted()).toBe(true); }, @@ -66,11 +70,12 @@ describe("Abilities - Sturdy", () => { ); test( - "Sturdy pokemon should be inmune to OHKO moves", + "Sturdy pokemon should be immune to OHKO moves", async () => { await game.startBattle(); game.doAttack(getMovePosition(game.scene, 0, Moves.FISSURE)); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(MoveEndPhase); + const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); }, @@ -84,7 +89,8 @@ describe("Abilities - Sturdy", () => { await game.startBattle(); game.doAttack(getMovePosition(game.scene, 0, Moves.CLOSE_COMBAT)); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(DamagePhase); + const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; expect(enemyPokemon.hp).toBe(0); expect(enemyPokemon.isFainted()).toBe(true);