Move flush from global to test util
Also rename to waitEventLoop() and remove polymer dependency. Cases
where callback or synchronous version were used were rewritten to
promises.
Release-Notes: skip
Change-Id: I3e480d3d91db73df509a6b2da2c9b22fb94fe07b
diff --git a/polygerrit-ui/app/services/scheduler/max-in-flight-scheduler_test.ts b/polygerrit-ui/app/services/scheduler/max-in-flight-scheduler_test.ts
index 53d92ca..0f24eda 100644
--- a/polygerrit-ui/app/services/scheduler/max-in-flight-scheduler_test.ts
+++ b/polygerrit-ui/app/services/scheduler/max-in-flight-scheduler_test.ts
@@ -3,8 +3,8 @@
* Copyright 2022 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
-import '../../test/common-test-setup-karma.js';
-import {assertFails} from '../../test/test-utils.js';
+import '../../test/common-test-setup-karma';
+import {assertFails, waitEventLoop} from '../../test/test-utils';
import {Scheduler} from './scheduler';
import {MaxInFlightScheduler} from './max-in-flight-scheduler';
import {FakeScheduler} from './fake-scheduler';
@@ -67,7 +67,7 @@
assert.equal(fakeScheduler.scheduled.length, 2);
fakeScheduler.resolve();
assert.equal(fakeScheduler.scheduled.length, 1);
- await flush();
+ await waitEventLoop();
assert.equal(fakeScheduler.scheduled.length, 2);
});
@@ -78,7 +78,7 @@
assert.equal(fakeScheduler.scheduled.length, 2);
fakeScheduler.reject(new Error('Fake Error'));
assert.equal(fakeScheduler.scheduled.length, 1);
- await flush();
+ await waitEventLoop();
assert.equal(fakeScheduler.scheduled.length, 2);
});
@@ -89,7 +89,7 @@
}
for (let i = 0; i < 3; ++i) {
fakeScheduler.resolve();
- await flush();
+ await waitEventLoop();
}
const res = await Promise.all(promises);
assert.deepEqual(res, [0, 1, 2]);