bonus uturn test

This commit is contained in:
snoozbuster 2024-08-12 21:38:24 -07:00
parent d6ec174715
commit c6e93985ca
1 changed files with 25 additions and 1 deletions

View File

@ -1,5 +1,5 @@
import { Abilities } from "#app/enums/abilities.js"; import { Abilities } from "#app/enums/abilities.js";
import { SwitchPhase, TurnEndPhase } from "#app/phases"; import { BerryPhase, SwitchPhase, TurnEndPhase } from "#app/phases";
import GameManager from "#app/test/utils/gameManager"; import GameManager from "#app/test/utils/gameManager";
import { getMovePosition } from "#app/test/utils/gameManagerUtils"; import { getMovePosition } from "#app/test/utils/gameManagerUtils";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
@ -8,6 +8,7 @@ import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { StatusEffect } from "#app/enums/status-effect.js"; import { StatusEffect } from "#app/enums/status-effect.js";
import { SPLASH_ONLY } from "../utils/testUtils"; import { SPLASH_ONLY } from "../utils/testUtils";
import { Mode } from "#app/ui/ui.js";
describe("Moves - U-turn", () => { describe("Moves - U-turn", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -97,4 +98,27 @@ describe("Moves - U-turn", () => {
expect(game.scene.getEnemyPokemon()!.battleData.abilityRevealed).toBe(true); // proxy for asserting ability activated expect(game.scene.getEnemyPokemon()!.battleData.abilityRevealed).toBe(true); // proxy for asserting ability activated
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase"); expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
}, 20000); }, 20000);
it("does not switch out the user if the move fails", async () => {
// arrange
game.override
.enemySpecies(Species.DUGTRIO)
.moveset(Moves.VOLT_SWITCH); // cheating a little here but no types are immune to bug
await game.startBattle([
Species.RAICHU,
Species.SHUCKLE
]);
// act
game.doAttack(getMovePosition(game.scene, 0, Moves.U_TURN));
game.onNextPrompt("SwitchPhase", Mode.PARTY, () => {
expect.fail("Switch was forced");
}, () => game.isCurrentPhase(BerryPhase));
await game.phaseInterceptor.to(BerryPhase, false);
// assert
const playerPkm = game.scene.getPlayerPokemon()!;
expect(playerPkm.species.speciesId).toEqual(Species.RAICHU);
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
}, 20000);
}); });