Skip to content

armgit / Piik

Public Imported from GitHub
0

Free, open-source screen sharing for private live streams with friends. Watch together in a browser or self-host Piik. 免费开源的私密屏幕共享,支持游戏直播、一起看电影与自部署。

1000 B
Raw Blame
import { describe, expect, it } from "vitest";

import {
  candidateSignalOrigin,
  isPredictedCandidateFoundation,
} from "../src/shared/nat-candidate.ts";

describe("NAT candidate diagnostics", () => {
  it("recognizes only the bounded synthetic foundation namespace", () => {
    expect(isPredictedCandidateFoundation("sp1")).toBe(true);
    expect(isPredictedCandidateFoundation("sm4")).toBe(true);
    expect(isPredictedCandidateFoundation("base")).toBe(false);
    expect(isPredictedCandidateFoundation(null)).toBe(false);
  });

  it("classifies candidate signals without retaining endpoint data", () => {
    expect(candidateSignalOrigin(null)).toBe("end");
    expect(candidateSignalOrigin(" ")).toBe("end");
    expect(
      candidateSignalOrigin(
        "candidate:sp2 1 udp 1 203.0.113.1 50000 typ srflx",
      ),
    ).toBe("predicted");
    expect(
      candidateSignalOrigin(
        "candidate:base 1 udp 1 203.0.113.1 50000 typ srflx",
      ),
    ).toBe("ordinary");
  });
});