From 7cf22be00c6dec76295c0fb4a0b4da08a5d3f9d7 Mon Sep 17 00:00:00 2001 From: Joachim Van Herwegen Date: Tue, 26 Jan 2021 11:34:38 +0100 Subject: [PATCH] fix: Remove data.once('data') checks from test They were not needed for the test (only need to check if stream is destroyed or not), and caused errors in Node 14.0. --- test/integration/LockingResourceStore.test.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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);