// The file an address names open on the Files page: the player's key wins over the viewer's, and only a // real row id opens anything — a fractional, zero, negative or garbled one would look up a row that // cannot exist and say the file is gone. import { describe, expect, it } from "vitest"; import { openFileFrom } from "./filesUrlState"; const from = (q: string) => openFileFrom(new URLSearchParams(q)); describe("openFileFrom", () => { it("reads the viewer's and the player's file", () => { expect(from("fview=3")).toEqual({ open: "view", id: 3 }); expect(from("fplay=4")).toEqual({ open: "play", id: 4 }); expect(from("fview=3&fplay=4")).toEqual({ open: "play", id: 4 }); }); it("opens nothing for an id that is not a positive integer", () => { for (const raw of ["1.5", "0", "-2", "abc", ""]) expect(from(`fview=${raw}`)).toBeNull(); expect(from("q=x")).toBeNull(); }); });