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.
28 lines
880 B
TypeScript
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);
|
|
});
|
|
});
|