mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-16 04:19:32 +02:00
Fixed tests and such
This commit is contained in:
parent
0a3e4f9615
commit
7fc96aa8c4
8
test/@types/vitest.d.ts
vendored
8
test/@types/vitest.d.ts
vendored
@ -117,7 +117,10 @@ declare module "vitest" {
|
|||||||
toHaveHp(expectedHp: number): void;
|
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;
|
toHaveFainted(): void;
|
||||||
|
|
||||||
@ -127,7 +130,8 @@ declare module "vitest" {
|
|||||||
* @param ppUsed - The numerical amount of PP that should have been consumed,
|
* @param ppUsed - The numerical amount of PP that should have been consumed,
|
||||||
* or `all` to indicate the move should be _out_ of PP
|
* or `all` to indicate the move should be _out_ of PP
|
||||||
* @remarks
|
* @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.
|
* or contains the desired move more than once, this will fail the test.
|
||||||
*/
|
*/
|
||||||
toHaveUsedPP(expectedMove: MoveId, ppUsed: number | "all"): void;
|
toHaveUsedPP(expectedMove: MoveId, ppUsed: number | "all"): void;
|
||||||
|
@ -35,14 +35,15 @@ describe("Moves - Grudge", () => {
|
|||||||
it("should reduce the PP of an attack that faints the user to 0", async () => {
|
it("should reduce the PP of an attack that faints the user to 0", async () => {
|
||||||
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
||||||
|
|
||||||
|
const feebas = game.field.getPlayerPokemon();
|
||||||
|
const ratatta = game.field.getEnemyPokemon();
|
||||||
|
|
||||||
game.move.use(MoveId.GUILLOTINE);
|
game.move.use(MoveId.GUILLOTINE);
|
||||||
await game.move.forceEnemyMove(MoveId.GRUDGE);
|
await game.move.forceEnemyMove(MoveId.GRUDGE);
|
||||||
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
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
|
// 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(ratatta).toHaveFainted();
|
||||||
expect(feebas).toHaveUsedPP(MoveId.GUILLOTINE, "all");
|
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 () => {
|
it("should remain in effect until the user's next move", async () => {
|
||||||
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
||||||
|
|
||||||
|
const feebas = game.field.getPlayerPokemon();
|
||||||
|
const ratatta = game.field.getEnemyPokemon();
|
||||||
|
|
||||||
game.move.use(MoveId.SPLASH);
|
game.move.use(MoveId.SPLASH);
|
||||||
await game.move.forceEnemyMove(MoveId.GRUDGE);
|
await game.move.forceEnemyMove(MoveId.GRUDGE);
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||||
@ -60,8 +64,6 @@ describe("Moves - Grudge", () => {
|
|||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||||
await game.toEndOfTurn();
|
await game.toEndOfTurn();
|
||||||
|
|
||||||
const feebas = game.field.getPlayerPokemon();
|
|
||||||
const ratatta = game.field.getEnemyPokemon();
|
|
||||||
expect(ratatta).toHaveFainted();
|
expect(ratatta).toHaveFainted();
|
||||||
expect(feebas).toHaveUsedPP(MoveId.GUILLOTINE, "all");
|
expect(feebas).toHaveUsedPP(MoveId.GUILLOTINE, "all");
|
||||||
});
|
});
|
||||||
@ -71,13 +73,14 @@ describe("Moves - Grudge", () => {
|
|||||||
game.override.weather(WeatherType.SANDSTORM);
|
game.override.weather(WeatherType.SANDSTORM);
|
||||||
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
||||||
|
|
||||||
|
const feebas = game.field.getPlayerPokemon();
|
||||||
|
const ratatta = game.field.getEnemyPokemon();
|
||||||
|
|
||||||
game.move.use(MoveId.FALSE_SWIPE);
|
game.move.use(MoveId.FALSE_SWIPE);
|
||||||
await game.move.forceEnemyMove(MoveId.GRUDGE);
|
await game.move.forceEnemyMove(MoveId.GRUDGE);
|
||||||
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
||||||
await game.toEndOfTurn();
|
await game.toEndOfTurn();
|
||||||
|
|
||||||
const feebas = game.field.getPlayerPokemon();
|
|
||||||
const ratatta = game.field.getEnemyPokemon();
|
|
||||||
expect(ratatta).toHaveFainted();
|
expect(ratatta).toHaveFainted();
|
||||||
expect(feebas).toHaveUsedPP(MoveId.FALSE_SWIPE, 1);
|
expect(feebas).toHaveUsedPP(MoveId.FALSE_SWIPE, 1);
|
||||||
});
|
});
|
||||||
|
@ -40,7 +40,7 @@ describe("Moves - Spite", () => {
|
|||||||
const karp = game.field.getEnemyPokemon();
|
const karp = game.field.getEnemyPokemon();
|
||||||
game.move.changeMoveset(karp, [MoveId.SPLASH, MoveId.TACKLE]);
|
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.move.selectEnemyMove(MoveId.TACKLE);
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
@ -48,7 +48,7 @@ describe("Moves - Spite", () => {
|
|||||||
expect(karp).toHaveUsedPP(MoveId.TACKLE, 1);
|
expect(karp).toHaveUsedPP(MoveId.TACKLE, 1);
|
||||||
|
|
||||||
game.move.use(MoveId.SPITE);
|
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.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||||
await game.toEndOfTurn();
|
await game.toEndOfTurn();
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ describe("Moves - Spite", () => {
|
|||||||
const karp = game.field.getEnemyPokemon();
|
const karp = game.field.getEnemyPokemon();
|
||||||
game.move.changeMoveset(karp, [MoveId.SPLASH, MoveId.TACKLE]);
|
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.move.selectEnemyMove(MoveId.TACKLE);
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||||
await game.toEndOfTurn();
|
await game.toEndOfTurn();
|
||||||
@ -77,7 +77,7 @@ describe("Moves - Spite", () => {
|
|||||||
game.move.changeMoveset(karp, [MoveId.TACKLE]);
|
game.move.changeMoveset(karp, [MoveId.TACKLE]);
|
||||||
karp.moveset[0].ppUsed = 0;
|
karp.moveset[0].ppUsed = 0;
|
||||||
|
|
||||||
game.move.use(MoveId.SPLASH);
|
game.move.use(MoveId.SPITE);
|
||||||
await game.move.selectEnemyMove(MoveId.TACKLE);
|
await game.move.selectEnemyMove(MoveId.TACKLE);
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||||
await game.toEndOfTurn();
|
await game.toEndOfTurn();
|
||||||
|
@ -29,5 +29,7 @@ export function toHaveFainted(this: MatcherState, received: unknown): SyncExpect
|
|||||||
pass
|
pass
|
||||||
? `Expected ${pkmName} to NOT have fainted, but it did!`
|
? `Expected ${pkmName} to NOT have fainted, but it did!`
|
||||||
: `Expected ${pkmName} to have fainted, but it didn't! (${hp}/${maxHp} HP)`,
|
: `Expected ${pkmName} to have fainted, but it didn't! (${hp}/${maxHp} HP)`,
|
||||||
|
expected: 0,
|
||||||
|
actual: hp,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -29,5 +29,7 @@ export function toHaveFullHp(this: MatcherState, received: unknown): SyncExpecta
|
|||||||
pass
|
pass
|
||||||
? `Expected ${pkmName} to NOT have full hp, but it did!`
|
? `Expected ${pkmName} to NOT have full hp, but it did!`
|
||||||
: `Expected ${pkmName} to have full hp, but it didn't! (${hp}/${maxHp} HP)`,
|
: `Expected ${pkmName} to have full hp, but it didn't! (${hp}/${maxHp} HP)`,
|
||||||
|
expected: maxHp,
|
||||||
|
actual: hp,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ export function toHaveUsedPP(
|
|||||||
pass: false,
|
pass: false,
|
||||||
message: () =>
|
message: () =>
|
||||||
`Expected MoveId.${moveStr} to appear in ${pkmName}'s moveset exactly once, but got ${movesetMoves.length} times!`,
|
`Expected MoveId.${moveStr} to appear in ${pkmName}'s moveset exactly once, but got ${movesetMoves.length} times!`,
|
||||||
|
expected: expectedMove,
|
||||||
actual: received.getMoveset(),
|
actual: received.getMoveset(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user