From 00f9536d3a67e47141882c33b8d2098072dd6851 Mon Sep 17 00:00:00 2001 From: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Date: Mon, 15 Sep 2025 23:54:12 -0500 Subject: [PATCH] Add regression test to ensure pokemon generates with sufficient move counts --- test/ai/ai-moveset-gen.test.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/test/ai/ai-moveset-gen.test.ts b/test/ai/ai-moveset-gen.test.ts index 6d927926131..faec3856485 100644 --- a/test/ai/ai-moveset-gen.test.ts +++ b/test/ai/ai-moveset-gen.test.ts @@ -1,4 +1,4 @@ -import { __INTERNAL_TEST_EXPORTS } from "#app/ai/ai-moveset-gen"; +import { __INTERNAL_TEST_EXPORTS, generateMoveset } from "#app/ai/ai-moveset-gen"; import { COMMON_TIER_TM_LEVEL_REQUIREMENT, GREAT_TIER_TM_LEVEL_REQUIREMENT, @@ -282,4 +282,28 @@ describe("Regression Tests - ai-moveset-gen.ts", () => { ).not.toThrow(); }); }); + + describe("generateMoveset", () => { + it("should spawn with 4 moves if possible", async () => { + // Need to be in a wave for moveset generation to not actually break + await game.classicMode.startBattle([SpeciesId.PIKACHU]); + + // Create a pokemon that can learn at least 4 moves + pokemon = createTestablePokemon(SpeciesId.ROCKRUFF, { level: 15 }); + vi.spyOn(pokemon, "getLevelMoves").mockReturnValue([ + [1, MoveId.TACKLE], + [4, MoveId.LEER], + [7, MoveId.SAND_ATTACK], + [10, MoveId.ROCK_THROW], + [13, MoveId.DOUBLE_TEAM], + ]); + + // Generate the moveset + generateMoveset(pokemon); + expect(pokemon.moveset).toHaveLength(4); + // Unlike other test suites, phase interceptor is not automatically restored after the tests here, + // since most tests in this suite do not need the phase + game.phaseInterceptor.restoreOg(); + }); + }); });