Skip to content

Instantly share code, notes, and snippets.

@kumar303
Last active August 29, 2015 13:57
Show Gist options
  • Save kumar303/9652425 to your computer and use it in GitHub Desktop.
Save kumar303/9652425 to your computer and use it in GitHub Desktop.
sinon example
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