Files
kandev/apps/web/components/integrations/workspace-scoped-section.test.tsx
T
2026-07-09 23:20:48 +01:00

33 lines
925 B
TypeScript

import { cleanup, render, screen } from "@testing-library/react";
import { afterEach, describe, expect, it, vi } from "vitest";
const state = {
workspaces: {
activeId: "ws-active",
items: [
{ id: "ws-active", name: "Active" },
{ id: "ws-route", name: "Route" },
],
},
};
vi.mock("@/components/state-provider", () => ({
useAppStore: (selector: (s: typeof state) => unknown) => selector(state),
}));
import { WorkspaceScopedSection } from "./workspace-scoped-section";
describe("WorkspaceScopedSection", () => {
afterEach(() => cleanup());
it("uses an explicit route workspace before the active workspace", () => {
render(
<WorkspaceScopedSection workspaceId="ws-route">
{(workspaceId) => <div data-testid="workspace-id">{workspaceId}</div>}
</WorkspaceScopedSection>,
);
expect(screen.getByTestId("workspace-id").textContent).toBe("ws-route");
});
});