feat: remove unused test

This commit is contained in:
HerozDotExe 2026-03-16 18:25:36 +01:00
parent 95dccaeb57
commit f028d02bc6
12 changed files with 10 additions and 305 deletions

File diff suppressed because one or more lines are too long

View file

@ -1,42 +0,0 @@
import { expect, test, vi } from "vitest";
import * as nlk from "../../dist/index.js";
import path from "path";
import fs from "fs/promises";
const assetsPath = path.join(import.meta.dirname, "temp/assets");
const root = path.join(import.meta.dirname, "temp");
await fs.rm(assetsPath, { recursive: true, force: true });
await fs.mkdir(assetsPath, { recursive: true });
async function exists(path: string) {
try {
await fs.access(path, fs.constants.F_OK);
return true;
} catch {
return false;
}
}
// mock os to linux for testing
vi.stubGlobal("process", { platform: "linux" });
test(
"download assets for 1.21.8 correctly",
{ timeout: 0 },
async () => {
const versionManifest = await nlk.core.version.getVersionManifest("1.21.8", root);
const assetsDownloader = await nlk.core.AssetsDownloader(assetsPath, versionManifest);
assetsDownloader.on("completed", () => {
console.log(
`${assetsDownloader.done}/${assetsDownloader.total} | ${assetsDownloader.doneSize}/${assetsDownloader.totalSize}`,
);
});
await assetsDownloader.run()
expect(
await exists(path.join(assetsPath, "objects", "00", "00c9fa8115347fb0220aaf72a8d7d921f5354112")),
"objects/00/00c9fa8115347fb0220aaf72a8d7d921f5354112 exists",
).toBe(true);
},
);

View file

@ -1,50 +0,0 @@
import { expect, test, vi } from "vitest";
import * as nlk from "../../dist/index.js";
import path from "path";
import fs from "fs/promises";
const javaPath = path.join(import.meta.dirname, "temp/java");
await fs.rm(javaPath, { recursive: true, force: true });
await fs.mkdir(javaPath, { recursive: true });
async function exists(path: string) {
try {
await fs.access(path, fs.constants.F_OK);
return true;
} catch {
return false;
}
}
// mock os to linux for testing
vi.stubGlobal("process", { platform: "linux" });
test(
"install java-runtime-beta for linux correctly",
{ timeout: 0 },
async () => {
const javaDownloader = await nlk.core.java.JavaDownloader(
"linux",
"java-runtime-delta",
javaPath,
);
javaDownloader.on("completed", () => {
console.log(
`${javaDownloader.done}/${javaDownloader.total} | ${javaDownloader.doneSize}/${javaDownloader.totalSize}`,
);
});
await javaDownloader.run();
expect(
await fs.readFile(path.join(javaPath, "java-runtime-delta", "release"), { encoding: "utf-8" }),
"check release file",
).toBe(`JAVA_VERSION="21.0.7"
MODULES="java.base java.compiler java.datatransfer java.xml java.prefs java.desktop java.instrument java.logging java.management java.security.sasl java.naming java.rmi java.management.rmi java.net.http java.scripting java.security.jgss java.transaction.xa java.sql java.sql.rowset java.xml.crypto java.se java.smartcardio jdk.accessibility jdk.internal.jvmstat jdk.attach jdk.charsets jdk.internal.opt jdk.zipfs jdk.compiler jdk.crypto.ec jdk.crypto.cryptoki jdk.dynalink jdk.internal.ed jdk.editpad jdk.hotspot.agent jdk.httpserver jdk.incubator.vector jdk.internal.le jdk.internal.vm.ci jdk.internal.vm.compiler jdk.internal.vm.compiler.management jdk.jartool jdk.javadoc jdk.jcmd jdk.management jdk.management.agent jdk.jconsole jdk.jdeps jdk.jdwp.agent jdk.jdi jdk.jfr jdk.jlink jdk.jpackage jdk.jshell jdk.jsobject jdk.jstatd jdk.localedata jdk.management.jfr jdk.naming.dns jdk.naming.rmi jdk.net jdk.nio.mapmode jdk.random jdk.sctp jdk.security.auth jdk.security.jgss jdk.unsupported jdk.unsupported.desktop jdk.xml.dom"
`);
expect(
await exists(path.join(javaPath, "java-runtime-delta", "bin/java")),
"bin/java exists",
).toBe(true);
},
);

