Created
October 9, 2012 10:44
-
-
Save byrichardpowell/3857905 to your computer and use it in GitHub Desktop.
Model Fetch Unit Test
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("A Model should", function() { | |
// FETCH | |
describe( "have a fetch method that", function() { | |
beforeEach(function() { | |
urls = ['url1', 'url2', 'url3', 'url4', 'url5'] | |
spyOn( $, 'ajax'); | |
}); | |
it( "makes an AJAX request for each URL it is passed", function() { | |
model.fetch( urls ); | |
expect( $.ajax ).toHaveBeenCalled(); | |
expect( $.ajax.callCount ).toEqual( urls.length ) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It looks good. Here’s my take:
Comments
Opinion:
Fact:
callCount
makes the expectation that$.ajax
was called redundantInterested to hear others’ thoughts.