diff --git a/test/integration/LockingResourceStore.test.ts b/test/integration/LockingResourceStore.test.ts index 48220c828..05f04265f 100644 --- a/test/integration/LockingResourceStore.test.ts +++ b/test/integration/LockingResourceStore.test.ts @@ -1,4 +1,3 @@ -import type { Readable } from 'stream'; import { RootContainerInitializer } from '../../src/init/RootContainerInitializer'; import { BasicRepresentation } from '../../src/ldp/representation/BasicRepresentation'; import type { Representation } from '../../src/ldp/representation/Representation'; @@ -18,12 +17,6 @@ import { BASE } from './Config'; jest.useFakeTimers(); -async function readOnce(stream: Readable): Promise { - return await new Promise((resolve): void => { - stream.once('data', resolve); - }); -} - describe('A LockingResourceStore', (): void => { let path: string; let store: LockingResourceStore; @@ -82,11 +75,13 @@ describe('A LockingResourceStore', (): void => { // Wait 750ms and read jest.advanceTimersByTime(750); - await expect(readOnce(representation.data)).resolves.toBe(1); + expect(representation.data.destroyed).toBe(false); + representation.data.read(); // Wait 750ms and read jest.advanceTimersByTime(750); - await expect(readOnce(representation.data)).resolves.toBe(2); + expect(representation.data.destroyed).toBe(false); + representation.data.read(); // Wait 1000ms and watch the stream be destroyed jest.advanceTimersByTime(1000);