github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/web/src/PathBuilder.test.tsx (about)

     1  import PathBuilder from "./PathBuilder"
     2  
     3  describe("PathBuilder", () => {
     4    it("handles ports", () => {
     5      let pb = PathBuilder.forTesting("localhost:10350", "/r/fe")
     6      expect(pb.getDataUrl()).toEqual("ws://localhost:10350/ws/view")
     7    })
     8  
     9    it("handles snapshots in prod", () => {
    10      let pb = PathBuilder.forTesting("snapshots.tilt.dev", "/snapshot/aaaaaa")
    11      expect(pb.getDataUrl()).toEqual("/api/snapshot/aaaaaa")
    12      expect(pb.path("/foo")).toEqual("/snapshot/aaaaaa/foo")
    13    })
    14  
    15    it("handles snapshots in dev", () => {
    16      let pb = PathBuilder.forTesting("localhost", "/snapshot/aaaaaa")
    17      expect(pb.getDataUrl()).toEqual("/api/snapshot/aaaaaa")
    18      expect(pb.path("/foo")).toEqual("/snapshot/aaaaaa/foo")
    19    })
    20  
    21    it("handles websocket to an alternate host", () => {
    22      // When tilt starts with --host
    23      let pb = PathBuilder.forTesting("10.205.131.189:10350", "/r/fe")
    24      expect(pb.getDataUrl()).toEqual("ws://10.205.131.189:10350/ws/view")
    25    })
    26  
    27    it("handles secure websockets", () => {
    28      // When run with an https frontend (like ngrok)
    29      let pb = new PathBuilder({
    30        protocol: "https:",
    31        host: "10.205.131.189:10350",
    32        pathname: "/r/fe",
    33      })
    34      expect(pb.getDataUrl()).toEqual("wss://10.205.131.189:10350/ws/view")
    35    })
    36  })