31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { getCurrentSession } from "@core/session_manager";
|
|
import { Shell } from "@shell/shell";
|
|
import { Fixture } from "@tests/helpers/state_fixture";
|
|
import { describe, expect, test } from "vitest";
|
|
|
|
const state = Fixture.State;
|
|
|
|
describe("Shell tests", () => {
|
|
test("Successfully executes the cd command", async () => {
|
|
await Shell.init(state);
|
|
|
|
let result;
|
|
|
|
Shell.Instance?.on("result", payload => {
|
|
console.log(payload);
|
|
result = payload.result;
|
|
});
|
|
|
|
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 /folder1");
|
|
expect(getCurrentSession(statee!).cwd).toBe(1);
|
|
expect(getCurrentSession(statee!).exitCode).toBe(0);
|
|
});
|
|
test("Returns a proper command error from cd", () => {});
|
|
test("Returns an empty success result as per parsing a whitespace character or inputing nothing", () => {});
|
|
});
|