[Unittest] Remove HP assignment in unit tests (#2466)

This commit is contained in:
innerthunder 2024-06-20 12:02:17 -07:00 committed by GitHub
parent f9d74aa836
commit 22e26621b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 21 deletions

View File

@ -54,7 +54,7 @@ describe("Moves - Follow Me", () => {
expect(enemyPokemon.length).toBe(2); expect(enemyPokemon.length).toBe(2);
enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); 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)); game.doAttack(getMovePosition(game.scene, 0, Moves.FOLLOW_ME));
await game.phaseInterceptor.to(CommandPhase); await game.phaseInterceptor.to(CommandPhase);
@ -65,8 +65,8 @@ describe("Moves - Follow Me", () => {
game.doSelectTarget(BattlerIndex.ENEMY); game.doSelectTarget(BattlerIndex.ENEMY);
await game.phaseInterceptor.to(TurnEndPhase, false); await game.phaseInterceptor.to(TurnEndPhase, false);
expect(playerPokemon[0].hp).toBeLessThan(200); expect(playerPokemon[0].hp).toBeLessThan(playerStartingHp[0]);
expect(playerPokemon[1].hp).toBe(200); expect(playerPokemon[1].hp).toBe(playerStartingHp[1]);
}, TIMEOUT }, TIMEOUT
); );
@ -83,7 +83,7 @@ describe("Moves - Follow Me", () => {
expect(enemyPokemon.length).toBe(2); expect(enemyPokemon.length).toBe(2);
enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); 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)); game.doAttack(getMovePosition(game.scene, 0, Moves.FOLLOW_ME));
await game.phaseInterceptor.to(CommandPhase); 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)); playerPokemon.sort((a, b) => a.getBattleStat(Stat.SPD) - b.getBattleStat(Stat.SPD));
expect(playerPokemon[1].hp).toBeLessThan(200); expect(playerPokemon[1].hp).toBeLessThan(playerStartingHp[1]);
expect(playerPokemon[0].hp).toBe(200); expect(playerPokemon[0].hp).toBe(playerStartingHp[0]);
}, TIMEOUT }, TIMEOUT
); );
@ -115,7 +115,7 @@ describe("Moves - Follow Me", () => {
expect(enemyPokemon.length).toBe(2); expect(enemyPokemon.length).toBe(2);
enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); 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)); game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK));
await game.phaseInterceptor.to(SelectTargetPhase, false); await game.phaseInterceptor.to(SelectTargetPhase, false);
@ -128,7 +128,8 @@ describe("Moves - Follow Me", () => {
await game.phaseInterceptor.to(TurnEndPhase, false); await game.phaseInterceptor.to(TurnEndPhase, false);
// If redirection was bypassed, both enemies should be damaged // 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 }, TIMEOUT
); );
@ -148,7 +149,7 @@ describe("Moves - Follow Me", () => {
expect(enemyPokemon.length).toBe(2); expect(enemyPokemon.length).toBe(2);
enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); 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)); game.doAttack(getMovePosition(game.scene, 0, Moves.SNIPE_SHOT));
await game.phaseInterceptor.to(SelectTargetPhase, false); await game.phaseInterceptor.to(SelectTargetPhase, false);
@ -161,7 +162,8 @@ describe("Moves - Follow Me", () => {
await game.phaseInterceptor.to(TurnEndPhase, false); await game.phaseInterceptor.to(TurnEndPhase, false);
// If redirection was bypassed, both enemies should be damaged // 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 }, TIMEOUT
); );
}); });

View File

@ -55,7 +55,7 @@ describe("Moves - Rage Powder", () => {
expect(enemyPokemon.length).toBe(2); expect(enemyPokemon.length).toBe(2);
enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); 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)); game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK));
await game.phaseInterceptor.to(SelectTargetPhase, false); await game.phaseInterceptor.to(SelectTargetPhase, false);
@ -68,7 +68,8 @@ describe("Moves - Rage Powder", () => {
await game.phaseInterceptor.to(TurnEndPhase, false); await game.phaseInterceptor.to(TurnEndPhase, false);
// If redirection was bypassed, both enemies should be damaged // 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 }, TIMEOUT
); );
@ -89,7 +90,7 @@ describe("Moves - Rage Powder", () => {
expect(enemyPokemon.length).toBe(2); expect(enemyPokemon.length).toBe(2);
enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); 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)); game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK));
await game.phaseInterceptor.to(SelectTargetPhase, false); await game.phaseInterceptor.to(SelectTargetPhase, false);
@ -102,7 +103,8 @@ describe("Moves - Rage Powder", () => {
await game.phaseInterceptor.to(TurnEndPhase, false); await game.phaseInterceptor.to(TurnEndPhase, false);
// If redirection was bypassed, both enemies should be damaged // 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 }, TIMEOUT
); );
}); });

View File

@ -53,7 +53,7 @@ describe("Moves - Spotlight", () => {
expect(enemyPokemon.length).toBe(2); expect(enemyPokemon.length).toBe(2);
enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); 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)); game.doAttack(getMovePosition(game.scene, 0, Moves.SPOTLIGHT));
await game.phaseInterceptor.to(SelectTargetPhase, false); await game.phaseInterceptor.to(SelectTargetPhase, false);
@ -65,8 +65,8 @@ describe("Moves - Spotlight", () => {
game.doSelectTarget(BattlerIndex.ENEMY_2); game.doSelectTarget(BattlerIndex.ENEMY_2);
await game.phaseInterceptor.to(TurnEndPhase, false); await game.phaseInterceptor.to(TurnEndPhase, false);
expect(enemyPokemon[0].hp).toBeLessThan(200); expect(enemyPokemon[0].hp).toBeLessThan(enemyStartingHp[0]);
expect(enemyPokemon[1].hp).toBe(200); expect(enemyPokemon[1].hp).toBe(enemyStartingHp[1]);
}, TIMEOUT }, TIMEOUT
); );
@ -85,8 +85,6 @@ describe("Moves - Spotlight", () => {
expect(enemyPokemon.length).toBe(2); expect(enemyPokemon.length).toBe(2);
enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); 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, * 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. * 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 spotTarget = enemyPokemon[1].getBattlerIndex();
const attackTarget = enemyPokemon[0].getBattlerIndex(); const attackTarget = enemyPokemon[0].getBattlerIndex();
const enemyStartingHp = enemyPokemon.map(p => p.hp);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPOTLIGHT)); game.doAttack(getMovePosition(game.scene, 0, Moves.SPOTLIGHT));
await game.phaseInterceptor.to(SelectTargetPhase, false); await game.phaseInterceptor.to(SelectTargetPhase, false);
game.doSelectTarget(spotTarget); game.doSelectTarget(spotTarget);
@ -105,8 +105,8 @@ describe("Moves - Spotlight", () => {
game.doSelectTarget(attackTarget); game.doSelectTarget(attackTarget);
await game.phaseInterceptor.to(TurnEndPhase, false); await game.phaseInterceptor.to(TurnEndPhase, false);
expect(enemyPokemon[1].hp).toBeLessThan(200); expect(enemyPokemon[1].hp).toBeLessThan(enemyStartingHp[1]);
expect(enemyPokemon[0].hp).toBe(200); expect(enemyPokemon[0].hp).toBe(enemyStartingHp[0]);
}, TIMEOUT }, TIMEOUT
); );
}); });