Skip to content
Browse files

updated tests for using event

  • Loading branch information...
1 parent b3db35a commit 4160177ebaadce5935c5adf4a416ee44f97d7569 @substack committed
Showing with 7 additions and 1 deletion.
  1. +7 −1 test/resources.js
View
8 test/resources.js
@@ -5,13 +5,16 @@ exports.comprehensive = function (assert) {
function Foo (x) { this.x = x }
var ws = new Waitlist;
- var counts = { resources : [], waiting : [] };
+ var counts = { resources : [], waiting : [], using : [] };
ws.on('resources', function (n) {
counts.resources.push(n);
});
ws.on('waiting', function (n) {
counts.waiting.push(n);
});
+ ws.on('using', function (n) {
+ counts.using.push(n);
+ });
[ 1, 2 ].forEach(function (i) {
ws.add(i, new Foo(i * 10));
@@ -20,6 +23,7 @@ exports.comprehensive = function (assert) {
assert.deepEqual(counts, {
resources : [ 1, 2 ],
waiting : [],
+ using : []
});
var e1 = new EventEmitter;
@@ -56,10 +60,12 @@ exports.comprehensive = function (assert) {
assert.equal(avail.length, 2);
assert.equal(expired.length, 0);
assert.deepEqual(counts.waiting, [ 1 ]);
+ assert.deepEqual(counts.using, [ 1, 2 ]);
}, 25);
setTimeout(function () {
assert.deepEqual(counts.waiting, [ 1, 0, 0, 0 ]);
+ assert.deepEqual(counts.using, [ 1, 2, 2, 2, 1, 0 ]);
assert.equal(avail.length, 3);
assert.equal(expired.length, 3);
assert.equal(spots.length, 1);

0 comments on commit 4160177

Please sign in to comment.
Something went wrong with that request. Please try again.