Fix TaskQueue constructor when no options passed

This commit is contained in:
Christopher Willis-Ford 2019-02-15 15:20:38 -08:00
parent be040f4c9b
commit e6dd3f1175
2 changed files with 10 additions and 1 deletions

View file

@ -17,7 +17,7 @@ class TaskQueue {
* @property {number} maxTotalCost - reject a task if total queue cost would pass this limit (default: no limit).
* @memberof TaskQueue
*/
constructor (maxTokens, refillRate, options = null) {
constructor (maxTokens, refillRate, options = {}) {
this._maxTokens = maxTokens;
this._refillRate = refillRate;
this._pendingTaskRecords = [];

View file

@ -36,6 +36,15 @@ test('spec', t => {
t.end();
});
test('constructor', t => {
t.ok(new TaskQueue(1, 1));
t.ok(new TaskQueue(1, 1, {}));
t.ok(new TaskQueue(1, 1, {startingTokens: 0}));
t.ok(new TaskQueue(1, 1, {maxTotalCost: 999}));
t.ok(new TaskQueue(1, 1, {startingTokens: 0, maxTotalCost: 999}));
t.end();
});
test('run tasks', async t => {
const bukkit = makeTestQueue();