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
This commit is contained in:
flx-sta 2024-09-22 19:36:35 -07:00
parent 107a7497a9
commit 45e3c6bf87

View File

@ -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");