2023-05-28 11:43:09 +02:00
|
|
|
import { resolveScriptFilePath } from "../../../src/Paths/ScriptFilePath";
|
|
|
|
import { Server } from "../../../src/Server/Server";
|
2022-01-15 04:32:44 +01:00
|
|
|
|
2022-03-30 16:08:32 +02:00
|
|
|
const code = `/** @param {NS} ns */
|
2022-01-15 04:32:44 +01:00
|
|
|
export async function main(ns) {
|
|
|
|
ns.print(ns.getWeakenTime('n00dles'));
|
|
|
|
}`;
|
|
|
|
|
|
|
|
describe("Validate Save Script Works", function () {
|
2022-04-07 01:30:08 +02:00
|
|
|
it("Save", function () {
|
2023-05-28 11:43:09 +02:00
|
|
|
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.");
|
2022-01-15 04:32:44 +01:00
|
|
|
|
2022-04-07 01:30:08 +02:00
|
|
|
expect(script.filename).toEqual(filename);
|
|
|
|
expect(script.code).toEqual(code);
|
2023-05-28 11:43:09 +02:00
|
|
|
expect(script.server).toEqual(hostname);
|
2022-04-07 01:30:08 +02:00
|
|
|
});
|
2022-01-25 22:24:09 +01:00
|
|
|
});
|