pokerogue/src/test/field/pokemon.test.ts
PrabbyDD d99dbf4955
[P2] Fix for Pokemon Forms have Access to Other Forms' TM Movepools (#4398)
* fixing form issues generating tms pokemon shouldnt have

* cleaning up some code

* fixing tests and allowing rotom unique moves to be learned as tms for that rotom form

* Update src/test/field/pokemon.test.ts

Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com>

* making tests simpler

---------

Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com>
2024-09-29 22:00:29 -04:00

79 lines
2.4 KiB
TypeScript

import { Species } from "#app/enums/species";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import GameManager from "../utils/gameManager";
import { PokeballType } from "#app/enums/pokeball";
import BattleScene from "#app/battle-scene";
import { Moves } from "#app/enums/moves";
describe("Spec - Pokemon", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
});
it("should not crash when trying to set status of undefined", async () => {
await game.classicMode.runToSummon([Species.ABRA]);
const pkm = game.scene.getPlayerPokemon()!;
expect(pkm).toBeDefined();
expect(pkm.trySetStatus(undefined)).toBe(true);
});
describe("Add To Party", () => {
let scene: BattleScene;
beforeEach(async () => {
game.override.enemySpecies(Species.ZUBAT);
await game.classicMode.runToSummon([Species.ABRA, Species.ABRA, Species.ABRA, Species.ABRA, Species.ABRA]); // 5 Abra, only 1 slot left
scene = game.scene;
});
it("should append a new pokemon by default", async () => {
const zubat = scene.getEnemyPokemon()!;
zubat.addToParty(PokeballType.LUXURY_BALL);
const party = scene.getParty();
expect(party).toHaveLength(6);
party.forEach((pkm, index) =>{
expect(pkm.species.speciesId).toBe(index === 5 ? Species.ZUBAT : Species.ABRA);
});
});
it("should put a new pokemon into the passed slotIndex", async () => {
const slotIndex = 1;
const zubat = scene.getEnemyPokemon()!;
zubat.addToParty(PokeballType.LUXURY_BALL, slotIndex);
const party = scene.getParty();
expect(party).toHaveLength(6);
party.forEach((pkm, index) =>{
expect(pkm.species.speciesId).toBe(index === slotIndex ? Species.ZUBAT : Species.ABRA);
});
});
});
it("should not share tms between different forms", async () => {
game.override.starterForms({ [Species.ROTOM]: 4 });
await game.classicMode.startBattle([Species.ROTOM]);
const fanRotom = game.scene.getPlayerPokemon()!;
expect(fanRotom.compatibleTms).not.toContain(Moves.BLIZZARD);
expect(fanRotom.compatibleTms).toContain(Moves.AIR_SLASH);
});
});