logout test written, green

This commit is contained in:
2026-08-03 22:34:09 +02:00
parent d26d7d35ac
commit 394e0b9e7c
+15 -1
View File
@@ -1,5 +1,5 @@
import type { UserInfo } from "@core/session_manager";
import { createInitialSessionState, getCurrentSession, login } 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";
@@ -74,3 +74,17 @@ describe("login", () => {
expect(() => login(state, "no user", "321", passMap)).toThrow();
});
});
describe("logout", () => {
test("returns the state with the current user poped from the stack", () => {
const newState = login(state, "test", "321", passMap);
const newPop = getCurrentSession(newState);
expect(newPop.user).toEqual(testU);
const newNewState = logout(state);
const pop = getCurrentSession(newNewState);
expect(pop.user).toEqual(root);
});
});