Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

pairingUrls.test.ts

24 lines914 Bytes

1import { afterEach, describe, expect, it, vi } from "vite-plus/test";
2​
3import { resolveDesktopPairingUrl, resolveHostedPairingUrl } from "./pairingUrls";
4​
5describe("settings pairing URL helpers", () => {
6 afterEach(() => {
7 vi.unstubAllEnvs();
8 });
9​
10 it("uses direct backend pairing URLs for HTTP endpoints", () => {
11 expect(resolveHostedPairingUrl("http://192.168.1.44:3773", "PAIRCODE")).toBeNull();
12 expect(resolveDesktopPairingUrl("http://192.168.1.44:3773", "PAIRCODE")).toBe(
13 "http://192.168.1.44:3773/pair#token=PAIRCODE",
14 );
15 });
16​
17 it("uses hosted pairing URLs for HTTPS endpoints", () => {
18 vi.stubEnv("VITE_HOSTED_APP_URL", "https://preview.t3.codes");
19​
20 expect(resolveHostedPairingUrl("https://host.tailnet.example.ts.net:3773", "PAIRCODE")).toBe(
21 "https://preview.t3.codes/pair?host=https%3A%2F%2Fhost.tailnet.example.ts.net%3A3773#token=PAIRCODE",
22 );
23 });
24});