21 lines
710 B
TypeScript
21 lines
710 B
TypeScript
import { addHistoryEntry, getHistoryEntry } from "@core/history_state";
|
|
import { expect, test } from "vitest";
|
|
|
|
const historyState: readonly string[] = ['echo "Hello World!"'];
|
|
|
|
test("addHistoryEntry - successfully adds an entry to the array", () => {
|
|
const state = addHistoryEntry(historyState, "ls -l");
|
|
|
|
expect(state).toEqual(['echo "Hello World!"', "ls -l"]);
|
|
});
|
|
|
|
test("getHistoryEntry - successfully adds returns an entry ", () => {
|
|
const state = getHistoryEntry(historyState, 0);
|
|
|
|
expect(state).toBe('echo "Hello World!"');
|
|
});
|
|
|
|
test("getHistoryEntry - throws an error because of a nonexistant history entry ", () => {
|
|
expect(() => getHistoryEntry(historyState, 999)).toThrow();
|
|
});
|