mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-09 01:03:54 +01:00
7f852373d8
Was using old method of saving scripts which is now removed (was removing possible sources of the script hostname mismatch error)
25 lines
833 B
TypeScript
25 lines
833 B
TypeScript
import { resolveScriptFilePath } from "../../../src/Paths/ScriptFilePath";
|
|
import { Server } from "../../../src/Server/Server";
|
|
|
|
const code = `/** @param {NS} ns */
|
|
export async function main(ns) {
|
|
ns.print(ns.getWeakenTime('n00dles'));
|
|
}`;
|
|
|
|
describe("Validate Save Script Works", function () {
|
|
it("Save", function () {
|
|
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(hostname);
|
|
});
|
|
});
|