Last active
August 29, 2015 13:57
-
-
Save hitsujiwool/9462896 to your computer and use it in GitHub Desktop.
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 sinon = require('sinon'); | |
var assert = require('assert'); | |
function async(cb) { | |
setTimeout(function() { | |
cb(); | |
}, 1000); | |
} | |
describe('async()', function() { | |
it('should call callback', function() { | |
var clock = sinon.useFakeTimers('setTimeout'); | |
var cb = sinon.spy(); | |
async(cb); | |
clock.tick(999999); | |
assert(cb.called); | |
}); | |
}); |
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 sinon = require('sinon'); | |
var assert = require('assert'); | |
var http = require('http'); | |
var nock = require('nock'); | |
function async(cb) { | |
http.request({ hostname: 'localhost', path: '/' }, function(res) { | |
res.on('end', function() { | |
cb(); | |
}); | |
}).end(); | |
} | |
describe('async()', function() { | |
it('should call callback', function(done) { | |
var clock = sinon.useFakeTimers('setTimeout'); | |
var api = nock('http://localhost') | |
.get('/') | |
.reply(200); | |
var cb = sinon.spy(); | |
async(cb); | |
clock.tick(999999); | |
assert(cb.called); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment