From e6dd3f1175995c46a3393db5513555288f2e60a7 Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford Date: Fri, 15 Feb 2019 15:20:38 -0800 Subject: [PATCH] Fix TaskQueue constructor when no options passed --- src/util/task-queue.js | 2 +- test/unit/util_task-queue.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/util/task-queue.js b/src/util/task-queue.js index 9694c67c3..0b452ffb9 100644 --- a/src/util/task-queue.js +++ b/src/util/task-queue.js @@ -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 = []; diff --git a/test/unit/util_task-queue.js b/test/unit/util_task-queue.js index ac1f0c37d..6e484a7a4 100644 --- a/test/unit/util_task-queue.js +++ b/test/unit/util_task-queue.js @@ -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();