feat: release 2.5.1
This commit is contained in:
@@ -267,4 +267,19 @@ describe("authenticated API transport", () => {
|
||||
};
|
||||
await expect(consume()).rejects.toBeInstanceOf(SyntaxError);
|
||||
});
|
||||
|
||||
test("parses many records packed into one NDJSON chunk", async () => {
|
||||
const expected = Array.from({ length: 2_000 }, (_, sequence) => ({ sequence }));
|
||||
globalThis.fetch = mock(async () =>
|
||||
new Response(`${expected.map((record) => JSON.stringify(record)).join("\n")}\n`),
|
||||
) as unknown as typeof fetch;
|
||||
|
||||
const actual: Array<{ sequence: number }> = [];
|
||||
for await (const record of apiStreamNdjson<{ sequence: number }>(
|
||||
"/events",
|
||||
{},
|
||||
{ authenticated: false, baseUrl: "https://api.test" },
|
||||
)) actual.push(record);
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user