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

29 lines
826 B
TypeScript
Raw Normal View History

// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { jest, describe, expect, test } from "@jest/globals";
import { Script } from "../../../src/Script/Script";
import { Player } from "../../../src/Player";
2022-01-15 04:32:44 +01:00
jest.mock(`!!raw-loader!../NetscriptDefinitions.d.ts`, () => "", {
2022-04-07 01:30:08 +02:00
virtual: true,
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 server = "home";
const filename = "test.js";
const player = Player;
const script = new Script();
script.saveScript(player, filename, code, server, []);
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(server);
});
});