BUGFIX: fix relative imports (#1305)

Relative paths work in imports, at last.
This commit is contained in:
Caldwell
2024-06-03 02:38:01 +02:00
committed by GitHub
parent 76ce2f9955
commit f40d4f8e92
7 changed files with 219 additions and 51 deletions
+4 -1
View File
@@ -9,6 +9,7 @@ import { calculateRamUsage } from "../../../src/Script/RamCalculations";
import { ns } from "../../../src/NetscriptFunctions";
import { InternalAPI } from "src/Netscript/APIWrapper";
import { Singularity } from "@nsdefs";
import { ScriptFilePath } from "src/Paths/ScriptFilePath";
type PotentiallyAsyncFunction = (arg?: unknown) => { catch?: PotentiallyAsyncFunction };
@@ -71,13 +72,15 @@ describe("Netscript RAM Calculation/Generation Tests", function () {
extraLayerCost = 0,
) {
const code = `${fnPath.join(".")}();\n`.repeat(3);
const filename = "testfile.js" as ScriptFilePath;
const fnName = fnPath[fnPath.length - 1];
const server = "testserver";
//check imported getRamCost fn vs. expected ram from test
expect(getRamCost(fnPath, true)).toEqual(expectedRamCost);
// Static ram check
const staticCost = calculateRamUsage(code, new Map()).cost;
const staticCost = calculateRamUsage(code, filename, new Map(), server).cost;
expect(staticCost).toBeCloseTo(Math.min(baseCost + expectedRamCost + extraLayerCost, maxCost));
// reset workerScript for dynamic check