Created
April 14, 2011 22:31
-
-
Save bcg/920725 to your computer and use it in GitHub Desktop.
An example of nodeunit + httputil + sinon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require('sys'), | |
nodeUnit = require('nodeunit'), | |
httputil = nodeUnit.utils.httputil, | |
sinon = require('sinon'), | |
logger = require('ain-tcp'); | |
module.exports = nodeUnit.testCase({ | |
setUp: function(callback) { | |
router = require('router').router; // using choreographer | |
callback(); | |
}, | |
tearDown: function(callback) { | |
callback(); | |
}, | |
'Test foo=bar': function(assert) { | |
var mock = sinon.mock(logger); | |
mock.expects('send').withArgs('event', 'info', 'yay!').once(); | |
httputil(router, function(server, client) { | |
client.fetch('GET', '/test?foo=bar', {}, function(res) { | |
assert.equal(200, res.statusCode); | |
server.close(); | |
mock.verify(); | |
assert.done(); | |
}); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment