mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-10-30 16:05:52 +01:00
* Modify tests to use overrides helper functions * Apply stylistic consistency to overrides in tests Also remove some non-test-related expects()
192 lines
5.4 KiB
TypeScript
192 lines
5.4 KiB
TypeScript
import { TerrainType, getTerrainName } from "#app/data/terrain";
|
|
import { getTerrainBlockMessage, getTerrainClearMessage, getTerrainStartMessage } from "#app/data/weather";
|
|
import GameManager from "#test/utils/gameManager";
|
|
import { Species } from "#enums/species";
|
|
import i18next from "i18next";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { mockI18next } from "#test/utils/testUtils";
|
|
|
|
describe("terrain", () => {
|
|
let phaserGame: Phaser.Game;
|
|
let game: GameManager;
|
|
|
|
beforeAll(() => {
|
|
phaserGame = new Phaser.Game({
|
|
type: Phaser.HEADLESS,
|
|
});
|
|
i18next.init();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
game = new GameManager(phaserGame);
|
|
game.override.battleType("single");
|
|
});
|
|
|
|
describe("NONE", () => {
|
|
const terrainType = TerrainType.NONE;
|
|
|
|
it("should return the obtain text", () => {
|
|
mockI18next();
|
|
|
|
const text = getTerrainName(terrainType);
|
|
expect(text).toBe("");
|
|
});
|
|
|
|
it("should return the start text", () => {
|
|
mockI18next();
|
|
|
|
const text = getTerrainStartMessage(terrainType);
|
|
expect(text).toBe(undefined);
|
|
});
|
|
|
|
it("should return the clear text", () => {
|
|
mockI18next();
|
|
const text = getTerrainClearMessage(terrainType);
|
|
expect(text).toBe(undefined);
|
|
});
|
|
|
|
it("should return the block text", async () => {
|
|
await game.startBattle([Species.MAGIKARP]);
|
|
const pokemon = game.scene.getPlayerPokemon();
|
|
mockI18next();
|
|
const text = getTerrainBlockMessage(pokemon, terrainType);
|
|
expect(text).toBe("terrain:defaultBlockMessage");
|
|
});
|
|
});
|
|
|
|
describe("MISTY", () => {
|
|
const terrainType = TerrainType.MISTY;
|
|
|
|
it("should return the obtain text", () => {
|
|
mockI18next();
|
|
|
|
const text = getTerrainName(terrainType);
|
|
expect(text).toBe("terrain:misty");
|
|
});
|
|
|
|
it("should return the start text", () => {
|
|
mockI18next();
|
|
|
|
const text = getTerrainStartMessage(terrainType);
|
|
expect(text).toBe("terrain:mistyStartMessage");
|
|
});
|
|
|
|
it("should return the clear text", () => {
|
|
mockI18next();
|
|
const text = getTerrainClearMessage(terrainType);
|
|
expect(text).toBe("terrain:mistyClearMessage");
|
|
});
|
|
|
|
it("should return the block text", async () => {
|
|
await game.startBattle([Species.MAGIKARP]);
|
|
const pokemon = game.scene.getPlayerPokemon();
|
|
mockI18next();
|
|
const text = getTerrainBlockMessage(pokemon, terrainType);
|
|
expect(text).toBe("terrain:mistyBlockMessage");
|
|
});
|
|
});
|
|
|
|
describe("ELECTRIC", () => {
|
|
const terrainType = TerrainType.ELECTRIC;
|
|
|
|
it("should return the obtain text", () => {
|
|
mockI18next();
|
|
|
|
const text = getTerrainName(terrainType);
|
|
expect(text).toBe("terrain:electric");
|
|
});
|
|
|
|
it("should return the start text", () => {
|
|
mockI18next();
|
|
|
|
const text = getTerrainStartMessage(terrainType);
|
|
expect(text).toBe("terrain:electricStartMessage");
|
|
});
|
|
|
|
it("should return the clear text", () => {
|
|
mockI18next();
|
|
const text = getTerrainClearMessage(terrainType);
|
|
expect(text).toBe("terrain:electricClearMessage");
|
|
});
|
|
|
|
it("should return the block text", async () => {
|
|
await game.startBattle([Species.MAGIKARP]);
|
|
const pokemon = game.scene.getPlayerPokemon();
|
|
mockI18next();
|
|
const text = getTerrainBlockMessage(pokemon, terrainType);
|
|
expect(text).toBe("terrain:defaultBlockMessage");
|
|
});
|
|
});
|
|
|
|
describe("GRASSY", () => {
|
|
const terrainType = TerrainType.GRASSY;
|
|
|
|
it("should return the obtain text", () => {
|
|
mockI18next();
|
|
|
|
const text = getTerrainName(terrainType);
|
|
expect(text).toBe("terrain:grassy");
|
|
});
|
|
|
|
it("should return the start text", () => {
|
|
mockI18next();
|
|
|
|
const text = getTerrainStartMessage(terrainType);
|
|
expect(text).toBe("terrain:grassyStartMessage");
|
|
});
|
|
|
|
it("should return the clear text", () => {
|
|
mockI18next();
|
|
const text = getTerrainClearMessage(terrainType);
|
|
expect(text).toBe("terrain:grassyClearMessage");
|
|
});
|
|
|
|
it("should return the block text", async () => {
|
|
await game.startBattle([Species.MAGIKARP]);
|
|
const pokemon = game.scene.getPlayerPokemon();
|
|
mockI18next();
|
|
const text = getTerrainBlockMessage(pokemon, terrainType);
|
|
expect(text).toBe("terrain:defaultBlockMessage");
|
|
});
|
|
});
|
|
|
|
describe("PSYCHIC", () => {
|
|
const terrainType = TerrainType.PSYCHIC;
|
|
|
|
it("should return the obtain text", () => {
|
|
mockI18next();
|
|
|
|
const text = getTerrainName(terrainType);
|
|
expect(text).toBe("terrain:psychic");
|
|
});
|
|
|
|
it("should return the start text", () => {
|
|
mockI18next();
|
|
|
|
const text = getTerrainStartMessage(terrainType);
|
|
expect(text).toBe("terrain:psychicStartMessage");
|
|
});
|
|
|
|
it("should return the clear text", () => {
|
|
mockI18next();
|
|
const text = getTerrainClearMessage(terrainType);
|
|
expect(text).toBe("terrain:psychicClearMessage");
|
|
});
|
|
|
|
it("should return the block text", async () => {
|
|
await game.startBattle([Species.MAGIKARP]);
|
|
const pokemon = game.scene.getPlayerPokemon();
|
|
mockI18next();
|
|
const text = getTerrainBlockMessage(pokemon, terrainType);
|
|
expect(text).toBe("terrain:defaultBlockMessage");
|
|
});
|
|
});
|
|
|
|
|
|
afterEach(() => {
|
|
game.phaseInterceptor.restoreOg();
|
|
vi.resetAllMocks();
|
|
});
|
|
});
|