MISC: Various small fixes (#574)

* ns.ls filter can include leading slash in filename
* scp from terminal accepts multiple filenames
* terminal displays root / instead of ~ as base
* cd with no args returns to root
This commit is contained in:
Snarling
2023-06-06 08:46:07 -04:00
committed by GitHub
parent ed93fea141
commit 40b89baca1
6 changed files with 77 additions and 50 deletions

View File

@@ -13,6 +13,7 @@ import { hasScriptExtension } from "../../../src/Paths/ScriptFilePath";
import { LiteratureName } from "../../../src/Literature/data/LiteratureNames";
import { MessageFilename } from "../../../src/Message/MessageHelpers";
import { Terminal } from "../../../src/Terminal";
import { IPAddress } from "../../../src/Types/strings";
describe("getTabCompletionPossibilities", function () {
let closeServer: Server;
@@ -23,7 +24,7 @@ describe("getTabCompletionPossibilities", function () {
Player.init();
closeServer = new Server({
ip: "8.8.8.8",
ip: "8.8.8.8" as IPAddress,
hostname: "near",
hackDifficulty: 1,
moneyAvailable: 70000,
@@ -33,7 +34,7 @@ describe("getTabCompletionPossibilities", function () {
serverGrowth: 3000,
});
farServer = new Server({
ip: "4.4.4.4",
ip: "4.4.4.4" as IPAddress,
hostname: "far",
hackDifficulty: 1,
moneyAvailable: 70000,
@@ -87,23 +88,22 @@ describe("getTabCompletionPossibilities", function () {
it("completes the scp command", async () => {
writeFiles();
let options = await getTabCompletionPossibilities("scp ", root);
expect(options.sort()).toEqual(
[
"note.txt",
"folder1/text.txt",
"folder1/text2.txt",
"hack.js",
"weaken.js",
"grow.js",
"old.script",
"folder1/test.js",
"anotherFolder/win.js",
LiteratureName.AGreenTomorrow,
].sort(),
);
const filesToMatch = [
"note.txt",
"folder1/text.txt",
"folder1/text2.txt",
"hack.js",
"weaken.js",
"grow.js",
"old.script",
"folder1/test.js",
"anotherFolder/win.js",
LiteratureName.AGreenTomorrow,
];
expect(options.sort()).toEqual(filesToMatch.sort());
// Test the second command argument (server name)
options = await getTabCompletionPossibilities("scp note.txt ", root);
expect(options).toEqual(["home", "near", "far"]);
expect(options.sort()).toEqual(["home", "near", "far", ...filesToMatch].sort());
});
it("completes the kill, tail, mem, and check commands", async () => {