mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-25 01:46:14 -04:00
test timeouts for promises.js
This commit is contained in:
parent
28617ee9d0
commit
ff71e41812
1 changed files with 8 additions and 0 deletions
|
@ -26,10 +26,12 @@ describe(__filename, function () {
|
||||||
const timesLimitPromise = promises.timesLimit(total, concurrency, makePromise);
|
const timesLimitPromise = promises.timesLimit(total, concurrency, makePromise);
|
||||||
|
|
||||||
it('honors concurrency', async function () {
|
it('honors concurrency', async function () {
|
||||||
|
this.timeout(50);
|
||||||
assert.equal(wantIndex, concurrency);
|
assert.equal(wantIndex, concurrency);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('creates another when one completes', async function () {
|
it('creates another when one completes', async function () {
|
||||||
|
this.timeout(50);
|
||||||
const {promise, resolve} = testPromises.shift();
|
const {promise, resolve} = testPromises.shift();
|
||||||
resolve();
|
resolve();
|
||||||
await promise;
|
await promise;
|
||||||
|
@ -37,6 +39,7 @@ describe(__filename, function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('creates the expected total number of promises', async function () {
|
it('creates the expected total number of promises', async function () {
|
||||||
|
this.timeout(50);
|
||||||
while (testPromises.length > 0) {
|
while (testPromises.length > 0) {
|
||||||
// Resolve them in random order to ensure that the resolution order doesn't matter.
|
// Resolve them in random order to ensure that the resolution order doesn't matter.
|
||||||
const i = Math.floor(Math.random() * Math.floor(testPromises.length));
|
const i = Math.floor(Math.random() * Math.floor(testPromises.length));
|
||||||
|
@ -48,10 +51,12 @@ describe(__filename, function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('resolves', async function () {
|
it('resolves', async function () {
|
||||||
|
this.timeout(50);
|
||||||
await timesLimitPromise;
|
await timesLimitPromise;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not create too many promises if total < concurrency', async function () {
|
it('does not create too many promises if total < concurrency', async function () {
|
||||||
|
this.timeout(50);
|
||||||
wantIndex = 0;
|
wantIndex = 0;
|
||||||
assert.equal(testPromises.length, 0);
|
assert.equal(testPromises.length, 0);
|
||||||
const total = 7;
|
const total = 7;
|
||||||
|
@ -67,6 +72,7 @@ describe(__filename, function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts total === 0, concurrency > 0', async function () {
|
it('accepts total === 0, concurrency > 0', async function () {
|
||||||
|
this.timeout(50);
|
||||||
wantIndex = 0;
|
wantIndex = 0;
|
||||||
assert.equal(testPromises.length, 0);
|
assert.equal(testPromises.length, 0);
|
||||||
await promises.timesLimit(0, concurrency, makePromise);
|
await promises.timesLimit(0, concurrency, makePromise);
|
||||||
|
@ -74,6 +80,7 @@ describe(__filename, function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts total === 0, concurrency === 0', async function () {
|
it('accepts total === 0, concurrency === 0', async function () {
|
||||||
|
this.timeout(50);
|
||||||
wantIndex = 0;
|
wantIndex = 0;
|
||||||
assert.equal(testPromises.length, 0);
|
assert.equal(testPromises.length, 0);
|
||||||
await promises.timesLimit(0, 0, makePromise);
|
await promises.timesLimit(0, 0, makePromise);
|
||||||
|
@ -81,6 +88,7 @@ describe(__filename, function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects total > 0, concurrency === 0', async function () {
|
it('rejects total > 0, concurrency === 0', async function () {
|
||||||
|
this.timeout(50);
|
||||||
await assert.rejects(promises.timesLimit(total, 0, makePromise), RangeError);
|
await assert.rejects(promises.timesLimit(total, 0, makePromise), RangeError);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue