From 49a0faa05072430e518f6c6c8dacf0720f8a7b46 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Wed, 1 Oct 2025 08:30:27 +0100 Subject: [PATCH] fix test --- packages/objectloader2/src/queues/batchingQueue.test.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/objectloader2/src/queues/batchingQueue.test.ts b/packages/objectloader2/src/queues/batchingQueue.test.ts index c683b8a78..727c1f96b 100644 --- a/packages/objectloader2/src/queues/batchingQueue.test.ts +++ b/packages/objectloader2/src/queues/batchingQueue.test.ts @@ -213,7 +213,7 @@ describe('BatchingQueue', () => { test('should drain items even with ongoing processing during dispose', async () => { const processSpy = vi.fn() let firstBatchStarted = false - let allowFirstBatchToComplete: (() => void) | undefined = undefined + let allowFirstBatchToComplete: (() => void) | null = null const queue = new BatchingQueue({ batchSize: 2, @@ -238,10 +238,11 @@ describe('BatchingQueue', () => { queue.add('key1', 'item1') queue.add('key2', 'item2') - // Wait for first batch to start processing + // Wait for first batch to start processing and allowFirstBatchToComplete to be assigned await new Promise((resolve) => setTimeout(resolve, 50)) expect(firstBatchStarted).toBe(true) expect(processSpy).toHaveBeenCalledTimes(1) + expect(allowFirstBatchToComplete).not.toBeNull() // Add more items while first batch is still processing queue.add('key3', 'item3') @@ -254,7 +255,7 @@ describe('BatchingQueue', () => { const disposePromise = queue.disposeAsync() // Allow the first batch to complete - allowFirstBatchToComplete?.() + allowFirstBatchToComplete!() // Wait for disposal to complete await disposePromise