Skip to content

Instantly share code, notes, and snippets.

@bcg
Created April 14, 2011 22:31
Show Gist options
  • Save bcg/920725 to your computer and use it in GitHub Desktop.
Save bcg/920725 to your computer and use it in GitHub Desktop.
An example of nodeunit + httputil + sinon
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