mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-21 23:23:51 +01:00
Fix test
Was using old method of saving scripts which is now removed (was removing possible sources of the script hostname mismatch error)
This commit is contained in:
parent
ae8f26f03b
commit
7f852373d8
@ -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);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user