Fixed tests and such

This commit is contained in:
Bertie690 2025-07-28 12:06:05 -04:00
parent 0a3e4f9615
commit 7fc96aa8c4
6 changed files with 25 additions and 13 deletions

View File

@ -117,7 +117,10 @@ declare module "vitest" {
toHaveHp(expectedHp: number): void;
/**
* Check whether a {@linkcode Pokemon} has fainted (as determined by {@linkcode Pokemon.isFainted}).
* Check whether a {@linkcode Pokemon} is currently fainted (as determined by {@linkcode Pokemon.isFainted}).
* @remarks
* When checking whether an enemy wild Pokemon is fainted, one must reference it in a variable _before_ the fainting effect occurs
* as otherwise the Pokemon will be GC'ed and rendered `undefined`.
*/
toHaveFainted(): void;
@ -127,7 +130,8 @@ declare module "vitest" {
* @param ppUsed - The numerical amount of PP that should have been consumed,
* or `all` to indicate the move should be _out_ of PP
* @remarks
* If the Pokemon's moveset has been set via {@linkcode Overrides.MOVESET_OVERRIDE}/{@linkcode Overrides.OPP_MOVESET_OVERRIDE}
* If the Pokemon's moveset has been set via {@linkcode Overrides.MOVESET_OVERRIDE}/{@linkcode Overrides.OPP_MOVESET_OVERRIDE},
* does not contain {@linkcode expectedMove}
* or contains the desired move more than once, this will fail the test.
*/
toHaveUsedPP(expectedMove: MoveId, ppUsed: number | "all"): void;

View File

@ -35,14 +35,15 @@ describe("Moves - Grudge", () => {
it("should reduce the PP of an attack that faints the user to 0", async () => {
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
const feebas = game.field.getPlayerPokemon();
const ratatta = game.field.getEnemyPokemon();
game.move.use(MoveId.GUILLOTINE);
await game.move.forceEnemyMove(MoveId.GRUDGE);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.toEndOfTurn();
await game.phaseInterceptor.to("FaintPhase");
// Ratatta should have fainted and consumed all of Guillotine's PP
const feebas = game.field.getPlayerPokemon();
const ratatta = game.field.getEnemyPokemon();
expect(ratatta).toHaveFainted();
expect(feebas).toHaveUsedPP(MoveId.GUILLOTINE, "all");
});
@ -50,6 +51,9 @@ describe("Moves - Grudge", () => {
it("should remain in effect until the user's next move", async () => {
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
const feebas = game.field.getPlayerPokemon();
const ratatta = game.field.getEnemyPokemon();
game.move.use(MoveId.SPLASH);
await game.move.forceEnemyMove(MoveId.GRUDGE);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
@ -60,8 +64,6 @@ describe("Moves - Grudge", () => {
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.toEndOfTurn();
const feebas = game.field.getPlayerPokemon();
const ratatta = game.field.getEnemyPokemon();
expect(ratatta).toHaveFainted();
expect(feebas).toHaveUsedPP(MoveId.GUILLOTINE, "all");
});
@ -71,13 +73,14 @@ describe("Moves - Grudge", () => {
game.override.weather(WeatherType.SANDSTORM);
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
const feebas = game.field.getPlayerPokemon();
const ratatta = game.field.getEnemyPokemon();
game.move.use(MoveId.FALSE_SWIPE);
await game.move.forceEnemyMove(MoveId.GRUDGE);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.toEndOfTurn();
const feebas = game.field.getPlayerPokemon();
const ratatta = game.field.getEnemyPokemon();
expect(ratatta).toHaveFainted();
expect(feebas).toHaveUsedPP(MoveId.FALSE_SWIPE, 1);
});

View File

@ -40,7 +40,7 @@ describe("Moves - Spite", () => {
const karp = game.field.getEnemyPokemon();
game.move.changeMoveset(karp, [MoveId.SPLASH, MoveId.TACKLE]);
game.move.use(MoveId.SPLASH);
game.move.use(MoveId.SPITE);
await game.move.selectEnemyMove(MoveId.TACKLE);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.toNextTurn();
@ -48,7 +48,7 @@ describe("Moves - Spite", () => {
expect(karp).toHaveUsedPP(MoveId.TACKLE, 1);
game.move.use(MoveId.SPITE);
await game.move.forceEnemyMove(MoveId.SPLASH);
await game.move.selectEnemyMove(MoveId.SPLASH);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.toEndOfTurn();
@ -61,7 +61,7 @@ describe("Moves - Spite", () => {
const karp = game.field.getEnemyPokemon();
game.move.changeMoveset(karp, [MoveId.SPLASH, MoveId.TACKLE]);
game.move.use(MoveId.SPLASH);
game.move.use(MoveId.SPITE);
await game.move.selectEnemyMove(MoveId.TACKLE);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.toEndOfTurn();
@ -77,7 +77,7 @@ describe("Moves - Spite", () => {
game.move.changeMoveset(karp, [MoveId.TACKLE]);
karp.moveset[0].ppUsed = 0;
game.move.use(MoveId.SPLASH);
game.move.use(MoveId.SPITE);
await game.move.selectEnemyMove(MoveId.TACKLE);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.toEndOfTurn();

View File

@ -29,5 +29,7 @@ export function toHaveFainted(this: MatcherState, received: unknown): SyncExpect
pass
? `Expected ${pkmName} to NOT have fainted, but it did!`
: `Expected ${pkmName} to have fainted, but it didn't! (${hp}/${maxHp} HP)`,
expected: 0,
actual: hp,
};
}

View File

@ -29,5 +29,7 @@ export function toHaveFullHp(this: MatcherState, received: unknown): SyncExpecta
pass
? `Expected ${pkmName} to NOT have full hp, but it did!`
: `Expected ${pkmName} to have full hp, but it didn't! (${hp}/${maxHp} HP)`,
expected: maxHp,
actual: hp,
};
}

View File

@ -49,6 +49,7 @@ export function toHaveUsedPP(
pass: false,
message: () =>
`Expected MoveId.${moveStr} to appear in ${pkmName}'s moveset exactly once, but got ${movesetMoves.length} times!`,
expected: expectedMove,
actual: received.getMoveset(),
};
}