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

pullRequestFilesViewed.test.ts

23 lines1013 Bytes

1import { describe, expect, it } from "vite-plus/test";
2import { viewedOverlay } from "./pullRequestFilesViewed";
3​
4describe("viewedOverlay", () => {
5 it("keeps a press while its write is in flight", () => {
6 expect(
7 viewedOverlay({ "a.ts": { viewed: true, version: 1, awaitingReadAfter: undefined } }, 3),
8 ).toEqual({ "a.ts": true });
9 });
10​
11 it("yields a landed press to the next completed read, even one with unchanged data", () => {
12 const presses = { "a.ts": { viewed: true, version: 1, awaitingReadAfter: 3 } };
13 expect(viewedOverlay(presses, 3)).toEqual({ "a.ts": true });
14 expect(viewedOverlay(presses, 4)).toEqual({});
15 });
16​
17 it("treats paths named after Object members as ordinary paths", () => {
18 expect(viewedOverlay({}, 0)["constructor"]).toBeUndefined();
19 const press = { viewed: false, version: 1, awaitingReadAfter: undefined };
20 const overlay = viewedOverlay(Object.fromEntries([["__proto__", press]]), 0);
21 expect(overlay["__proto__"]).toBe(false);
22 });
23});