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.
This commit is contained in:
Joachim Van Herwegen 2021-01-26 11:34:38 +01:00 committed by Ruben Verborgh
parent f1304d8d04
commit 7cf22be00c

View File

@ -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<any> {
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);