mirror of
https://github.com/Kvan7/Exiled-Exchange-2.git
synced 2026-09-26 22:55:42 +00:00
finally fix tests?
This commit is contained in:
@@ -40,13 +40,6 @@ export const setupFetchMock = () => {
|
||||
basePath,
|
||||
url.replace(import.meta.env.BASE_URL, ""),
|
||||
);
|
||||
if (fs.existsSync(filePath)) {
|
||||
console.log(`file exists ${filePath}`);
|
||||
const stat = fs.statSync(filePath);
|
||||
console.log(`file size ${stat.size}`);
|
||||
} else {
|
||||
console.error(`file does not exist ${filePath}`);
|
||||
}
|
||||
|
||||
const createResponse = (body: unknown, status = 200) => ({
|
||||
ok: status >= 200 && status < 300,
|
||||
@@ -61,7 +54,7 @@ export const setupFetchMock = () => {
|
||||
bodyUsed: false,
|
||||
json: async () => JSON.parse(body as string),
|
||||
text: async () => body,
|
||||
arrayBuffer: async () => Buffer.from(body as string).buffer,
|
||||
arrayBuffer: async () => body as ArrayBuffer,
|
||||
blob: async () => new Blob([body as string]),
|
||||
formData: async () => {
|
||||
throw new Error("formData not implemented");
|
||||
@@ -75,7 +68,10 @@ export const setupFetchMock = () => {
|
||||
}
|
||||
if (filePath.endsWith(".bin")) {
|
||||
const data = fs.readFileSync(filePath);
|
||||
return createResponse(data, 200);
|
||||
return createResponse(
|
||||
data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength),
|
||||
200,
|
||||
);
|
||||
}
|
||||
if (filePath.endsWith(".json")) {
|
||||
const data = fs.readFileSync(filePath, "utf8");
|
||||
@@ -87,7 +83,6 @@ export const setupFetchMock = () => {
|
||||
|
||||
throw new Error(`Unhandled fetch request: ${url}`);
|
||||
});
|
||||
console.log("setup mock (kinda)");
|
||||
};
|
||||
|
||||
// Mock Host.Proxy calls
|
||||
|
||||
@@ -14,8 +14,6 @@ import { loadClientStrings } from "../client-string-loader";
|
||||
import { useTradeData } from "@/web/background/TradeData";
|
||||
import { GEM, ItemCategory } from "@/parser/meta";
|
||||
import { ItemRarity } from "@/parser/ParsedItem";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
|
||||
export * from "./interfaces";
|
||||
|
||||
@@ -221,13 +219,6 @@ async function loadItems(language: string) {
|
||||
for (const item of ITEMS_ITERATOR('"tradeTag":')) {
|
||||
TRADE_TAG_TO_REF.set(item.tradeTag!, item.refName);
|
||||
}
|
||||
|
||||
const bow = ITEMS_ITERATOR("Obliterator Bow").toArray();
|
||||
console.log(`w/ Obliterator Bow ${bow.length}`);
|
||||
console.log(bow);
|
||||
|
||||
const bow2 = ITEM_BY_REF("ITEM", "Obliterator Bow");
|
||||
console.log(bow2);
|
||||
}
|
||||
|
||||
async function loadStats(language: string) {
|
||||
@@ -291,20 +282,6 @@ async function loadStats(language: string) {
|
||||
};
|
||||
|
||||
STATS_ITERATOR = ndjsonFindLines<Stat>(ndjson);
|
||||
|
||||
const res = STATS_ITERATOR("#% to Fire Resistance").toArray();
|
||||
console.log(`w/ fire res ${res.length}`);
|
||||
console.log(res);
|
||||
|
||||
const light = STATS_ITERATOR("Adds # to # Lightning Damage").toArray();
|
||||
console.log(`w/ lightning ${light.length}`);
|
||||
console.log(light);
|
||||
|
||||
const res2 = STAT_BY_REF("#% to Fire Resistance");
|
||||
console.log(res2);
|
||||
|
||||
const light2 = STAT_BY_REF("Adds # to # Lightning Damage");
|
||||
console.log(light2);
|
||||
}
|
||||
|
||||
// assertion, to avoid regressions in stats.ndjson
|
||||
@@ -342,22 +319,6 @@ export async function init(lang: string) {
|
||||
console.log(
|
||||
"Cannot find stat" + (missing.length > 1 ? "s" : "") + missing.join("\n"),
|
||||
);
|
||||
const url = `${import.meta.env.BASE_URL}data/${lang}/stats.ndjson`;
|
||||
console.log(`should have fetched : ${url}`);
|
||||
const basePath = path.resolve(__dirname, "../../../public/");
|
||||
console.log(`basePath : ${basePath}`);
|
||||
const repl = url.replace(import.meta.env.BASE_URL, "");
|
||||
console.log(`repl : ${repl}`);
|
||||
const filePath = path.join(basePath, repl);
|
||||
console.log(`filePath(where the file actually should be) : ${filePath}`);
|
||||
// just check if the file exists
|
||||
if (fs.existsSync(filePath)) {
|
||||
console.log(`file exists`);
|
||||
} else {
|
||||
console.log(`file does not exist`);
|
||||
const ls = fs.readdirSync(basePath);
|
||||
console.log(`ls : ${ls}`);
|
||||
}
|
||||
}
|
||||
DELAYED_STAT_VALIDATION.clear();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import fnv1a from "@sindresorhus/fnv1a";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
const LANGUAGES = ["en", "ru", "cmn-Hant", "ko", "ja", "de", "es", "pt", "fr"];
|
||||
const LANGUAGES = ["en", "ru", "cmn-Hant", "ko"];
|
||||
|
||||
for (const lang of LANGUAGES) {
|
||||
const lineStarts = {
|
||||
@@ -41,11 +41,6 @@ for (const lang of LANGUAGES) {
|
||||
}
|
||||
start = end + 1;
|
||||
}
|
||||
if (lang === "en") {
|
||||
console.log(`char in stats: ${ndjson.length}`);
|
||||
console.log(`ref count: ${lineStarts.statsByRef.length}`);
|
||||
console.log(`matcher count: ${lineStarts.matchers.length}`);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -55,19 +50,10 @@ for (const lang of LANGUAGES) {
|
||||
indexData[i * 2 + 0] = lineStarts.statsByRef[i].hash;
|
||||
indexData[i * 2 + 1] = lineStarts.statsByRef[i].start;
|
||||
}
|
||||
if (lang === "en") {
|
||||
console.log("stats-ref initial length", indexData.length);
|
||||
}
|
||||
fs.writeFileSync(
|
||||
path.join("./public/data", lang, "stats-ref.index.bin"),
|
||||
indexData,
|
||||
);
|
||||
if (lang === "en") {
|
||||
const stats = fs.statSync(
|
||||
path.join("./public/data", lang, "stats-ref.index.bin"),
|
||||
);
|
||||
console.log(`stats-ref.index.bin size: ${stats.size}`);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -77,19 +63,10 @@ for (const lang of LANGUAGES) {
|
||||
indexData[i * 2 + 0] = lineStarts.matchers[i].hash;
|
||||
indexData[i * 2 + 1] = lineStarts.matchers[i].start;
|
||||
}
|
||||
if (lang === "en") {
|
||||
console.log("stats-matchers initial length", indexData.length);
|
||||
}
|
||||
fs.writeFileSync(
|
||||
path.join("./public/data", lang, "stats-matcher.index.bin"),
|
||||
indexData,
|
||||
);
|
||||
if (lang === "en") {
|
||||
const stats = fs.statSync(
|
||||
path.join("./public/data", lang, "stats-matcher.index.bin"),
|
||||
);
|
||||
console.log(`stats-matcher.index.bin size: ${stats.size}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,10 +99,6 @@ for (const lang of LANGUAGES) {
|
||||
start = end + 1;
|
||||
}
|
||||
lineStarts = Array.from(startsByName.values());
|
||||
if (lang === "en") {
|
||||
console.log(`char in items: ${ndjson.length}`);
|
||||
console.log(`item count: ${lineStarts.length}`);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -135,19 +108,10 @@ for (const lang of LANGUAGES) {
|
||||
indexData[i * 2 + 0] = lineStarts[i].hashName;
|
||||
indexData[i * 2 + 1] = lineStarts[i].start;
|
||||
}
|
||||
if (lang === "en") {
|
||||
console.log("item-name initial length", indexData.length);
|
||||
}
|
||||
fs.writeFileSync(
|
||||
path.join("./public/data", lang, "items-name.index.bin"),
|
||||
indexData,
|
||||
);
|
||||
if (lang === "en") {
|
||||
const stats = fs.statSync(
|
||||
path.join("./public/data", lang, "items-name.index.bin"),
|
||||
);
|
||||
console.log(`items-name.index.bin size: ${stats.size}`);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -157,18 +121,9 @@ for (const lang of LANGUAGES) {
|
||||
indexData[i * 2 + 0] = lineStarts[i].hashRefName;
|
||||
indexData[i * 2 + 1] = lineStarts[i].start;
|
||||
}
|
||||
if (lang === "en") {
|
||||
console.log("item-ref initial length", indexData.length);
|
||||
}
|
||||
fs.writeFileSync(
|
||||
path.join("./public/data", lang, "items-ref.index.bin"),
|
||||
indexData,
|
||||
);
|
||||
if (lang === "en") {
|
||||
const stats = fs.statSync(
|
||||
path.join("./public/data", lang, "items-ref.index.bin"),
|
||||
);
|
||||
console.log(`items-ref.index.bin size: ${stats.size}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user