Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import { frameReader } from "./tanStackSourceEvents.ts";
4
5describe("frameReader", () => {
6 it("records the id-only frames Source opens with and reports only frames with an event", () => {
7 const cursor = { lastEventId: undefined as string | undefined };
8 const read = frameReader(cursor);
9 // Captured from `GET /repos/{owner}/{repo}/events?scope=pr&number=4`, then one change.
10 const lines = [
11 ": ok",
12 "",
13 "id: 135",
14 "",
15 "id: 136",
16 "event: item",
17 'data: {"type":"item"}',
18 "",
19 ];
20 expect(lines.map(read)).toEqual([false, false, false, false, false, false, false, true]);
21 expect(cursor.lastEventId).toBe("136");
22 });
23});