Created
April 15, 2013 20:48
-
-
Save runemadsen/5391170 to your computer and use it in GitHub Desktop.
Using sinon.js to fake calls to multiple URLs in a test
This file contains 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 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