View file

@ -1,41 +0,0 @@
import { expect, test, vi } from "vitest";
import * as nlk from "../../dist/index.js";
import path from "path";
import fs from "fs/promises";
const librariesPath = path.join(import.meta.dirname, "temp/libraries");
const root = path.join(import.meta.dirname, "temp");
await fs.rm(librariesPath, { recursive: true, force: true });
await fs.mkdir(librariesPath, { recursive: true });
async function exists(path: string) {
try {
await fs.access(path, fs.constants.F_OK);
return true;
} catch {
return false;
}
}
// mock os to linux for testing
vi.stubGlobal("process", { platform: "linux" });
test(
"download libraries for 1.21.8 correctly",
{ timeout: 0 },
async () => {
const versionManifest = await nlk.core.version.getVersionManifest("1.21.8", root);
const librariesDownloader = await nlk.core.LibrariesDownloader(librariesPath, versionManifest);
librariesDownloader.on("completed", () => {
console.log(
`${librariesDownloader.done}/${librariesDownloader.total} | ${librariesDownloader.doneSize}/${librariesDownloader.totalSize}`,
);
});
await librariesDownloader.run()
expect(
await exists(path.join(librariesPath, "com/fasterxml/jackson/core/jackson-core/2.13.4/jackson-core-2.13.4.jar")),
"com/fasterxml/jackson/core/jackson-core/2.13.4/jackson-core-2.13.4.jar exists",
).toBe(true);
},
);

View file

@ -1,34 +0,0 @@
import { expect, test, vi } from "vitest";
import * as nlk from "../../dist/index.js";
import path from "path";
import { hash } from "crypto";
import fs from "fs/promises";
const root = path.join(import.meta.dirname, "temp");
const xmlFile = path.join(root, "client-1.21.2.xml");
try {
await fs.rm(xmlFile, { recursive: true });
} catch {
// first time the test is runned
}
// mock os to linux for testing
vi.stubGlobal("process", { platform: "linux" });
test(
"download xml file and return correct arguments",
{ timeout: 0 },
async () => {
const versionManifest = await nlk.core.version.getVersionManifest("1.21.8", root);
const arg = await nlk.core.log4j.getArgument(versionManifest, root);
expect(arg, "correct arg returned").toBe(
`-Dlog4j.configurationFile=${xmlFile}`,
);
expect(
hash("sha1", await fs.readFile(xmlFile, { encoding: "utf-8" })),
"correct hash",
).toBe("39384bd14c0606d812afec88d8aff595b2587dd9");
},
);

View file

@ -1,41 +0,0 @@
import { expect, test, vi } from "vitest";
import * as nlk from "../../dist/index.js";
import path from "path";
import fs from "fs/promises";
const nativesPath = path.join(import.meta.dirname, "temp/natives");
const root = path.join(import.meta.dirname, "temp");
await fs.rm(nativesPath, { recursive: true, force: true });
await fs.mkdir(nativesPath, { recursive: true });
async function exists(path: string) {
try {
await fs.access(path, fs.constants.F_OK);
return true;
} catch {
return false;
}
}
// mock os to linux for testing
vi.stubGlobal("process", { platform: "linux" });
// old version because newer versions doesn't have natives
test("download natives for 1.15 correctly", { timeout: 0 }, async () => {
const versionManifest = await nlk.core.version.getVersionManifest("1.15", root);
const nativesDownloader = await nlk.core.NativesDownloader(
nativesPath,
versionManifest,
);
nativesDownloader.on("completed", () => {
console.log(
`${nativesDownloader.done}/${nativesDownloader.total} | ${nativesDownloader.doneSize}/${nativesDownloader.totalSize}`,
);
});
await nativesDownloader.run();
expect(
await exists(path.join(nativesPath, "libglfw.so")),
"libglfw.so exists",
).toBe(true);
});

