From 7f852373d8bf3cff568b939dc92f8307941eda6c Mon Sep 17 00:00:00 2001 From: omuretsu <84951833+Snarling@users.noreply.github.com> Date: Sun, 28 May 2023 05:43:09 -0400 Subject: [PATCH] Fix test Was using old method of saving scripts which is now removed (was removing possible sources of the script hostname mismatch error) --- test/jest/Script/Script.test.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/jest/Script/Script.test.ts b/test/jest/Script/Script.test.ts index 34641bb3d..b4e17700c 100644 --- a/test/jest/Script/Script.test.ts +++ b/test/jest/Script/Script.test.ts @@ -1,4 +1,5 @@ -import { Script } from "../../../src/Script/Script"; +import { resolveScriptFilePath } from "../../../src/Paths/ScriptFilePath"; +import { Server } from "../../../src/Server/Server"; const code = `/** @param {NS} ns */ export async function main(ns) { @@ -7,13 +8,17 @@ export async function main(ns) { describe("Validate Save Script Works", function () { it("Save", function () { - const server = "home"; - const filename = "test.js"; - const script = new Script(); - script.saveScript(filename, code, server); + const hostname = "TestServer"; + const server = new Server({ hostname }); + const filename = resolveScriptFilePath("test.js"); + if (!filename) throw new Error("Could not resolve hardcoded filepath."); + + server.writeToContentFile(filename, code); + const script = server.scripts.get(filename); + if (!script) throw new Error("Script was not saved."); expect(script.filename).toEqual(filename); expect(script.code).toEqual(code); - expect(script.server).toEqual(server); + expect(script.server).toEqual(hostname); }); });