add simple tests for addToParty

This commit is contained in:
flx-sta 2024-09-04 13:15:49 -07:00
parent 846ae97f7c
commit be2d9d90b8

View File

@ -1,6 +1,8 @@
import { Species } from "#app/enums/species"; import { Species } from "#app/enums/species";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import GameManager from "../utils/gameManager"; import GameManager from "../utils/gameManager";
import { PokeballType } from "#app/enums/pokeball.js";
import BattleScene from "#app/battle-scene.js";
describe("Spec - Pokemon", () => { describe("Spec - Pokemon", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -28,4 +30,37 @@ describe("Spec - Pokemon", () => {
expect(pkm.trySetStatus(undefined)).toBe(true); 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);
});
});
});
}); });