bitburner-src/test/jest/Script/Script.test.ts

25 lines
833 B
TypeScript
Raw Normal View History

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 () {
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);
expect(script.server).toEqual(hostname);
2022-04-07 01:30:08 +02:00
});
});