Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

release test now passes

  • Loading branch information...
commit 42c36fa246cf0a4ccd7b2af8b18572b4f042b617 1 parent 42ee958
James Halliday authored

Showing 3 changed files with 18 additions and 20 deletions. Show diff stats Hide diff stats

  1. +2 2 index.js
  2. +1 1  test/comprehensive.js
  3. +15 17 test/release.js
4 index.js
@@ -74,9 +74,9 @@ Resources.prototype.release = function (token) {
74 74
75 75 var ix = self.queue.indexOf(token);
76 76 if (ix >= 0) {
77   - queue.splice(ix, 1);
  77 + self.queue.splice(ix, 1);
78 78
79   - queue.forEach(function (id, j) {
  79 + self.queue.forEach(function (id, j) {
80 80 self.sessions[id].emit('spot', j + 1, self.queue.length);
81 81 });
82 82
2  test/comprehensive.js
... ... @@ -1,5 +1,5 @@
1 1 var test = require('tap').test;
2   -var Waitlist = require('waitlist');
  2 +var Waitlist = require('../');
3 3 var EventEmitter = require('events').EventEmitter;
4 4
5 5 test('comprehensive', function (t) {
32 test/release.js
... ... @@ -1,23 +1,13 @@
1 1 var test = require('tap').test;
2   -var Waitlist = require('waitlist');
  2 +var Waitlist = require('../');
3 3 var EventEmitter = require('events').EventEmitter;
4 4
5 5 test('release', function (t) {
6 6 var ws = new Waitlist;
7 7
8   - var resources = [];
9   - ws.on('resources', function (n) {
10   - resources.push(n);
11   - });
12   -
13   - var waiting = [];
14   - ws.on('waiting', function (n) {
15   - waiting.push(n);
16   - });
17   -
18   - var removed = [];
19   - ws.on('remove', function (n) {
20   - removed.push(n);
  8 + var stats = [];
  9 + ws.on('stats', function (s) {
  10 + stats.push(JSON.parse(JSON.stringify(s)));
21 11 });
22 12
23 13 ws.add('moo', {});
@@ -50,9 +40,17 @@ test('release', function (t) {
50 40 ws.release(token);
51 41 ws.remove('moo');
52 42 t.deepEqual(spots, [ 2, 1, 1 ]);
53   - t.deepEqual(waiting, [ 1, 2, 1, 2, 1, 0 ]);
54   - t.deepEqual(resources, [ 1, 0 ]);
  43 + t.deepEqual(stats, [
  44 + { resources : 1, waiting : 0, using : 0 },
  45 + { resources : 1, waiting : 0, using : 1 },
  46 + { resources : 1, waiting : 1, using : 1 },
  47 + { resources : 1, waiting : 2, using : 1 },
  48 + { resources : 1, waiting : 1, using : 1 },
  49 + { resources : 1, waiting : 2, using : 1 },
  50 + { resources : 1, waiting : 1, using : 1 },
  51 + { resources : 1, waiting : 0, using : 1 },
  52 + { resources : 0, waiting : 0, using : 1 },
  53 + ]);
55 54 t.end();
56 55 }, 100);
57 56 });
58   -

0 comments on commit 42c36fa

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