mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-10 17:39:31 +02:00
* Partially ported over pkty matchers (WIP) * Cleaned up some more matchers * Fiexd up matchers * Fixed up remaining matchers * Removed the word "matcher" from the pkty matcher functions If we want them back we can always undo this commit and convert the other custom ones * Added wip spite test * Added `toHaveUsedPP` matcher * Fixed up docs and tests * Fixed spite test * Ran biome * Apply Biome * Reverted biome breaking i18next * Update src/typings/i18next.d.ts comment * Fixed log message to not be overly verbose * Added option to check for all PP used in pp matcher + cleaned up grudge tests * Fixed up tests * Fixed tests and such * Fix various TSDocs + missing TSDoc imports
44 lines
1.6 KiB
TypeScript
44 lines
1.6 KiB
TypeScript
/* biome-ignore-start lint/correctness/noUnusedImports: tsdoc imports */
|
|
import type { Pokemon } from "#field/pokemon";
|
|
/* biome-ignore-end lint/correctness/noUnusedImports: tsdoc imports */
|
|
|
|
import { getPokemonNameWithAffix } from "#app/messages";
|
|
import { AbilityId } from "#enums/ability-id";
|
|
import { getEnumStr } from "#test/test-utils/string-utils";
|
|
import { isPokemonInstance, receivedStr } from "#test/test-utils/test-utils";
|
|
import type { MatcherState, SyncExpectationResult } from "@vitest/expect";
|
|
|
|
/**
|
|
* Matcher that checks if a {@linkcode Pokemon} has applied a specific {@linkcode AbilityId}.
|
|
* @param received - The object to check. Should be a {@linkcode Pokemon}
|
|
* @param expectedAbility - The {@linkcode AbilityId} to check for
|
|
* @returns Whether the matcher passed
|
|
*/
|
|
export function toHaveAbilityApplied(
|
|
this: MatcherState,
|
|
received: unknown,
|
|
expectedAbilityId: AbilityId,
|
|
): SyncExpectationResult {
|
|
if (!isPokemonInstance(received)) {
|
|
return {
|
|
pass: false,
|
|
message: () => `Expected to recieve a Pokemon, but got ${receivedStr(received)}!`,
|
|
};
|
|
}
|
|
|
|
const pass = received.waveData.abilitiesApplied.has(expectedAbilityId);
|
|
|
|
const pkmName = getPokemonNameWithAffix(received);
|
|
const expectedAbilityStr = getEnumStr(AbilityId, expectedAbilityId);
|
|
|
|
return {
|
|
pass,
|
|
message: () =>
|
|
pass
|
|
? `Expected ${pkmName} to NOT have applied ${expectedAbilityStr}, but it did!`
|
|
: `Expected ${pkmName} to have applied ${expectedAbilityStr}, but it didn't!`,
|
|
expected: expectedAbilityId,
|
|
actual: received.waveData.abilitiesApplied,
|
|
};
|
|
}
|