From 966e361fb35399bccd4515acaa7f82428ff912d7 Mon Sep 17 00:00:00 2001 From: Harvey Zuccon Date: Tue, 21 Jul 2026 12:51:37 +1000 Subject: [PATCH] Improve test fixtures --- tests/fixtures/events.fixtures.ts | 4 ++-- tests/helpers/sse-stream.ts | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/fixtures/events.fixtures.ts b/tests/fixtures/events.fixtures.ts index a19bd30..60ce553 100644 --- a/tests/fixtures/events.fixtures.ts +++ b/tests/fixtures/events.fixtures.ts @@ -2,14 +2,14 @@ import type { SSEvent } from '../../src/types.js'; type EventFixture = { raw: string; - parsed?: SSEvent[]; + parsed: SSEvent[]; }; /** Combines all the raw strings into a single chunk and flattens the parsed arrays into a single array to simulate multi-event chunks. */ const withCombinedChunk = (fixtures: EventFixture[]): EventFixture => { return { raw: fixtures.map(({ raw }) => raw).join(''), - parsed: fixtures.flatMap(({ parsed }) => parsed ?? []), + parsed: fixtures.flatMap(({ parsed }) => parsed), }; }; diff --git a/tests/helpers/sse-stream.ts b/tests/helpers/sse-stream.ts index f2fa094..a04e7da 100644 --- a/tests/helpers/sse-stream.ts +++ b/tests/helpers/sse-stream.ts @@ -41,8 +41,6 @@ export class SseTestStream { await new Promise((resolve) => setTimeout(resolve, chunkDelayMs)); } - if (this.closed) return; - controller.enqueue(encoder.encode(chunks[i]!)); } @@ -57,8 +55,6 @@ export class SseTestStream { * Ends the HTTP body the way a server closing the SSE connection would. */ close(): void { - if (this.closed) return; - this.closed = true; this.controller?.close(); }