remoteEnvironmentKey.test.ts 1003 B

12345678910111213141516171819202122
  1. import { describe, expect, it } from "vitest";
  2. import { buildRemoteEnvironmentKey } from "../src/remoteEnvironmentKey.js";
  3. describe("buildRemoteEnvironmentKey", () => {
  4. it("ignores workspace/session facts and normalizes every remote target kind", () => {
  5. expect(buildRemoteEnvironmentKey({ kind: "ssh", host: "EXAMPLE.COM", username: "dev" })).toBe(
  6. buildRemoteEnvironmentKey({ kind: "ssh", host: "example.com", port: 22, username: "dev" }),
  7. );
  8. expect(buildRemoteEnvironmentKey({ kind: "wsl", distro: " Ubuntu ", user: "dev" })).toBe(
  9. "wsl:Ubuntu\0dev",
  10. );
  11. expect(buildRemoteEnvironmentKey({ kind: "docker", container: " zcode-dev " })).toBe(
  12. "docker:zcode-dev",
  13. );
  14. expect(
  15. buildRemoteEnvironmentKey({ kind: "server", url: "wss://host.example/ws?token=x" }),
  16. ).toBe("server:https://host.example");
  17. expect(
  18. buildRemoteEnvironmentKey({ kind: "server", serverId: "srv-1", url: "https://ignored" }),
  19. ).toBe("server:srv-1");
  20. });
  21. });