Files
paseo/packages/app/src/hooks/use-workspace-navigation.test.ts
T
Mohamed BoudraandGitHub 868479c493 Fix workspace navigation regression on web (#772)
Centralize workspace navigation behind a small route-derived API so the workspace shell reads active selection from the current Expo Router route instead of a separately synchronized store.

Remove the stale layout-driven active-workspace write that regressed web after 02e5b564.
2026-05-06 13:22:31 +08:00

28 lines
880 B
TypeScript

/**
* @vitest-environment jsdom
*/
import { renderHook } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
const navigateToWorkspaceMock = vi.hoisted(() => vi.fn());
vi.mock("@/stores/navigation-active-workspace-store", () => ({
navigateToWorkspace: navigateToWorkspaceMock,
}));
import { navigateToWorkspace, useWorkspaceNavigation } from "@/hooks/use-workspace-navigation";
describe("useWorkspaceNavigation", () => {
it("re-exports the workspace navigation action", () => {
expect(navigateToWorkspace).toBe(navigateToWorkspaceMock);
});
it("returns a stable callback wrapper", () => {
const { result } = renderHook(() => useWorkspaceNavigation());
result.current.navigateToWorkspace("server-1", "workspace-a");
expect(navigateToWorkspaceMock).toHaveBeenCalledWith("server-1", "workspace-a", undefined);
});
});