pokerogue/test/test-utils/matchers/to-have-full-hp.ts
Bertie690 5ed9e152ab
[Test] Port over + augment remaining test matchers from pkty (#6159)
* 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
2025-08-02 15:35:06 -07:00

36 lines
1.1 KiB
TypeScript

import { getPokemonNameWithAffix } from "#app/messages";
// biome-ignore lint/correctness/noUnusedImports: TSDoc
import type { Pokemon } from "#field/pokemon";
import { isPokemonInstance, receivedStr } from "#test/test-utils/test-utils";
import type { MatcherState, SyncExpectationResult } from "@vitest/expect";
/**
* Matcher that checks if a {@linkcode Pokemon} is at full hp.
* @param received - The object to check. Should be a {@linkcode Pokemon}.
* @returns Whether the matcher passed
*/
export function toHaveFullHp(this: MatcherState, received: unknown): SyncExpectationResult {
if (!isPokemonInstance(received)) {
return {
pass: false,
message: () => `Expected to receive a Pokémon, but got ${receivedStr(received)}!`,
};
}
const pass = received.isFullHp();
const hp = received.hp;
const maxHp = received.getMaxHp();
const pkmName = getPokemonNameWithAffix(received);
return {
pass,
message: () =>
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,
};
}