Last active
August 29, 2015 13:57
-
-
Save kumar303/9652425 to your computer and use it in GitHub Desktop.
sinon example
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
describe('fxpay', function () { | |
describe('API', function() { | |
var api; | |
var server; | |
beforeEach(function() { | |
api = new fxpay.API(); | |
server = sinon.fakeServer.create(); | |
}); | |
afterEach(function() { | |
server.restore(); | |
}); | |
it('should report 500 responses', function(done) { | |
server.respondWith( | |
'GET', '/error', | |
[500, {"Content-Type": "application/json"}, | |
JSON.stringify({result: 'error'})]); | |
api.get('/error', function(error) { | |
assert.equal(error, 'BAD_API_RESPONSE'); | |
done(); | |
}); | |
// Respond to the asynchronous request now: | |
server.respond(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment