Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import { resolveRemotePairingTarget } from "./remote.ts";
4
5describe("remote", () => {
6 it("derives backend urls and token from a pairing url", () => {
7 expect(
8 resolveRemotePairingTarget({
9 pairingUrl: "https://remote.example.com/pair#token=pairing-token",
10 }),
11 ).toEqual({
12 credential: "pairing-token",
13 httpBaseUrl: "https://remote.example.com/",
14 wsBaseUrl: "wss://remote.example.com/",
15 });
16 });
17
18 it("accepts pairing urls that still use a query token", () => {
19 expect(
20 resolveRemotePairingTarget({
21 pairingUrl: "https://remote.example.com/pair?token=pairing-token",
22 }),
23 ).toEqual({
24 credential: "pairing-token",
25 httpBaseUrl: "https://remote.example.com/",
26 wsBaseUrl: "wss://remote.example.com/",
27 });
28 });
29
30 it("derives backend urls from hosted app pairing links", () => {
31 expect(
32 resolveRemotePairingTarget({
33 pairingUrl:
34 "https://app.t3.codes/pair?host=https%3A%2F%2Fdesktop.tailnet.ts.net%3A44342%2F#token=pairing-token",
35 }),
36 ).toEqual({
37 credential: "pairing-token",
38 httpBaseUrl: "https://desktop.tailnet.ts.net:44342/",
39 wsBaseUrl: "wss://desktop.tailnet.ts.net:44342/",
40 });
41 });
42
43 it("derives backend urls from a host and pairing code", () => {
44 expect(
45 resolveRemotePairingTarget({
46 host: "https://remote.example.com",
47 pairingCode: "pairing-token",
48 }),
49 ).toEqual({
50 credential: "pairing-token",
51 httpBaseUrl: "https://remote.example.com/",
52 wsBaseUrl: "wss://remote.example.com/",
53 });
54 });
55
56 it("preserves host ports when normalizing a bare host input", () => {
57 expect(
58 resolveRemotePairingTarget({
59 host: "myserver.com:3000",
60 pairingCode: "pairing-token",
61 }),
62 ).toEqual({
63 credential: "pairing-token",
64 httpBaseUrl: "https://myserver.com:3000/",
65 wsBaseUrl: "wss://myserver.com:3000/",
66 });
67 });
68});