fix: actually create test for natives

This commit is contained in:
HerozDotExe 2025-10-06 16:20:11 +02:00
parent c6a392077a
commit aaad782501

View file

@ -1,19 +1,28 @@
import { test } from "vitest";
import { expect, test } 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");
console.log(nativesPath)
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;
}
}
// old version because newer versions doesn't have natives
test(
"download natives for 1.15 correctly",
{ timeout: 10000 },
async () => {
const versionManifest = await nlk.core.version.getVersionManifest("1.15");
await nlk.core.natives.download(nativesPath, versionManifest);
},
);
test("download natives for 1.15 correctly", { timeout: 10000 }, async () => {
const versionManifest = await nlk.core.version.getVersionManifest("1.15");
await nlk.core.natives.download(nativesPath, versionManifest);
expect(
await exists(path.join(nativesPath, "libglfw.so")),
"libglfw.so exists",
).toBe(true);
});