mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
test: Add flushPromises utility function
This commit is contained in:
@@ -16,6 +16,8 @@ import { SingleThreadedResourceLocker } from '../../src/util/locking/SingleThrea
|
||||
import { WrappedExpiringReadWriteLocker } from '../../src/util/locking/WrappedExpiringReadWriteLocker';
|
||||
import { guardedStreamFrom } from '../../src/util/StreamUtil';
|
||||
import { PIM, RDF } from '../../src/util/Vocabularies';
|
||||
import { flushPromises } from '../util/Util';
|
||||
|
||||
jest.useFakeTimers('legacy');
|
||||
|
||||
describe('A LockingResourceStore', (): void => {
|
||||
@@ -67,7 +69,7 @@ describe('A LockingResourceStore', (): void => {
|
||||
|
||||
// Wait 1000ms and read
|
||||
jest.advanceTimersByTime(1000);
|
||||
await new Promise(setImmediate);
|
||||
await flushPromises();
|
||||
expect(representation.data.destroyed).toBe(true);
|
||||
|
||||
// Verify a timeout error was thrown
|
||||
@@ -95,7 +97,7 @@ describe('A LockingResourceStore', (): void => {
|
||||
|
||||
// Wait 1000ms and watch the stream be destroyed
|
||||
jest.advanceTimersByTime(1000);
|
||||
await new Promise(setImmediate);
|
||||
await flushPromises();
|
||||
expect(representation.data.destroyed).toBe(true);
|
||||
|
||||
// Verify a timeout error was thrown
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import fetch from 'cross-fetch';
|
||||
import type { App, RedisResourceLocker } from '../../src';
|
||||
|
||||
import { describeIf, getPort } from '../util/Util';
|
||||
import { describeIf, flushPromises, getPort } from '../util/Util';
|
||||
import { getDefaultVariables, getTestConfigPath, instantiateFromConfig } from './Config';
|
||||
|
||||
/**
|
||||
@@ -139,7 +138,7 @@ describeIf('docker', 'A server with a RedisResourceLocker as ResourceLocker', ()
|
||||
const lock2 = locker.acquire(identifier);
|
||||
const lock3 = locker.acquire(identifier);
|
||||
|
||||
await new Promise((resolve): any => setImmediate(resolve));
|
||||
await flushPromises();
|
||||
|
||||
const l2 = lock2.then(async(): Promise<void> => {
|
||||
res += 'l2';
|
||||
|
||||
Reference in New Issue
Block a user