4fa4f13558
Co-authored-by: iamlukethedev <iamlukethedev@users.noreply.github.com>
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
buildAgentMainSessionKey,
|
|
isSameSessionKey,
|
|
parseAgentIdFromSessionKey,
|
|
} from "@/lib/gateway/GatewayClient";
|
|
|
|
describe("sessionKey helpers", () => {
|
|
it("buildAgentMainSessionKey formats agent session key", () => {
|
|
expect(buildAgentMainSessionKey("agent-1", "main")).toBe("agent:agent-1:main");
|
|
});
|
|
|
|
it("parseAgentIdFromSessionKey extracts agent id", () => {
|
|
expect(parseAgentIdFromSessionKey("agent:agent-1:main")).toBe("agent-1");
|
|
});
|
|
|
|
it("parseAgentIdFromSessionKey returns null when missing", () => {
|
|
expect(parseAgentIdFromSessionKey("")).toBeNull();
|
|
});
|
|
|
|
it("isSameSessionKey requires exact session key match", () => {
|
|
expect(isSameSessionKey("agent:main:studio:one", "agent:main:studio:one")).toBe(true);
|
|
expect(isSameSessionKey("agent:main:studio:one", "agent:main:discord:one")).toBe(false);
|
|
});
|
|
|
|
it("isSameSessionKey trims whitespace", () => {
|
|
expect(isSameSessionKey(" agent:main:studio:one ", "agent:main:studio:one")).toBe(true);
|
|
});
|
|
});
|