View file

@ -1,41 +0,0 @@
import { expect, test, vi } from "vitest";
import * as nlk from "../../dist/index.js";
import path from "path";
import fs from "fs/promises";
const root = path.join(import.meta.dirname, "temp");
try {
await fs.rm(path.join(root, "1.21.8.json"));
await fs.rm(path.join(root, "1.21.8.jar"));
} catch (e) {
console.warn(e)
}
async function exists(path: string) {
try {
await fs.access(path, fs.constants.F_OK);
return true;
} catch {
return false;
}
}
// mock os to linux for testing
vi.stubGlobal("process", { platform: "linux" });
test("parse arguments correctly for 1.21.8", { timeout: 0 }, async () => {
const versionManifest = await nlk.core.version.getVersionManifest(
"1.21.8",
root,
);
await nlk.core.version.downloadJar(versionManifest, root);
expect(
await exists(path.join(root, `${versionManifest.id}.jar`)),
"check jar file",
).toBe(true);
expect(
await exists(path.join(root, `${versionManifest.id}.json`)),
"check json file",
).toBe(true);
});

View file

@ -1,5 +1,5 @@
import { test } from "vitest";
import { Instance, offlineAuth, RuntimeManager, getJavaComponent } from "../../../dist/index.js";
import { Instance, offlineAuth, RuntimeManager, getJavaComponent } from "../../dist/index.js";
import path from "path";
import fs from "fs/promises";

View file

@ -1,5 +1,5 @@
import { test } from "vitest";
import { Instance, offlineAuth, RuntimeManager, getJavaComponent } from "../../../dist/index.js";
import { Instance, offlineAuth, RuntimeManager, getJavaComponent } from "../../dist/index.js";
import path from "path";
import fs from "fs/promises";

View file

@ -1,11 +1,11 @@
import { test } from "vitest";
import { Instance, offlineAuth, RuntimeManager, getJavaComponent } from "../../../dist/index.js";
import { Instance, offlineAuth, RuntimeManager, getJavaComponent } from "../../dist/index.js";
import path from "path";
import fs from "fs/promises";
const gameRoot = path.join(import.meta.dirname, "..", "temp");
// await fs.rm(gameRoot, { recursive: true, force: true });
// await fs.mkdir(gameRoot, { recursive: true });
await fs.rm(gameRoot, { recursive: true, force: true });
await fs.mkdir(gameRoot, { recursive: true });
test("launch game", { timeout: 0 }, async () => {
const instance = new Instance();
@ -13,14 +13,14 @@ test("launch game", { timeout: 0 }, async () => {
javaManager.on("progress", console.log)
// const java = await javaManager.use(await getJavaComponent("1.12.2"))
const java = await javaManager.use(await getJavaComponent("1.12.2"))
const auth = offlineAuth("player");
instance.setVersion("1.7.1001");
instance.setPaths(gameRoot);
instance.setAuth(auth);
instance.setJavaExecutable("java")
instance.setJavaExecutable(java)
instance.setModLoader("forge", "10.13.4.1614");
instance.on("progress", console.log);

View file

@ -1,8 +1,8 @@
import { test } from "vitest";
import { Instance, offlineAuth, RuntimeManager } from "../../../dist/index.js";
import { Instance, offlineAuth, RuntimeManager } from "../../dist/index.js";
import path from "path";
import fs from "fs/promises";
import { getJavaComponent } from "../../../src/index.js";
import { getJavaComponent } from "../../src/index.js";
const gameRoot = path.join(import.meta.dirname, "..", "temp");
await fs.rm(gameRoot, { recursive: true, force: true });