[Test] Optimize Quick Draw tests (#2625)

* optimize the tests

* add level override in favor of directly changing stats
This commit is contained in:
Dmitriy K 2024-06-26 17:01:14 -04:00 committed by GitHub
parent f3eeb6abea
commit 576f099243
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 35 additions and 62 deletions

View File

@ -1,16 +1,13 @@
import {afterEach, beforeAll, beforeEach, describe, expect, it, vi} from "vitest";
import Phaser from "phaser";
import GameManager from "#app/test/utils/gameManager";
import * as overrides from "#app/overrides";
import {Abilities} from "#enums/abilities";
import {Species} from "#enums/species";
import {EnemyCommandPhase, TitlePhase, TurnEndPhase, TurnStartPhase,
} from "#app/phases";
import * as Overrides from "#app/overrides";
import { Abilities } from "#enums/abilities";
import { Species } from "#enums/species";
import { FaintPhase } from "#app/phases";
import { Moves } from "#enums/moves";
import { Stat } from "#app/data/pokemon-stat";
import { getMovePosition } from "#app/test/utils/gameManagerUtils";
import { allAbilities, BypassSpeedChanceAbAttr } from "#app/data/ability";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
describe("Abilities - Quick Draw", () => {
let phaserGame: Phaser.Game;
@ -28,90 +25,66 @@ describe("Abilities - Quick Draw", () => {
beforeEach(() => {
game = new GameManager(phaserGame);
vi.spyOn(overrides, "SINGLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
vi.spyOn(overrides, "ABILITY_OVERRIDE", "get").mockReturnValue(
Abilities.QUICK_DRAW
);
vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(
Species.RATTATA
);
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([
Moves.TACKLE,
Moves.TACKLE,
Moves.TACKLE,
Moves.TACKLE,
]);
vi.spyOn(Overrides, "SINGLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
vi.spyOn(Overrides, "ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.QUICK_DRAW);
vi.spyOn(Overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.TACKLE, Moves.TAIL_WHIP]);
vi.spyOn(Overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(100);
vi.spyOn(Overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.RATTATA);
vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
vi.spyOn(
allAbilities[Abilities.QUICK_DRAW].getAttrs(BypassSpeedChanceAbAttr)[0],
"chance","get"
).mockReturnValue(100);
vi.spyOn(allAbilities[Abilities.QUICK_DRAW].getAttrs(BypassSpeedChanceAbAttr)[0], "chance", "get").mockReturnValue(100);
});
it("makes pokemon going first in its priority bracket", async() => {
test("makes pokemon going first in its priority bracket", async () => {
await game.startBattle([Species.SLOWBRO]);
const pokemon = game.scene.getParty()[0];
const enemy = game.scene.getEnemyParty()[0];
const pokemon = game.scene.getPlayerPokemon();
const enemy = game.scene.getEnemyPokemon();
pokemon.stats[Stat.SPD] = 50;
enemy.stats[Stat.SPD] = 150;
pokemon.hp = 1;
enemy.hp = 1;
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
await game.phaseInterceptor.to(FaintPhase, false);
await game.phaseInterceptor.run(EnemyCommandPhase);
await game.phaseInterceptor.run(TurnStartPhase);
await game.phaseInterceptor.to(TurnEndPhase);
expect(pokemon.battleData.abilityRevealed).toBe(true);
expect(pokemon.isFainted()).toBe(false);
expect(enemy.isFainted()).toBe(true);
expect(pokemon.battleData.abilitiesApplied).contain(Abilities.QUICK_DRAW);
}, 20000);
it("does not triggered by non damage moves", async () => {
test("does not triggered by non damage moves", async () => {
await game.startBattle([Species.SLOWBRO]);
const pokemon = game.scene.getParty()[0];
const enemy = game.scene.getEnemyParty()[0];
const pokemon = game.scene.getPlayerPokemon();
const enemy = game.scene.getEnemyPokemon();
pokemon.stats[Stat.SPD] = 50;
enemy.stats[Stat.SPD] = 150;
pokemon.hp = 1;
enemy.hp = 1;
game.doAttack(getMovePosition(game.scene, 0, Moves.TOXIC));
game.doAttack(getMovePosition(game.scene, 0, Moves.TAIL_WHIP));
await game.phaseInterceptor.to(FaintPhase, false);
await game.phaseInterceptor.run(EnemyCommandPhase);
await game.phaseInterceptor.run(TurnStartPhase);
await game.phaseInterceptor.to(TitlePhase);
expect(pokemon.battleData.abilityRevealed).not.toBe(true);
expect(pokemon.isFainted()).toBe(true);
expect(enemy.isFainted()).toBe(false);
expect(pokemon.battleData.abilitiesApplied).not.contain(Abilities.QUICK_DRAW);
}, 20000);
it("does not increase priority", async () => {
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([
Moves.EXTREME_SPEED,
Moves.EXTREME_SPEED,
Moves.EXTREME_SPEED,
Moves.EXTREME_SPEED,
]);
test("does not increase priority", async () => {
vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue(Array(4).fill(Moves.EXTREME_SPEED));
await game.startBattle([Species.SLOWBRO]);
const pokemon = game.scene.getParty()[0];
const enemy = game.scene.getEnemyParty()[0];
const pokemon = game.scene.getPlayerPokemon();
const enemy = game.scene.getEnemyPokemon();
pokemon.stats[Stat.SPD] = 50;
enemy.stats[Stat.SPD] = 150;
pokemon.hp = 1;
enemy.hp = 1;
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
await game.phaseInterceptor.to(FaintPhase, false);
await game.phaseInterceptor.run(EnemyCommandPhase);
await game.phaseInterceptor.run(TurnStartPhase);
await game.phaseInterceptor.to(TitlePhase);
expect(pokemon.battleData.abilityRevealed).toBe(true);
expect(pokemon.isFainted()).toBe(true);
expect(enemy.isFainted()).toBe(false);
expect(pokemon.battleData.abilitiesApplied).contain(Abilities.QUICK_DRAW);
}, 20000);
});