- Old tests fixed

- Added a static Fixuture class for test mockups
This commit is contained in:
2026-08-28 16:52:59 +02:00
parent 310218663d
commit 1ee2a2fe7a
13 changed files with 161 additions and 306 deletions
+5 -2
View File
@@ -188,6 +188,9 @@
"bases:Create new base": false
}
},
"active": "1db1d6b317bc05ae",
"lastOpenFiles": []
"active": "af4cfba92021d1c8",
"lastOpenFiles": [
"src/util/posix.ts",
"src/core/util/sort.ts"
]
}
+4 -6
View File
@@ -15,8 +15,6 @@ import type { TreeNode } from "@core/filesystem/treenode";
import { getCurrentSession, type GroupInfo, type UserInfo } from "@core/session_manager";
import { createInitialShellState, type ShellState } from "@core/shell_state";
import { resolveInode } from "@core/util/path_resolver";
import { sortTreeNodes } from "@core/util/sort";
import { dnTraverseTree } from "@core/util/tree_traversal";
import { deserializeFileSystem } from "@shell/serializer";
import { Shell } from "@shell/shell";
import { printTree } from "./util/tree_visualizer";
@@ -50,10 +48,10 @@ groups.set(1000, group);
const state: ShellState = createInitialShellState(fs, users, groups, user);
await Shell.init(state);
console.log(resolveInode(Shell.Instance?.State!, 6));
console.log(resolveInode(Shell.Instance?.State!, 6, true));
//console.log(resolveInode(Shell.Instance?.State!, 6));
//console.log(resolveInode(Shell.Instance?.State!, 6, true));
console.log(sortTreeNodes(Shell.Instance?.State!, dnTraverseTree(Shell.Instance?.State.filesystem!, 0)));
//console.log(sortTreeNodes(Shell.Instance?.State!, dnTraverseTree(Shell.Instance?.State.filesystem!, 0)));
Shell.Instance?.on("result", payload => {
const decoded = new TextDecoder().decode(payload.result.stdout.toArray());
@@ -73,7 +71,7 @@ Shell.Instance?.on("result", payload => {
}); */
//console.clear();
process.stdout.write(resolveInode(Shell.Instance?.State!, getCurrentSession(state).cwd) + "\n> ");
process.stdout.write(resolveInode(state, getCurrentSession(state).cwd) + "\n> ");
process.stdin.on("data", async data => {
if (Shell.Instance?.BoundPID !== null) {
Shell.Instance?.sendInput(data.toString().trim());
+3 -1
View File
@@ -18,6 +18,7 @@ export class Process {
private readonly _MaxChunkByteSize: number;
readonly PID: number;
readonly Name: string;
readonly CommandDescriptor: CommandDescriptor;
readonly State: ShellState;
readonly Args: string[];
@@ -26,6 +27,7 @@ export class Process {
constructor(pid: number, state: ShellState, descriptor: CommandDescriptor, flags: string[], args: string[]) {
this.PID = pid;
this.State = state;
this.Name = descriptor.name;
this.CommandDescriptor = descriptor;
this.Flags = flags;
this.Args = args;
@@ -146,7 +148,7 @@ export class Process {
const result: ResultError<SignalTerminationError> = createErrorResult(
"SignalTermination",
`Process ${this.PID} killed by a ${signal.type}`,
`Process ${this.Name}(${this.PID}) killed by a ${SIGNAL_MAP[signal.type]}(${signal.type})`,
{ signalNumber: signal.type, signalName: SIGNAL_MAP[signal.type] },
this.CommandDescriptor.name,
);
+6 -43
View File
@@ -3,48 +3,11 @@ import { descriptor as cd } from "@core/commands/cd";
import type { ResultError, ResultSuccess } from "@core/result";
import type { UserInfo } from "@core/session_manager";
import { getCurrentSession } from "@core/session_manager";
import { createInitialShellState, withCwd, type ShellState } from "@core/shell_state";
import { withCwd, type ShellState } from "@core/shell_state";
import type { PathResolutionError } from "@core/util/errors";
import { buildTestFS, type FixtureNode } from "@tests/helpers/filesystems_fixture";
import { Fixture } from "@tests/helpers/state_fixture";
import { expect, test } from "vitest";
const testTree: FixtureNode = {
inode: 0,
name: "root",
type: "Dir",
children: [
{
inode: 1,
name: "hello.txt",
type: "File",
content: "Goodbye World!",
children: [],
},
{
inode: 2,
name: "sub",
type: "Dir",
children: [
{
inode: 3,
name: "world.txt",
type: "File",
content: "Goodbye!",
children: [],
},
{
inode: 4,
name: "bye",
type: "Dir",
children: [],
},
],
},
],
};
const fs = buildTestFS(testTree);
const stdout: Uint8Array[] = [];
const stderr: Uint8Array[] = [];
@@ -70,7 +33,7 @@ const user: UserInfo = {
};
users.set(0, user);
const state: ShellState = createInitialShellState(fs, users, user);
const state: ShellState = Fixture.State;
test("changes cwd to home", async () => {
let newState = withCwd(state, 2);
@@ -80,7 +43,7 @@ test("changes cwd to home", async () => {
const session = getCurrentSession(newState);
expect((result as ResultSuccess).exitCode).toBe(0);
expect(session.cwd).toBe(0);
expect(session.cwd).toBe(Fixture.user.home);
expect(session.pwd).toBe(2);
});
test("changes cwd to pwd", async () => {
@@ -96,7 +59,7 @@ test("changes cwd to pwd", async () => {
expect(session.pwd).toBe(2);
});
test("changes cwd to 4", async () => {
const output = await cd.fn(io, state, [], ["/sub/bye"]);
const output = await cd.fn(io, state, [], ["/folder2/subdir2"]);
const newState = output.state;
const result = output.result;
const session = getCurrentSession(newState);
@@ -118,7 +81,7 @@ test("returns an error result (tried to enter a non existent location)", async (
});
test("returns an error result (tried to enter a file)", async () => {
const output = await cd.fn(io, state, [], ["/hello.txt"]);
const output = await cd.fn(io, state, [], ["/some-file"]);
const newState = output.state;
const result = output.result;
const session = getCurrentSession(newState);
+5 -52
View File
@@ -1,48 +1,10 @@
import type { CommandIO } from "@core/command_io";
import { descriptor as echo } from "@core/commands/echo";
import type { ResultSuccess } from "@core/result";
import type { UserInfo } from "@core/session_manager";
import { createInitialShellState, type ShellState } from "@core/shell_state";
import { buildTestFS, type FixtureNode } from "@tests/helpers/filesystems_fixture";
import { type ShellState } from "@core/shell_state";
import { Fixture } from "@tests/helpers/state_fixture";
import { expect, test } from "vitest";
const testTree: FixtureNode = {
inode: 0,
name: "root",
type: "Dir",
children: [
{
inode: 1,
name: "hello.txt",
type: "File",
content: "Goodbye World!",
children: [],
},
{
inode: 2,
name: "sub",
type: "Dir",
children: [
{
inode: 3,
name: "world.txt",
type: "File",
content: "Goodbye!",
children: [],
},
{
inode: 4,
name: "bye",
type: "Dir",
children: [],
},
],
},
],
};
const fs = buildTestFS(testTree);
const stdout: Uint8Array[] = [];
const stderr: Uint8Array[] = [];
@@ -58,17 +20,7 @@ const io: CommandIO = {
},
};
const users: Map<number, UserInfo> = new Map();
const user: UserInfo = {
username: "root",
uid: 0,
gid: 0,
group: [0],
home: 0,
};
users.set(0, user);
const state: ShellState = createInitialShellState(fs, users, user);
const state: ShellState = Fixture.State;
test("returns a Result of type success", async () => {
const output = await echo.fn(io, state, [], ["hello", "world"]);
@@ -76,5 +28,6 @@ test("returns a Result of type success", async () => {
expect(output.result.type).toBe("success");
expect((output.result as ResultSuccess).exitCode).toBe(0);
expect(string).toBe("hello world");
// Fix: added a newline character
expect(string).toEqual("hello world\n");
});
+14 -57
View File
@@ -1,59 +1,12 @@
import type { UserInfo } from "@core/session_manager";
import { createInitialShellState, type ShellState } from "@core/shell_state";
import type { ResultError } from "@core/result";
import { type ShellState } from "@core/shell_state";
import { SIGNAL_MAP } from "@core/signal";
import type { SignalTerminationError } from "@core/util/errors";
import { Shell } from "@shell/shell";
import { buildTestFS, type FixtureNode } from "@tests/helpers/filesystems_fixture";
import { test } from "vitest";
import { Fixture } from "@tests/helpers/state_fixture";
import { expect, test } from "vitest";
const testTree: FixtureNode = {
inode: 0,
name: "root",
type: "Dir",
children: [
{
inode: 1,
name: "hello.txt",
type: "File",
content: "Goodbye World!",
children: [],
},
{
inode: 2,
name: "sub",
type: "Dir",
children: [
{
inode: 3,
name: "world.txt",
type: "File",
content: "Goodbye!",
children: [],
},
{
inode: 4,
name: "bye",
type: "Dir",
children: [],
},
],
},
],
};
const fs = buildTestFS(testTree);
const stdout: Uint8Array[] = [];
const users: Map<number, UserInfo> = new Map();
const user: UserInfo = {
username: "root",
uid: 0,
gid: 0,
group: [0],
home: 0,
};
users.set(0, user);
const state: ShellState = createInitialShellState(fs, users, user);
const state: ShellState = Fixture.State;
test("returns a Result of type success", async () => {
await Shell.init(state);
@@ -61,10 +14,14 @@ test("returns a Result of type success", async () => {
let result;
Shell.Instance?.on("result", payload => {
const decoder = new TextDecoder();
console.log(decoder.decode(payload.result.stdout.toArray()));
console.log(payload);
//const decoder = new TextDecoder();
//console.log(decoder.decode(payload.result.stdout.toArray()));
//console.log(payload);
result = payload.result;
expect(result.type).toBe("error");
expect((result as ResultError<SignalTerminationError>).error.exitCode).toEqual(130);
expect((result as ResultError<SignalTerminationError>).error.signalNumber).toEqual(SIGNAL_MAP.SIGINT);
});
await Shell.Instance?.execute("async");
+5 -5
View File
@@ -1,10 +1,10 @@
import { resolveInode, resolvePath } from "@core/util/path_resolver";
import { expectNodeNotFoundError, expectNotADirectoryError } from "@tests/helpers/error_matchers";
import { buildTestFS } from "@tests/helpers/filesystems_fixture";
import { depth7Tree } from "@tests/helpers/tree_fixture";
import { Fixture7Depth } from "@tests/helpers/state_fixture";
import { describe, expect, test } from "vitest";
const fs = buildTestFS(depth7Tree);
const state = Fixture7Depth.State;
const fs = state.filesystem;
describe("resolvePath", () => {
test("returns an inode from an absolute path", () => {
@@ -64,10 +64,10 @@ describe("resolvePath", () => {
describe("resolveInode", () => {
test("returns an the path from the d4 node", () => {
expect(resolveInode(fs, 4)).toBe("/d1/d2/d3/d4");
expect(resolveInode(state, 4, true)).toBe("/d1/d2/d3/d4");
});
test("returns an empty string from a non existent inode", () => {
expect(resolveInode(fs, 999)).toBe("");
expect(resolveInode(state, 999)).toBe("");
});
});
+12 -45
View File
@@ -1,65 +1,32 @@
import type { UserInfo } from "@core/session_manager";
import { createInitialSessionState, getCurrentSession, login, logout } from "@core/session_manager";
import { createInitialShellState } from "@core/shell_state";
import { buildTestFS } from "@tests/helpers/filesystems_fixture";
import { depth7Tree } from "@tests/helpers/tree_fixture";
import { Fixture } from "@tests/helpers/state_fixture";
import { describe, expect, test } from "vitest";
const root: UserInfo = {
username: "root",
uid: 0,
gid: 0,
group: [0],
home: 0,
};
const testU: UserInfo = {
username: "test",
uid: 1,
gid: 1,
group: [1],
home: 1,
};
const fs = buildTestFS(depth7Tree);
const users = new Map();
users.set(0, root);
users.set(1, testU);
const state = createInitialShellState(fs, users, root);
const state = Fixture.State;
const passMap = new Map();
passMap.set(0, "123");
passMap.set(1, "321");
passMap.set(1000, "321");
test("createInitialSessionState - successfully creates a new session state", () => {
const state = createInitialSessionState(root);
const state = createInitialSessionState(Fixture.user);
expect(state.cwd).toEqual(root.home);
expect(state.pwd).toEqual(root.home);
expect(state.cwd).toEqual(Fixture.user.home);
expect(state.pwd).toEqual(Fixture.user.home);
expect(state.exitCode).toEqual(0);
expect(state.user).toBe(root);
expect(state.user).toBe(Fixture.user);
expect(Object.isFrozen(state)).toBe(true);
});
describe("login", () => {
test("it successfully starts a new session under the user test", () => {
const newState = login(state, "test", "321", passMap);
const newState = login(state, "user", "321", passMap);
const pop = getCurrentSession(newState);
expect(pop.user).toEqual(testU);
expect(pop.user).toEqual(Fixture.user2);
});
test("fails to start a new session. Cause: no password mapped to the uid", () => {
const nopass: UserInfo = {
username: "no pass",
uid: 2,
gid: 1,
group: [1],
home: 1,
};
users.set(2, nopass);
//TODO: Fix to expect the correct object;
expect(() => login(state, "no pass", "321", passMap)).toThrow();
});
@@ -77,14 +44,14 @@ describe("login", () => {
describe("logout", () => {
test("returns the state with the current user poped from the stack", () => {
const newState = login(state, "test", "321", passMap);
const newState = login(state, "user", "321", passMap);
const newPop = getCurrentSession(newState);
expect(newPop.user).toEqual(testU);
expect(newPop.user).toEqual(Fixture.user2);
const newNewState = logout(state);
const pop = getCurrentSession(newNewState);
expect(pop.user).toEqual(root);
expect(pop.user).toEqual(Fixture.user);
});
});
+5 -39
View File
@@ -1,48 +1,14 @@
import { FileSystem } from "@core/filesystem/filesystem";
import { TreeNodeType, type DirectoryNode, type TreeNode } from "@core/filesystem/treenode";
import type { UserInfo } from "@core/session_manager";
import { getCurrentSession } from "@core/session_manager";
import { createInitialShellState, withCwd, withEnv, withExitCode, withHistory } from "@core/shell_state";
import { withCwd, withEnv, withExitCode, withHistory } from "@core/shell_state";
import { Fixture } from "@tests/helpers/state_fixture";
import { expect, test } from "vitest";
const map: Map<number, TreeNode> = new Map();
const time = Date.now();
const root: DirectoryNode = {
type: TreeNodeType.Directory,
inode: 0,
name: "root",
parent: 0,
mode: 0o555,
owner: 0,
group: 0,
mtime: time,
atime: time,
ctime: time,
children: {},
};
map.set(0, root);
const base: ReadonlyMap<number, TreeNode> = map;
const overlay: ReadonlyMap<number, TreeNode | null> = new Map();
const fs = FileSystem.init(base, overlay, 0);
const users: Map<number, UserInfo> = new Map();
const user: UserInfo = {
username: "root",
uid: 0,
gid: 0,
group: [0],
home: 0,
};
users.set(0, user);
const state = createInitialShellState(fs, users, user);
const state = Fixture.State;
test("createInitialShellState - initializes successfully", () => {
expect(state.sessionStack.at(0)).toBeDefined();
expect(state.users.get(user.uid)).toEqual(user);
expect(state.users.get(Fixture.user.uid)).toEqual(Fixture.user);
expect(Object.isFrozen(state)).toBe(true);
});
@@ -61,7 +27,7 @@ test("getCurrentSession - successfully returns the current (top most) session fr
expect(session.exitCode).toBe(0);
expect(session.history).toEqual([]);
expect(session.envVars.size).toBe(0);
expect(session.user).toBe(user);
expect(session.user).toBe(Fixture.user);
});
test("withCwd", () => {
+4 -1
View File
@@ -38,7 +38,10 @@ const fsTwo = buildTestFS(depth7Tree);
describe("dnTraverseTree", () => {
test("successfully traverses down the tree in depth-first pre-order", () => {
const result = dnTraverseTree(fs, 0);
expect(result, `Checking the result ${result} to be [0, 1, 2, 3]`).toEqual([0, 2, 3, 1]);
// This got changed from [0, 2, 3, 1] to [1, 2, 3]
// A bug in dnTraverseTree resulted in the tree traversal not respecting order of nodes, and including root.
// Including root in results caused further problems so it was decided that results wont include the passed root node;
expect(result, `Checking the result ${result} to be [1, 2, 3]`).toEqual([1, 2, 3]);
});
test("returns empty array for a non existent root inode", () => {
+1 -1
View File
@@ -26,7 +26,7 @@ export function expectNotADirectoryError(fn: () => unknown, overrides?: Partial<
inode: expect.any(Number) as number,
message: expect.any(String) as string,
timestamp: expect.any(Number) as number,
nodeType: expect.any(String) as TreeNodeType,
nodeType: expect.any(Number) as TreeNodeType,
...overrides,
});
}
+91
View File
@@ -0,0 +1,91 @@
import { FileSystem } from "@core/filesystem/filesystem";
import type { TreeNode } from "@core/filesystem/treenode";
import type { GroupInfo, UserInfo } from "@core/session_manager";
import { createInitialShellState, type ShellState } from "@core/shell_state";
import { deserializeFileSystem } from "@shell/serializer";
import { buildTestFS } from "./filesystems_fixture";
import { depth7Tree } from "./tree_fixture";
export class Fixture {
/*
root (0)
├── folder1 (1)
│ └── subdir1 (2)
├── folder2 (3)
│ ├── subdir2 (4)
│ └── subdir3 (5)
│ └── empty-foo (6)
└── some-file (7)
*/
static rawJson = `{"atime": 1786341244,"children": [{"atime": 1786341264,"children": [{"atime": 1786341330,"children": [],"content": null,"ctime": 1786341330,"group": 1000,"inode": 2,"mode": 493,"mtime": 1786341330,"name": "subdir1","owner": 1000,"parent": 1,"type": "directory"}],"content": null,"ctime": 1786341330,"group": 1000,"inode": 1,"mode": 493,"mtime": 1786341330,"name": "folder1","owner": 1000,"parent": 0,"type": "directory"},{"atime": 1786341269,"children": [{"atime": 1786341344,"children": [],"content": null,"ctime": 1786341344,"group": 1000,"inode": 4,"mode": 493,"mtime": 1786341344,"name": "subdir2","owner": 1000,"parent": 3,"type": "directory"},{"atime": 1786341345,"children": [{"atime": 1786341356,"children": [],"content": [],"ctime": 1786341356,"group": 1000,"inode": 6,"mode": 420,"mtime": 1786341356,"name": "empty-foo","owner": 1000,"parent": 5,"type": "regular"}],"content": null,"ctime": 1786341356,"group": 1000,"inode": 5,"mode": 493,"mtime": 1786341356,"name": "subdir3","owner": 1000,"parent": 3,"type": "directory"}],"content": null,"ctime": 1786341345,"group": 1000,"inode": 3,"mode": 493,"mtime": 1786341345,"name": "folder2","owner": 1000,"parent": 0,"type": "directory"},{"atime": 1786341312,"children": [],"content": [72,101,108,108,111,44,32,87,111,114,108,100,33,10],"ctime": 1786341312,"group": 1000,"inode": 7,"mode": 420,"mtime": 1786341312,"name": "some-file","owner": 1000,"parent": 0,"type": "regular"}],"content": null,"ctime": 1786341312,"group": 1000,"inode": 0,"mode": 493,"mtime": 1786341312,"name": "root","owner": 1000,"parent": 0,"type": "directory"}`;
static user: UserInfo = {
username: "root",
uid: 0,
gid: 0, // <- PRIMARY GID
group: [0], // <- GROUPS ARRAY
home: 0,
};
static user2: UserInfo = {
username: "user",
uid: 1000,
gid: 1000,
group: [1000],
home: 1,
};
static nopass: UserInfo = {
username: "no pass",
uid: 1001,
gid: 1000,
group: [1000],
home: 2,
};
static group: GroupInfo = {
groupname: "root",
gid: 0,
members: [0], // <- UID
};
static group2: GroupInfo = {
groupname: "user",
gid: 1000,
members: [1000, 1001], // <- UID
};
public static get State(): ShellState {
const rawJson = `{"atime": 1786341244,"children": [{"atime": 1786341264,"children": [{"atime": 1786341330,"children": [],"content": null,"ctime": 1786341330,"group": 1000,"inode": 2,"mode": 493,"mtime": 1786341330,"name": "subdir1","owner": 1000,"parent": 1,"type": "directory"}],"content": null,"ctime": 1786341330,"group": 1000,"inode": 1,"mode": 493,"mtime": 1786341330,"name": "folder1","owner": 1000,"parent": 0,"type": "directory"},{"atime": 1786341269,"children": [{"atime": 1786341344,"children": [],"content": null,"ctime": 1786341344,"group": 1000,"inode": 4,"mode": 493,"mtime": 1786341344,"name": "subdir2","owner": 1000,"parent": 3,"type": "directory"},{"atime": 1786341345,"children": [{"atime": 1786341356,"children": [],"content": [],"ctime": 1786341356,"group": 1000,"inode": 6,"mode": 420,"mtime": 1786341356,"name": "empty-foo","owner": 1000,"parent": 5,"type": "regular"}],"content": null,"ctime": 1786341356,"group": 1000,"inode": 5,"mode": 493,"mtime": 1786341356,"name": "subdir3","owner": 1000,"parent": 3,"type": "directory"}],"content": null,"ctime": 1786341345,"group": 1000,"inode": 3,"mode": 493,"mtime": 1786341345,"name": "folder2","owner": 1000,"parent": 0,"type": "directory"},{"atime": 1786341312,"children": [],"content": [72,101,108,108,111,44,32,87,111,114,108,100,33,10],"ctime": 1786341312,"group": 1000,"inode": 7,"mode": 420,"mtime": 1786341312,"name": "some-file","owner": 1000,"parent": 0,"type": "regular"}],"content": null,"ctime": 1786341312,"group": 1000,"inode": 0,"mode": 493,"mtime": 1786341312,"name": "root","owner": 1000,"parent": 0,"type": "directory"}`;
const base = deserializeFileSystem(rawJson);
const overlay: ReadonlyMap<number, TreeNode | null> = new Map();
const fs = FileSystem.init(base, overlay, base.size - 1);
const users: Map<number, UserInfo> = new Map();
const groups: Map<number, GroupInfo> = new Map();
users.set(0, Fixture.user);
users.set(1000, Fixture.user2);
users.set(1001, Fixture.nopass);
groups.set(0, Fixture.group);
groups.set(1000, Fixture.group2);
return createInitialShellState(fs, users, groups, Fixture.user);
}
}
export class Fixture7Depth extends Fixture {
public static get State(): ShellState {
const fs = buildTestFS(depth7Tree);
const users: Map<number, UserInfo> = new Map();
const groups: Map<number, GroupInfo> = new Map();
users.set(0, Fixture7Depth.user);
users.set(1000, Fixture7Depth.user2);
groups.set(0, Fixture7Depth.group);
groups.set(1000, Fixture7Depth.group2);
return createInitialShellState(fs, users, groups, Fixture7Depth.user);
}
}
+6 -54
View File
@@ -1,57 +1,9 @@
import { getCurrentSession, type UserInfo } from "@core/session_manager";
import { createInitialShellState, type ShellState } from "@core/shell_state";
import { getCurrentSession } from "@core/session_manager";
import { Shell } from "@shell/shell";
import { buildTestFS, type FixtureNode } from "@tests/helpers/filesystems_fixture";
import { Fixture } from "@tests/helpers/state_fixture";
import { describe, expect, test } from "vitest";
const testTree: FixtureNode = {
inode: 0,
name: "root",
type: "Dir",
children: [
{
inode: 1,
name: "hello.txt",
type: "File",
content: "Goodbye World!",
children: [],
},
{
inode: 2,
name: "sub",
type: "Dir",
children: [
{
inode: 3,
name: "world.txt",
type: "File",
content: "Goodbye!",
children: [],
},
{
inode: 4,
name: "bye",
type: "Dir",
children: [],
},
],
},
],
};
const fs = buildTestFS(testTree);
const users: Map<number, UserInfo> = new Map();
const user: UserInfo = {
username: "root",
uid: 0,
gid: 0,
group: [0],
home: 0,
};
users.set(0, user);
const state: ShellState = createInitialShellState(fs, users, user);
const state = Fixture.State;
describe("Shell tests", () => {
test("Successfully executes the cd command", async () => {
@@ -64,13 +16,13 @@ describe("Shell tests", () => {
result = payload.result;
});
await Shell.Instance?.execute("cd /sub");
await Shell.Instance?.execute("cd /folder1");
const statee = Shell.Instance?.State;
expect(result!.type).toEqual("success");
expect(getCurrentSession(statee!).history.length).toBe(1);
expect(getCurrentSession(statee!).history[0]).toEqual("cd /sub");
expect(getCurrentSession(statee!).cwd).toBe(2);
expect(getCurrentSession(statee!).history[0]).toEqual("cd /folder1");
expect(getCurrentSession(statee!).cwd).toBe(1);
expect(getCurrentSession(statee!).exitCode).toBe(0);
});
test("Returns a proper command error from cd", () => {});