Skip to content

Instantly share code, notes, and snippets.

@runemadsen
Created April 15, 2013 20:48
Show Gist options
  • Save runemadsen/5391170 to your computer and use it in GitHub Desktop.
Save runemadsen/5391170 to your computer and use it in GitHub Desktop.
Using sinon.js to fake calls to multiple URLs in a test
var server = sinon.fakeServer.create();
var result1;
var result2;
server.respondWith("url/one", '{ "id": 1 }');
server.respondWith("url/two", '{ "id": 2 }');
$.getJSON('url/one', function(data) {
result1 = data;
});
$.getJSON('url/two', function(data) {
result2 = data;
});
server.respond();
expect(result1.id).toEqual(1);
expect(result2.id).toEqual(2);
server.restore();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment