Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
Add tests for PrioritizedTaskExecutor
Browse files Browse the repository at this point in the history
  • Loading branch information
medvedev1088 committed Mar 9, 2018
1 parent 55ab1cf commit 6731209
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/prioritizedTaskExecutor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const PrioritizedTaskExecutor = require('../prioritizedTaskExecutor.js')
const tape = require('tape')
const taskExecutor = new PrioritizedTaskExecutor(2)

tape('prioritized task executor test', function (t) {
var tasks = [1, 2, 3, 4]
var callbacks = []
var executionOrder = []
tasks.forEach(function (task) {
taskExecutor.execute(task, function (cb) {
executionOrder.push(task)
callbacks.push(cb)
})
})

callbacks.forEach(function (callback) {
callback()
})

var expectedExecutionOrder = [1, 2, 4, 3]
t.deepEqual(executionOrder, expectedExecutionOrder)
t.end()
})

0 comments on commit 6731209

Please sign in to comment.