Co-authored-by: Julius Marminge <[email protected]> Co-authored-by: Cursor Agent <[email protected]>
69 lines
2.0 KiB
TypeScript
69 lines
2.0 KiB
TypeScript
import { describe, expect, it } from "vite-plus/test";
|
|
|
|
import { resolveRemotePairingTarget } from "./remote.ts";
|
|
|
|
describe("remote", () => {
|
|
it("derives backend urls and token from a pairing url", () => {
|
|
expect(
|
|
resolveRemotePairingTarget({
|
|
pairingUrl: "https://remote.example.com/pair#token=pairing-token",
|
|
}),
|
|
).toEqual({
|
|
credential: "pairing-token",
|
|
httpBaseUrl: "https://remote.example.com/",
|
|
wsBaseUrl: "wss://remote.example.com/",
|
|
});
|
|
});
|
|
|
|
it("accepts pairing urls that still use a query token", () => {
|
|
expect(
|
|
resolveRemotePairingTarget({
|
|
pairingUrl: "https://remote.example.com/pair?token=pairing-token",
|
|
}),
|
|
).toEqual({
|
|
credential: "pairing-token",
|
|
httpBaseUrl: "https://remote.example.com/",
|
|
wsBaseUrl: "wss://remote.example.com/",
|
|
});
|
|
});
|
|
|
|
it("derives backend urls from hosted app pairing links", () => {
|
|
expect(
|
|
resolveRemotePairingTarget({
|
|
pairingUrl:
|
|
"https://app.t3.codes/pair?host=https%3A%2F%2Fdesktop.tailnet.ts.net%3A44342%2F#token=pairing-token",
|
|
}),
|
|
).toEqual({
|
|
credential: "pairing-token",
|
|
httpBaseUrl: "https://desktop.tailnet.ts.net:44342/",
|
|
wsBaseUrl: "wss://desktop.tailnet.ts.net:44342/",
|
|
});
|
|
});
|
|
|
|
it("derives backend urls from a host and pairing code", () => {
|
|
expect(
|
|
resolveRemotePairingTarget({
|
|
host: "https://remote.example.com",
|
|
pairingCode: "pairing-token",
|
|
}),
|
|
).toEqual({
|
|
credential: "pairing-token",
|
|
httpBaseUrl: "https://remote.example.com/",
|
|
wsBaseUrl: "wss://remote.example.com/",
|
|
});
|
|
});
|
|
|
|
it("preserves host ports when normalizing a bare host input", () => {
|
|
expect(
|
|
resolveRemotePairingTarget({
|
|
host: "myserver.com:3000",
|
|
pairingCode: "pairing-token",
|
|
}),
|
|
).toEqual({
|
|
credential: "pairing-token",
|
|
httpBaseUrl: "https://myserver.com:3000/",
|
|
wsBaseUrl: "wss://myserver.com:3000/",
|
|
});
|
|
});
|
|
});
|