mirror of
https://github.com/iamlukethedev/Claw3D.git
synced 2026-07-31 03:52:15 +00:00
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import { createElement } from "react";
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { cleanup, render, screen } from "@testing-library/react";
|
|
|
|
describe("useRuntimeConnection", () => {
|
|
afterEach(() => {
|
|
cleanup();
|
|
vi.resetModules();
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
it("selects the hermes provider from the active adapter type", async () => {
|
|
vi.doMock("@/lib/gateway/GatewayClient", () => ({
|
|
useGatewayConnection: () => ({
|
|
client: {},
|
|
status: "connected",
|
|
gatewayUrl: "ws://localhost:18789",
|
|
token: "",
|
|
selectedAdapterType: "hermes",
|
|
detectedAdapterType: "hermes",
|
|
activeAdapterType: "hermes",
|
|
localGatewayDefaults: null,
|
|
error: null,
|
|
connectPromptReady: true,
|
|
shouldPromptForConnect: false,
|
|
connect: async () => {},
|
|
disconnect: () => {},
|
|
useLocalGatewayDefaults: () => {},
|
|
setGatewayUrl: () => {},
|
|
setToken: () => {},
|
|
setSelectedAdapterType: () => {},
|
|
clearError: () => {},
|
|
}),
|
|
}));
|
|
|
|
const { useRuntimeConnection } = await import("@/lib/runtime/useRuntimeConnection");
|
|
|
|
const Probe = () => {
|
|
const state = useRuntimeConnection({} as never);
|
|
return createElement(
|
|
"div",
|
|
null,
|
|
createElement("div", { "data-testid": "providerId" }, state.providerId),
|
|
createElement("div", { "data-testid": "providerLabel" }, state.providerLabel)
|
|
);
|
|
};
|
|
|
|
render(createElement(Probe));
|
|
|
|
expect(screen.getByTestId("providerId")).toHaveTextContent("hermes");
|
|
expect(screen.getByTestId("providerLabel")).toHaveTextContent("Hermes");
|
|
});
|
|
});
|