Permalink
Browse files

[test] improve callbacks.js test

  • Loading branch information...
1 parent c2cf24d commit 356423c73ad37f130bfa6f38d7d959c85b71b1f3 @AndreasMadsen committed Sep 5, 2012
Showing with 10 additions and 10 deletions.
  1. +10 −10 test/callbacks.js
View
20 test/callbacks.js
@@ -104,27 +104,27 @@ test("callback hook", function (t) {
var server = require('net').createServer();
// argument passed public to listen
- function listenCallback(err, fd) {
+ function listenCallback() {
t.equal(callOrder++, 1, 'real callback was executed after patch callback');
+ console.log('hi');
- server.close(t.end.bind(t));
+ server.close(function () {
+ console.log('close');
+ t.end();
+ });
}
// attach monkey patch callback
hook.callback.attach(function callbackAttach(name, callback) {
- // BUG: event.EventEmtter.on should be here
- if (name === 'events.EventEmitter.on' || name === 'process.nextTick') {
- return callback;
- }
+ if (name !== 'net.Server.listen') return callback;
- // BUG: this isn't executed
hook.callback.deattach(callbackAttach);
t.equal(name, 'net.Server.listen', 'name argument in .attach is net.Server.listen');
t.equal(callback, listenCallback, 'callback argument match input');
// set a new callback
- return function (err, fd) {
+ return function () {
t.equal(callOrder++, 0, 'pached callback in correct order');
// chain the callback
@@ -141,7 +141,7 @@ test("callback hook", function (t) {
var callOrder = 0;
// argument passed public to nextTick
- function tickCallback(err, fd) {
+ function tickCallback() {
t.equal(callOrder++, 1, 'real callback was executed after patch callback');
t.end();
}
@@ -154,7 +154,7 @@ test("callback hook", function (t) {
t.equal(callback, tickCallback, 'callback argument match input');
// set a new callback
- return function (err, fd) {
+ return function () {
t.equal(callOrder++, 0, 'pached callback is executed first');
// chain the callback

0 comments on commit 356423c

Please sign in to comment.