mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 07:52:17 +02:00
Stop on EndEvolutionPhase
to prevent game state leak in tests
This commit is contained in:
parent
622e077520
commit
7101f4f0fa
@ -114,7 +114,7 @@ describe("Evolution", () => {
|
|||||||
expect(golem.hp).toBe(1);
|
expect(golem.hp).toBe(1);
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF));
|
||||||
await game.phaseInterceptor.to("EvolutionPhase");
|
await game.phaseInterceptor.to("EndEvolutionPhase");
|
||||||
|
|
||||||
expect(totodile.hp).toBe(totodile.getMaxHp());
|
expect(totodile.hp).toBe(totodile.getMaxHp());
|
||||||
expect(totodile.hp).toBeGreaterThan(hpBefore);
|
expect(totodile.hp).toBeGreaterThan(hpBefore);
|
||||||
@ -125,17 +125,17 @@ describe("Evolution", () => {
|
|||||||
.enemySpecies(Species.GOLEM)
|
.enemySpecies(Species.GOLEM)
|
||||||
.enemyMoveset(SPLASH_ONLY)
|
.enemyMoveset(SPLASH_ONLY)
|
||||||
.startingWave(21)
|
.startingWave(21)
|
||||||
.startingLevel(16)
|
.startingLevel(13)
|
||||||
.enemyLevel(50);
|
.enemyLevel(30);
|
||||||
|
|
||||||
await game.startBattle([Species.TOTODILE]);
|
await game.startBattle([Species.CYNDAQUIL]);
|
||||||
|
|
||||||
const totodile = game.scene.getPlayerPokemon()!;
|
const cyndaquil = game.scene.getPlayerPokemon()!;
|
||||||
totodile.hp = totodile.getMaxHp() / 2;
|
cyndaquil.hp = Math.floor(cyndaquil.getMaxHp() / 2);
|
||||||
const hpBefore = totodile.hp;
|
const hpBefore = cyndaquil.hp;
|
||||||
const maxHpBefore = totodile.getMaxHp();
|
const maxHpBefore = cyndaquil.getMaxHp();
|
||||||
|
|
||||||
expect(totodile.hp).toBe(totodile.getMaxHp() / 2);
|
expect(cyndaquil.hp).toBe(Math.floor(cyndaquil.getMaxHp() / 2));
|
||||||
|
|
||||||
const golem = game.scene.getEnemyPokemon()!;
|
const golem = game.scene.getEnemyPokemon()!;
|
||||||
golem.hp = 1;
|
golem.hp = 1;
|
||||||
@ -143,10 +143,10 @@ describe("Evolution", () => {
|
|||||||
expect(golem.hp).toBe(1);
|
expect(golem.hp).toBe(1);
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF));
|
||||||
await game.phaseInterceptor.to("EvolutionPhase");
|
await game.phaseInterceptor.to("EndEvolutionPhase");
|
||||||
|
|
||||||
expect(totodile.getMaxHp()).toBeGreaterThan(maxHpBefore);
|
expect(cyndaquil.getMaxHp()).toBeGreaterThan(maxHpBefore);
|
||||||
expect(totodile.hp).toBeGreaterThan(hpBefore);
|
expect(cyndaquil.hp).toBeGreaterThan(hpBefore);
|
||||||
expect(totodile.hp).toBeLessThan(totodile.getMaxHp());
|
expect(cyndaquil.hp).toBeLessThan(cyndaquil.getMaxHp());
|
||||||
}, TIMEOUT);
|
}, TIMEOUT);
|
||||||
});
|
});
|
||||||
|
@ -38,7 +38,7 @@ import UI, { Mode } from "#app/ui/ui";
|
|||||||
import { Phase } from "#app/phase";
|
import { Phase } from "#app/phase";
|
||||||
import ErrorInterceptor from "#app/test/utils/errorInterceptor";
|
import ErrorInterceptor from "#app/test/utils/errorInterceptor";
|
||||||
import { QuietFormChangePhase } from "#app/form-change-phase";
|
import { QuietFormChangePhase } from "#app/form-change-phase";
|
||||||
import { EvolutionPhase } from "#app/evolution-phase.js";
|
import { EndEvolutionPhase, EvolutionPhase } from "#app/evolution-phase.js";
|
||||||
|
|
||||||
export default class PhaseInterceptor {
|
export default class PhaseInterceptor {
|
||||||
public scene;
|
public scene;
|
||||||
@ -94,6 +94,7 @@ export default class PhaseInterceptor {
|
|||||||
[SwitchPhase, this.startPhase],
|
[SwitchPhase, this.startPhase],
|
||||||
[SwitchSummonPhase, this.startPhase],
|
[SwitchSummonPhase, this.startPhase],
|
||||||
[EvolutionPhase, this.startPhase],
|
[EvolutionPhase, this.startPhase],
|
||||||
|
[EndEvolutionPhase, this.startPhase],
|
||||||
];
|
];
|
||||||
|
|
||||||
private endBySetMode = [
|
private endBySetMode = [
|
||||||
|
Loading…
Reference in New Issue
Block a user