Skip to content

Commit

Permalink
[Unittest] Remove HP assignment in unit tests (pagefaultgames#2466)
Browse files Browse the repository at this point in the history
  • Loading branch information
innerthunder authored Jun 20, 2024
1 parent f9d74aa commit 22e2662
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
22 changes: 12 additions & 10 deletions src/test/moves/follow_me.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
);

Expand All @@ -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);
Expand All @@ -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
);

Expand All @@ -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);
Expand All @@ -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
);

Expand All @@ -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);
Expand All @@ -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
);
});
10 changes: 6 additions & 4 deletions src/test/moves/rage_powder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
);

Expand All @@ -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);
Expand All @@ -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
);
});
14 changes: 7 additions & 7 deletions src/test/moves/spotlight.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
);

Expand All @@ -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.
Expand All @@ -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);
Expand All @@ -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
);
});

0 comments on commit 22e2662

Please sign in to comment.