From 2ebe8660a99d07cd240117fca477772d867cb0d8 Mon Sep 17 00:00:00 2001 From: DustinLin Date: Sat, 10 Aug 2024 13:18:06 -0400 Subject: [PATCH] adding tests --- src/test/moves/chilly_reception.test.ts | 69 +++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/test/moves/chilly_reception.test.ts diff --git a/src/test/moves/chilly_reception.test.ts b/src/test/moves/chilly_reception.test.ts new file mode 100644 index 00000000000..bb9df061d05 --- /dev/null +++ b/src/test/moves/chilly_reception.test.ts @@ -0,0 +1,69 @@ +import { SPLASH_ONLY } from "../utils/testUtils"; +import { BerryPhase, TurnInitPhase } from "#app/phases"; +import { WeatherType } from "#enums/weather-type"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; +import GameManager from "../utils/gameManager"; +import { getMovePosition } from "../utils/gameManagerUtils"; + +const TIMEOUT = 20 * 1000; + +describe("Moves - Chilly Reception", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + game.override.battleType("single"); + game.override.moveset([Moves.CHILLY_RECEPTION, Moves.SPLASH, Moves.SNOWSCAPE]); + game.override.enemyMoveset(SPLASH_ONLY); + game.override.startingLevel(5); + game.override.enemyLevel(5); + + }); + + test( + "Chilly reception should still change the weather if user can't switch out", + async () => { + await game.startBattle([Species.SLOWKING]); + + const enemyPokemon = game.scene.getEnemyPokemon()!; + expect(enemyPokemon).toBeDefined(); + game.doAttack(getMovePosition(game.scene, 0, Moves.CHILLY_RECEPTION)); + + await game.phaseInterceptor.to(BerryPhase, false); + expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW); + }, TIMEOUT + ); + + test( + "Chilly reception should switch out even if it's snowing", + async () => { + await game.startBattle([Species.SLOWKING, Species.MEOWTH]); + // first turn set up snow with snowscape, try chilly reception on second turn + game.doAttack(getMovePosition(game.scene, 0, Moves.SNOWSCAPE)); + await game.phaseInterceptor.to(BerryPhase, false); + expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW); + + await game.phaseInterceptor.to(TurnInitPhase, false); + game.doAttack(getMovePosition(game.scene, 0, Moves.CHILLY_RECEPTION)); + game.doSelectPartyPokemon(1); + + await game.phaseInterceptor.to(BerryPhase, false); + expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW); + expect(game.scene.getPlayerField()[0].species.speciesId).toBe(Species.MEOWTH); + }, TIMEOUT + ); +});