Merge pull request #2638 from deathly809/bug/fix_scripts

When saving we were not saving the script content
This commit is contained in:
hydroflame 2022-01-14 23:37:17 -05:00 committed by Olivier Gagnon
commit 00b672a719
5 changed files with 42 additions and 13 deletions

18
dist/vendor.bundle.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -118,7 +118,7 @@ export class Script {
*/ */
saveScript(player: IPlayer, filename: string, code: string, hostname: string, otherScripts: Script[]): void { saveScript(player: IPlayer, filename: string, code: string, hostname: string, otherScripts: Script[]): void {
// Update code and filename // Update code and filename
this.code = Script.formatCode(this.code); this.code = Script.formatCode(code);
this.filename = filename; this.filename = filename;
this.server = hostname; this.server = hostname;

@ -0,0 +1,29 @@
// 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";
jest.mock(`!!raw-loader!../NetscriptDefinitions.d.ts`, () => "", {
virtual: true,
});
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 server = "home";
const filename = "test.js";
const player = Player;
const script = new Script();
script.saveScript(player, filename, code, server, []);
expect(script.filename).toEqual(filename)
expect(script.code).toEqual(code)
expect(script.server).toEqual(server)
});
});