From 2bc8778f00a96b990a44a7d7bdfd83b4daef223d Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Mon, 3 Dec 2018 21:25:06 -0500 Subject: [PATCH 1/2] Test commit for checking out Travis. --- test/unit/util_task-queue.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/unit/util_task-queue.js b/test/unit/util_task-queue.js index 2e67770fd..6b2ab63f6 100644 --- a/test/unit/util_task-queue.js +++ b/test/unit/util_task-queue.js @@ -5,6 +5,8 @@ const TaskQueue = require('../../src/util/task-queue'); const testCompare = require('../fixtures/test-compare'); +// TODO: temporary comment to trigger git + test('constructor', t => { // Max tokens = 1000, refill 1000 tokens per second (1 per millisecond), and start with 0 tokens const bukkit = new TaskQueue(1000, 1000, 0); From 16e45957fa9100b5a6a618ac564aaeddc0f7bbbf Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Tue, 4 Dec 2018 12:12:06 -0500 Subject: [PATCH 2/2] Adding a simulated timer to the task queue test instead of using a Timer object. --- test/unit/util_task-queue.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/unit/util_task-queue.js b/test/unit/util_task-queue.js index 6b2ab63f6..50d187606 100644 --- a/test/unit/util_task-queue.js +++ b/test/unit/util_task-queue.js @@ -1,18 +1,16 @@ const test = require('tap').test; -const Timer = require('../../src/util/timer'); const TaskQueue = require('../../src/util/task-queue'); const testCompare = require('../fixtures/test-compare'); -// TODO: temporary comment to trigger git - test('constructor', t => { // Max tokens = 1000, refill 1000 tokens per second (1 per millisecond), and start with 0 tokens const bukkit = new TaskQueue(1000, 1000, 0); - const timer = new Timer(); - timer.start(); + // Simulate time passing with a stubbed timer + const simulatedTimeStart = Date.now(); + bukkit._timer = {timeElapsed: () => Date.now() - simulatedTimeStart}; const taskResults = []; const promises = []; @@ -28,13 +26,13 @@ test('constructor', t => { bukkit.cancelAll(); promises.push( bukkit.do(() => taskResults.push('a'), 50).then(() => - testCompare(t, timer.timeElapsed(), '>=', 50, 'Costly task must wait') + testCompare(t, bukkit._timer.timeElapsed(), '>=', 50, 'Costly task must wait') ), bukkit.do(() => taskResults.push('b'), 10).then(() => - testCompare(t, timer.timeElapsed(), '>=', 60, 'Tasks must run in serial') + testCompare(t, bukkit._timer.timeElapsed(), '>=', 60, 'Tasks must run in serial') ), bukkit.do(() => taskResults.push('c'), 1).then(() => - testCompare(t, timer.timeElapsed(), '<', 80, 'Cheap task should run soon') + testCompare(t, bukkit._timer.timeElapsed(), '<', 80, 'Cheap task should run soon') ) ); return Promise.all(promises).then(() => {