diff --git a/src/test/evolution.test.ts b/src/test/evolution.test.ts index b54deaa4611..c935d1a9ecd 100644 --- a/src/test/evolution.test.ts +++ b/src/test/evolution.test.ts @@ -1,9 +1,12 @@ import { pokemonEvolutions, SpeciesFormEvolution, SpeciesWildEvolutionDelay } from "#app/data/pokemon-evolutions.js"; import { Abilities } from "#app/enums/abilities.js"; +import { Moves } from "#app/enums/moves.js"; import { Species } from "#app/enums/species.js"; import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; +import { getMovePosition } from "./utils/gameManagerUtils"; +import { SPLASH_ONLY } from "./utils/testUtils"; describe("Evolution", () => { let phaserGame: Phaser.Game; @@ -89,4 +92,29 @@ describe("Evolution", () => { expect(speciesFormEvo.wildDelay).toBe(SpeciesWildEvolutionDelay.NONE); }); + + it("should increase both HP and max HP when evolving", async () => { + game.override.moveset([Moves.SURF]) + .enemySpecies(Species.GOLEM) + .enemyMoveset(SPLASH_ONLY) + .startingWave(21) + .startingLevel(16) + .enemyLevel(50); + + await game.startBattle([Species.TOTODILE]); + + const totodile = game.scene.getPlayerPokemon()!; + const hpBefore = totodile.hp; + + const enemyGolem = game.scene.getEnemyPokemon()!; + enemyGolem.hp = 1; + + expect(totodile.hp).toBe(totodile.getMaxHp()); + + game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); + await game.phaseInterceptor.to("EvolutionPhase"); + + expect(totodile.hp).toBe(totodile.getMaxHp()); + expect(totodile.hp).toBeGreaterThan(hpBefore); + }, TIMEOUT); }); diff --git a/src/test/utils/mocks/mockTextureManager.ts b/src/test/utils/mocks/mockTextureManager.ts index 330409e9776..fb197dfdc06 100644 --- a/src/test/utils/mocks/mockTextureManager.ts +++ b/src/test/utils/mocks/mockTextureManager.ts @@ -7,6 +7,8 @@ import MockText from "#test/utils/mocks/mocksContainer/mockText"; import MockPolygon from "#test/utils/mocks/mocksContainer/mockPolygon"; import { MockGameObject } from "./mockGameObject"; import MockTexture from "#test/utils/mocks/mocksContainer/mockTexture"; +import { vi } from "vitest"; +import { MockVideoGameObject } from "./mockVideoGameObject"; /** * Stub class for Phaser.Textures.TextureManager @@ -34,6 +36,7 @@ export default class MockTextureManager { text: this.text.bind(this), bitmapText: this.text.bind(this), displayList: this.displayList, + video: vi.fn(() => new MockVideoGameObject()), }; } diff --git a/src/test/utils/mocks/mockVideoGameObject.ts b/src/test/utils/mocks/mockVideoGameObject.ts new file mode 100644 index 00000000000..4ab371ed9fc --- /dev/null +++ b/src/test/utils/mocks/mockVideoGameObject.ts @@ -0,0 +1,12 @@ +import { vi } from "vitest"; +import { MockGameObject } from "./mockGameObject"; + +export class MockVideoGameObject implements MockGameObject { + constructor() {} + + public play = vi.fn(); + public stop = vi.fn(() => this); + public setOrigin = vi.fn(); + public setScale = vi.fn(); + public setVisible = vi.fn(); +} diff --git a/src/test/utils/phaseInterceptor.ts b/src/test/utils/phaseInterceptor.ts index 34f79f93b6e..d404afe04d4 100644 --- a/src/test/utils/phaseInterceptor.ts +++ b/src/test/utils/phaseInterceptor.ts @@ -38,6 +38,7 @@ import UI, { Mode } from "#app/ui/ui"; import { Phase } from "#app/phase"; import ErrorInterceptor from "#app/test/utils/errorInterceptor"; import { QuietFormChangePhase } from "#app/form-change-phase"; +import { EvolutionPhase } from "#app/evolution-phase.js"; export default class PhaseInterceptor { public scene; @@ -92,6 +93,7 @@ export default class PhaseInterceptor { [QuietFormChangePhase, this.startPhase], [SwitchPhase, this.startPhase], [SwitchSummonPhase, this.startPhase], + [EvolutionPhase, this.startPhase], ]; private endBySetMode = [