Permalink
Browse files

release test now passes

  • Loading branch information...
1 parent 42ee958 commit 42c36fa246cf0a4ccd7b2af8b18572b4f042b617 @substack committed Jan 17, 2012
Showing with 18 additions and 20 deletions.
  1. +2 −2 index.js
  2. +1 −1 test/comprehensive.js
  3. +15 −17 test/release.js
View
@@ -74,9 +74,9 @@ Resources.prototype.release = function (token) {
var ix = self.queue.indexOf(token);
if (ix >= 0) {
- queue.splice(ix, 1);
+ self.queue.splice(ix, 1);
- queue.forEach(function (id, j) {
+ self.queue.forEach(function (id, j) {
self.sessions[id].emit('spot', j + 1, self.queue.length);
});
View
@@ -1,5 +1,5 @@
var test = require('tap').test;
-var Waitlist = require('waitlist');
+var Waitlist = require('../');
var EventEmitter = require('events').EventEmitter;
test('comprehensive', function (t) {
View
@@ -1,23 +1,13 @@
var test = require('tap').test;
-var Waitlist = require('waitlist');
+var Waitlist = require('../');
var EventEmitter = require('events').EventEmitter;
test('release', function (t) {
var ws = new Waitlist;
- var resources = [];
- ws.on('resources', function (n) {
- resources.push(n);
- });
-
- var waiting = [];
- ws.on('waiting', function (n) {
- waiting.push(n);
- });
-
- var removed = [];
- ws.on('remove', function (n) {
- removed.push(n);
+ var stats = [];
+ ws.on('stats', function (s) {
+ stats.push(JSON.parse(JSON.stringify(s)));
});
ws.add('moo', {});
@@ -50,9 +40,17 @@ test('release', function (t) {
ws.release(token);
ws.remove('moo');
t.deepEqual(spots, [ 2, 1, 1 ]);
- t.deepEqual(waiting, [ 1, 2, 1, 2, 1, 0 ]);
- t.deepEqual(resources, [ 1, 0 ]);
+ t.deepEqual(stats, [
+ { resources : 1, waiting : 0, using : 0 },
+ { resources : 1, waiting : 0, using : 1 },
+ { resources : 1, waiting : 1, using : 1 },
+ { resources : 1, waiting : 2, using : 1 },
+ { resources : 1, waiting : 1, using : 1 },
+ { resources : 1, waiting : 2, using : 1 },
+ { resources : 1, waiting : 1, using : 1 },
+ { resources : 1, waiting : 0, using : 1 },
+ { resources : 0, waiting : 0, using : 1 },
+ ]);
t.end();
}, 100);
});
-

0 comments on commit 42c36fa

Please sign in to comment.