From 45e3c6bf87e8a626a709e398badda892bb37af3c Mon Sep 17 00:00:00 2001 From: flx-sta <50131232+flx-sta@users.noreply.github.com> Date: Sun, 22 Sep 2024 19:36:35 -0700 Subject: [PATCH] fix: shell side arm test flakyness some rng could affect the tests thus it wasn't guaranteed to be consistent in its result. Fixed that by taking control of `getBaseDamage()` with a spy --- src/test/moves/shell_side_arm.test.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/test/moves/shell_side_arm.test.ts b/src/test/moves/shell_side_arm.test.ts index ded7ed82fd1..b5bf4eaaa41 100644 --- a/src/test/moves/shell_side_arm.test.ts +++ b/src/test/moves/shell_side_arm.test.ts @@ -1,5 +1,5 @@ import { BattlerIndex } from "#app/battle"; -import { allMoves, ShellSideArmCategoryAttr } from "#app/data/move"; +import { allMoves, MoveCategory, ShellSideArmCategoryAttr } from "#app/data/move"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; @@ -36,6 +36,15 @@ describe("Moves - Shell Side Arm", () => { await game.classicMode.startBattle([Species.MANAPHY]); + const enemySnorlax = game.scene.getEnemyPokemon()!; + vi.spyOn(enemySnorlax, "getBaseDamage").mockImplementation((_user, _move, category) => { + if (category === MoveCategory.PHYSICAL) { + return 100; + } else { + return 10; + } + }); + const shellSideArm = allMoves[Moves.SHELL_SIDE_ARM]; const shellSideArmAttr = shellSideArm.getAttrs(ShellSideArmCategoryAttr)[0]; vi.spyOn(shellSideArmAttr, "apply"); @@ -52,6 +61,15 @@ describe("Moves - Shell Side Arm", () => { await game.classicMode.startBattle([Species.MANAPHY]); + const enemySlowbro = game.scene.getEnemyPokemon()!; + vi.spyOn(enemySlowbro, "getBaseDamage").mockImplementation((_user, _move, category) => { + if (category === MoveCategory.SPECIAL) { + return 100; + } else { + return 10; + } + }); + const shellSideArm = allMoves[Moves.SHELL_SIDE_ARM]; const shellSideArmAttr = shellSideArm.getAttrs(ShellSideArmCategoryAttr)[0]; vi.spyOn(shellSideArmAttr, "apply");