mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-14 05:45:20 +01:00
* Add caching for test matchers types to improve ts performance * add skipLibCheck to tsconfig.json * Bump package versions * Move tm species map to its own file * Turn on ts-nocheck in pokemon-level-moves * Move initBiomes to own file * Add types to methods in ME encounter phase utils * Fix spacing --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2025 Pagefault Games
|
|
* SPDX-FileContributor: SirzBenjie
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
/**
|
|
* `tm-species-map.ts` has `@ts-nocheck` at the top to disable type checking, as not
|
|
* using this directive dramatically slows down type checking due to the sheer
|
|
* size of the file.
|
|
* To remedy this while preserving type safety, this test ensures that
|
|
* each entry of `tmSpecies` is a valid `TMSpeciesEntry`.
|
|
*
|
|
*
|
|
* @module
|
|
*/
|
|
|
|
import { tmSpecies } from "#balance/tm-species-map";
|
|
import { MoveId } from "#enums/move-id";
|
|
import { SpeciesId } from "#enums/species-id";
|
|
import { describe, expect, test } from "vitest";
|
|
|
|
describe("TypeCheck - tmSpecies", () => {
|
|
// Basic sanity check
|
|
const tmNameMap = Object.entries(tmSpecies).map(([moveId, value]) => {
|
|
return { name: MoveId[+moveId], value };
|
|
});
|
|
test.each(tmNameMap)("$name has valid species", ({ name, value }) => {
|
|
expect(name, "tm is a valid move ID").toBeDefined();
|
|
expect(Array.isArray(value), "value is an array").toBe(true);
|
|
|
|
for (const entry of value) {
|
|
const speciesId = typeof entry === "number" ? entry : entry[0];
|
|
expect(SpeciesId[speciesId], "each entry should be a species ID").toBeDefined();
|
|
|
|
if (typeof entry !== "number") {
|
|
expect(Array.isArray(entry), "non-numeric entry must be array").toBe(true);
|
|
expect(entry.length, "array entry must have at least 2 elements").toBeGreaterThan(1);
|
|
|
|
for (const subEntry of entry.slice(1)) {
|
|
expect(subEntry, "form arrays must have strings for remaining elements").toBeTypeOf("string");
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|