fix broken pokemonSprite test

This commit is contained in:
Sirz Benjie 2025-03-07 22:51:14 -06:00
parent 64791039dd
commit 9f16c79af1
No known key found for this signature in database
GPG Key ID: 4A524B4D196C759E
2 changed files with 17 additions and 22 deletions

View File

@ -91,7 +91,11 @@
{ {
"include": ["test/**/*.test.ts"], "include": ["test/**/*.test.ts"],
"javascript": { "globals": [] }, "javascript": { "globals": [] },
"linter": { "rules": {} } "linter": { "rules": {
"performance": {
"noDelete": "off"
}
} }
} }
] ]
} }

View File

@ -1,6 +1,6 @@
import { getAppRootDir } from "#test/sprites/spritesUtils"; import { getAppRootDir } from "#test/sprites/spritesUtils";
import fs from "node:fs"; import fs from "fs";
import path from "node:path"; import path from "path";
import { beforeAll, describe, expect, it } from "vitest"; import { beforeAll, describe, expect, it } from "vitest";
import _masterlist from "../../public/images/pokemon/variant/_masterlist.json"; import _masterlist from "../../public/images/pokemon/variant/_masterlist.json";
@ -24,11 +24,11 @@ describe("check if every variant's sprite are correctly set", () => {
femaleVariant = masterlist.female; femaleVariant = masterlist.female;
backVariant = masterlist.back; backVariant = masterlist.back;
//@ts-ignore //@ts-ignore
masterlist.exp = undefined; //TODO: resolve ts-ignore delete masterlist.exp; //TODO: resolve ts-ignore
//@ts-ignore //@ts-ignore
masterlist.female = undefined; //TODO: resolve ts-ignore delete masterlist.female; //TODO: resolve ts-ignore
//@ts-ignore //@ts-ignore
masterlist.back = undefined; //TODO: resolve ts-ignore delete masterlist.back; //TODO: resolve ts-ignore
}); });
it("data should not be undefined", () => { it("data should not be undefined", () => {
@ -70,10 +70,7 @@ describe("check if every variant's sprite are correctly set", () => {
errors.push(`[${id}] missing key ${id} in masterlist for ${trimmedFilePath}`); errors.push(`[${id}] missing key ${id} in masterlist for ${trimmedFilePath}`);
} }
if (mlist[id][index] === 1 && jsonFileExists) { if (mlist[id][index] === 1 && jsonFileExists) {
const raw = fs.readFileSync(urlJsonFile, { const raw = fs.readFileSync(urlJsonFile, { encoding: "utf8", flag: "r" });
encoding: "utf8",
flag: "r",
});
const data = JSON.parse(raw); const data = JSON.parse(raw);
const keys = Object.keys(data); const keys = Object.keys(data);
if (!keys.includes(`${index}`)) { if (!keys.includes(`${index}`)) {
@ -92,10 +89,7 @@ describe("check if every variant's sprite are correctly set", () => {
} else if (!mlist.hasOwnProperty(name)) { } else if (!mlist.hasOwnProperty(name)) {
errors.push(`[${name}] - missing key ${name} in masterlist for ${trimmedFilePath}`); errors.push(`[${name}] - missing key ${name} in masterlist for ${trimmedFilePath}`);
} else { } else {
const raw = fs.readFileSync(filePath, { const raw = fs.readFileSync(filePath, { encoding: "utf8", flag: "r" });
encoding: "utf8",
flag: "r",
});
const data = JSON.parse(raw); const data = JSON.parse(raw);
for (const key of Object.keys(data)) { for (const key of Object.keys(data)) {
if (mlist[name][key] !== 1) { if (mlist[name][key] !== 1) {
@ -125,10 +119,7 @@ describe("check if every variant's sprite are correctly set", () => {
} else if (elm === 1) { } else if (elm === 1) {
url = `${key}.json`; url = `${key}.json`;
const filePath = `${dirPath}${url}`; const filePath = `${dirPath}${url}`;
const raw = fs.readFileSync(filePath, { const raw = fs.readFileSync(filePath, { encoding: "utf8", flag: "r" });
encoding: "utf8",
flag: "r",
});
const data = JSON.parse(raw); const data = JSON.parse(raw);
if (!data.hasOwnProperty(index)) { if (!data.hasOwnProperty(index)) {
errors.push(`index: ${index} - ${filePath}`); errors.push(`index: ${index} - ${filePath}`);
@ -183,7 +174,7 @@ describe("check if every variant's sprite are correctly set", () => {
it("check back male back variant files", () => { it("check back male back variant files", () => {
const dirPath = `${rootDir}back${path.sep}`; const dirPath = `${rootDir}back${path.sep}`;
const backMaleVariant = deepCopy(backVariant); const backMaleVariant = deepCopy(backVariant);
backMaleVariant.female = undefined; delete backMaleVariant.female;
const errors = getMissingFiles(backMaleVariant, dirPath); const errors = getMissingFiles(backMaleVariant, dirPath);
if (errors.length) { if (errors.length) {
console.log("errors", errors); console.log("errors", errors);
@ -203,7 +194,7 @@ describe("check if every variant's sprite are correctly set", () => {
it("check exp back male variant files", () => { it("check exp back male variant files", () => {
const dirPath = `${rootDir}exp${path.sep}back${path.sep}`; const dirPath = `${rootDir}exp${path.sep}back${path.sep}`;
const backMaleVariant = deepCopy(expVariant.back); const backMaleVariant = deepCopy(expVariant.back);
backMaleVariant.female = undefined; delete backMaleVariant.female;
const errors = getMissingFiles(backMaleVariant, dirPath); const errors = getMissingFiles(backMaleVariant, dirPath);
if (errors.length) { if (errors.length) {
console.log("errors", errors); console.log("errors", errors);
@ -223,8 +214,8 @@ describe("check if every variant's sprite are correctly set", () => {
it("check exp male variant files", () => { it("check exp male variant files", () => {
const dirPath = `${rootDir}exp${path.sep}`; const dirPath = `${rootDir}exp${path.sep}`;
const expMaleVariant = deepCopy(expVariant); const expMaleVariant = deepCopy(expVariant);
expMaleVariant.female = undefined; delete expMaleVariant.female;
expMaleVariant.back = undefined; delete expMaleVariant.back;
const errors = getMissingFiles(expMaleVariant, dirPath); const errors = getMissingFiles(expMaleVariant, dirPath);
if (errors.length) { if (errors.length) {
console.log("errors", errors); console.log("errors", errors);