From 22e26621b39ae52dfadabbd8eaf7f83ef8010f2b Mon Sep 17 00:00:00 2001 From: innerthunder <168692175+innerthunder@users.noreply.github.com> Date: Thu, 20 Jun 2024 12:02:17 -0700 Subject: [PATCH] [Unittest] Remove HP assignment in unit tests (#2466) --- src/test/moves/follow_me.test.ts | 22 ++++++++++++---------- src/test/moves/rage_powder.test.ts | 10 ++++++---- src/test/moves/spotlight.test.ts | 14 +++++++------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/test/moves/follow_me.test.ts b/src/test/moves/follow_me.test.ts index 584c7c62dbf..f0b80ab90c0 100644 --- a/src/test/moves/follow_me.test.ts +++ b/src/test/moves/follow_me.test.ts @@ -54,7 +54,7 @@ describe("Moves - Follow Me", () => { expect(enemyPokemon.length).toBe(2); enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); - playerPokemon.forEach(p => p.hp = 200); + const playerStartingHp = playerPokemon.map(p => p.hp); game.doAttack(getMovePosition(game.scene, 0, Moves.FOLLOW_ME)); await game.phaseInterceptor.to(CommandPhase); @@ -65,8 +65,8 @@ describe("Moves - Follow Me", () => { game.doSelectTarget(BattlerIndex.ENEMY); await game.phaseInterceptor.to(TurnEndPhase, false); - expect(playerPokemon[0].hp).toBeLessThan(200); - expect(playerPokemon[1].hp).toBe(200); + expect(playerPokemon[0].hp).toBeLessThan(playerStartingHp[0]); + expect(playerPokemon[1].hp).toBe(playerStartingHp[1]); }, TIMEOUT ); @@ -83,7 +83,7 @@ describe("Moves - Follow Me", () => { expect(enemyPokemon.length).toBe(2); enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); - playerPokemon.forEach(p => p.hp = 200); + const playerStartingHp = playerPokemon.map(p => p.hp); game.doAttack(getMovePosition(game.scene, 0, Moves.FOLLOW_ME)); await game.phaseInterceptor.to(CommandPhase); @@ -93,8 +93,8 @@ describe("Moves - Follow Me", () => { playerPokemon.sort((a, b) => a.getBattleStat(Stat.SPD) - b.getBattleStat(Stat.SPD)); - expect(playerPokemon[1].hp).toBeLessThan(200); - expect(playerPokemon[0].hp).toBe(200); + expect(playerPokemon[1].hp).toBeLessThan(playerStartingHp[1]); + expect(playerPokemon[0].hp).toBe(playerStartingHp[0]); }, TIMEOUT ); @@ -115,7 +115,7 @@ describe("Moves - Follow Me", () => { expect(enemyPokemon.length).toBe(2); enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); - enemyPokemon.forEach(p => p.hp = 200); + const enemyStartingHp = enemyPokemon.map(p => p.hp); game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK)); await game.phaseInterceptor.to(SelectTargetPhase, false); @@ -128,7 +128,8 @@ describe("Moves - Follow Me", () => { await game.phaseInterceptor.to(TurnEndPhase, false); // If redirection was bypassed, both enemies should be damaged - enemyPokemon.forEach(p => expect(p.hp).toBeLessThan(200)); + expect(enemyPokemon[0].hp).toBeLessThan(enemyStartingHp[0]); + expect(enemyPokemon[1].hp).toBeLessThan(enemyStartingHp[1]); }, TIMEOUT ); @@ -148,7 +149,7 @@ describe("Moves - Follow Me", () => { expect(enemyPokemon.length).toBe(2); enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); - enemyPokemon.forEach(p => p.hp = 200); + const enemyStartingHp = enemyPokemon.map(p => p.hp); game.doAttack(getMovePosition(game.scene, 0, Moves.SNIPE_SHOT)); await game.phaseInterceptor.to(SelectTargetPhase, false); @@ -161,7 +162,8 @@ describe("Moves - Follow Me", () => { await game.phaseInterceptor.to(TurnEndPhase, false); // If redirection was bypassed, both enemies should be damaged - enemyPokemon.forEach(p => expect(p.hp).toBeLessThan(200)); + expect(enemyPokemon[0].hp).toBeLessThan(enemyStartingHp[0]); + expect(enemyPokemon[1].hp).toBeLessThan(enemyStartingHp[1]); }, TIMEOUT ); }); diff --git a/src/test/moves/rage_powder.test.ts b/src/test/moves/rage_powder.test.ts index 35bce54f533..1116810f743 100644 --- a/src/test/moves/rage_powder.test.ts +++ b/src/test/moves/rage_powder.test.ts @@ -55,7 +55,7 @@ describe("Moves - Rage Powder", () => { expect(enemyPokemon.length).toBe(2); enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); - enemyPokemon.forEach(p => p.hp = 200); + const enemyStartingHp = enemyPokemon.map(p => p.hp); game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK)); await game.phaseInterceptor.to(SelectTargetPhase, false); @@ -68,7 +68,8 @@ describe("Moves - Rage Powder", () => { await game.phaseInterceptor.to(TurnEndPhase, false); // If redirection was bypassed, both enemies should be damaged - enemyPokemon.forEach(p => expect(p.hp).toBeLessThan(200)); + expect(enemyPokemon[0].hp).toBeLessThan(enemyStartingHp[0]); + expect(enemyPokemon[1].hp).toBeLessThan(enemyStartingHp[1]); }, TIMEOUT ); @@ -89,7 +90,7 @@ describe("Moves - Rage Powder", () => { expect(enemyPokemon.length).toBe(2); enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); - enemyPokemon.forEach(p => p.hp = 200); + const enemyStartingHp = enemyPokemon.map(p => p.hp); game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK)); await game.phaseInterceptor.to(SelectTargetPhase, false); @@ -102,7 +103,8 @@ describe("Moves - Rage Powder", () => { await game.phaseInterceptor.to(TurnEndPhase, false); // If redirection was bypassed, both enemies should be damaged - enemyPokemon.forEach(p => expect(p.hp).toBeLessThan(200)); + expect(enemyPokemon[0].hp).toBeLessThan(enemyStartingHp[0]); + expect(enemyPokemon[1].hp).toBeLessThan(enemyStartingHp[1]); }, TIMEOUT ); }); diff --git a/src/test/moves/spotlight.test.ts b/src/test/moves/spotlight.test.ts index 7ba01dcfb3a..ec3f4977007 100644 --- a/src/test/moves/spotlight.test.ts +++ b/src/test/moves/spotlight.test.ts @@ -53,7 +53,7 @@ describe("Moves - Spotlight", () => { expect(enemyPokemon.length).toBe(2); enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); - enemyPokemon.forEach(p => p.hp = 200); + const enemyStartingHp = enemyPokemon.map(p => p.hp); game.doAttack(getMovePosition(game.scene, 0, Moves.SPOTLIGHT)); await game.phaseInterceptor.to(SelectTargetPhase, false); @@ -65,8 +65,8 @@ describe("Moves - Spotlight", () => { game.doSelectTarget(BattlerIndex.ENEMY_2); await game.phaseInterceptor.to(TurnEndPhase, false); - expect(enemyPokemon[0].hp).toBeLessThan(200); - expect(enemyPokemon[1].hp).toBe(200); + expect(enemyPokemon[0].hp).toBeLessThan(enemyStartingHp[0]); + expect(enemyPokemon[1].hp).toBe(enemyStartingHp[1]); }, TIMEOUT ); @@ -85,8 +85,6 @@ describe("Moves - Spotlight", () => { expect(enemyPokemon.length).toBe(2); enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); - enemyPokemon.forEach(p => p.hp = 200); - /** * Spotlight will target the slower enemy. In this situation without Spotlight being used, * the faster enemy would normally end up with the Center of Attention tag. @@ -95,6 +93,8 @@ describe("Moves - Spotlight", () => { const spotTarget = enemyPokemon[1].getBattlerIndex(); const attackTarget = enemyPokemon[0].getBattlerIndex(); + const enemyStartingHp = enemyPokemon.map(p => p.hp); + game.doAttack(getMovePosition(game.scene, 0, Moves.SPOTLIGHT)); await game.phaseInterceptor.to(SelectTargetPhase, false); game.doSelectTarget(spotTarget); @@ -105,8 +105,8 @@ describe("Moves - Spotlight", () => { game.doSelectTarget(attackTarget); await game.phaseInterceptor.to(TurnEndPhase, false); - expect(enemyPokemon[1].hp).toBeLessThan(200); - expect(enemyPokemon[0].hp).toBe(200); + expect(enemyPokemon[1].hp).toBeLessThan(enemyStartingHp[1]); + expect(enemyPokemon[0].hp).toBe(enemyStartingHp[0]); }, TIMEOUT ); });