Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

split tap tests up into multiple files

  • Loading branch information...
commit 304e4893c763123098c817e723ab1fdd972b9a8f 1 parent e506f9e
@substack authored
View
4 package.json
@@ -16,10 +16,10 @@
"hashish" : ">=0.0.1"
},
"devDependencies" : {
- "expresso" : ">=0.6.0"
+ "tap" : "0.2.x"
},
"scripts" : {
- "test" : "expresso"
+ "test" : "tap test/*.js"
},
"license" : "MIT/X11",
"engine" : ["node >=0.2.0"]
View
78 test/resources.js → test/comprehensive.js
@@ -116,81 +116,3 @@ test('comprehensive', function (t) {
t.end();
}, 500);
});
-
-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);
- });
-
- ws.add('moo', {});
-
- var t1 = ws.acquire(50, function () {});
- var t2 = ws.acquire(50, function () {});
-
- var em = new EventEmitter;
-
- em.on('token', function (tt) {
- setTimeout(function () {
- t.equal(token, tt);
- }, 1);
- });
-
- var spots = [];
- em.on('spot', function (n) {
- spots.push(n);
- });
-
- var token = ws.acquire(150, em.emit.bind(em));
- setTimeout(function () {
- ws.acquire(50, function () {});
- ws.release(token);
- }, 30);
-
- ws.release(t1);
-
- setTimeout(function () {
- 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.end();
- }, 100);
-});
-
-test('zero', function (t) {
- var ws = new Waitlist;
- ws.add('zing', {});
-
- var em = new EventEmitter;
- var counts = { available : 0, expire : 0 };
- em.on('available', function (t) {
- counts.available ++;
- });
- em.on('expire', function (t) {
- counts.expire ++;
- });
-
- var t0 = ws.acquire(0, em.emit.bind(em));
- var t1 = ws.acquire(0, em.emit.bind(em));
-
- setTimeout(function () {
- t.equal(counts.available, 1);
- t.equal(counts.expire, 0);
- ws.remove('zing');
- t.end();
- }, 100);
-});
View
58 test/release.js
@@ -0,0 +1,58 @@
+var test = require('tap').test;
+var Waitlist = require('waitlist');
+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);
+ });
+
+ ws.add('moo', {});
+
+ var t1 = ws.acquire(50, function () {});
+ var t2 = ws.acquire(50, function () {});
+
+ var em = new EventEmitter;
+
+ em.on('token', function (tt) {
+ setTimeout(function () {
+ t.equal(token, tt);
+ }, 1);
+ });
+
+ var spots = [];
+ em.on('spot', function (n) {
+ spots.push(n);
+ });
+
+ var token = ws.acquire(150, em.emit.bind(em));
+ setTimeout(function () {
+ ws.acquire(50, function () {});
+ ws.release(token);
+ }, 30);
+
+ ws.release(t1);
+
+ setTimeout(function () {
+ 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.end();
+ }, 100);
+});
+
View
27 test/zero.js
@@ -0,0 +1,27 @@
+var test = require('tap').test;
+var Waitlist = require('waitlist');
+var EventEmitter = require('events').EventEmitter;
+
+test('zero', function (t) {
+ var ws = new Waitlist;
+ ws.add('zing', {});
+
+ var em = new EventEmitter;
+ var counts = { available : 0, expire : 0 };
+ em.on('available', function (t) {
+ counts.available ++;
+ });
+ em.on('expire', function (t) {
+ counts.expire ++;
+ });
+
+ var t0 = ws.acquire(0, em.emit.bind(em));
+ var t1 = ws.acquire(0, em.emit.bind(em));
+
+ setTimeout(function () {
+ t.equal(counts.available, 1);
+ t.equal(counts.expire, 0);
+ ws.remove('zing');
+ t.end();
+ }, 100);
+});
Please sign in to comment.
Something went wrong with that request. Please try again.