Created
May 7, 2013 00:06
-
-
Save amirci/5529301 to your computer and use it in GitHub Desktop.
Spec using mock to call response method
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
describe "ChildrenCheckinViewModel", -> | |
beforeEach -> | |
spyOn(jQuery, 'getJSON') | |
@actualChildren = ko.observableArray() | |
@subject = new Childcarepro.ChildrenCheckinViewModel @actualChildren | |
@response = [ | |
{FIRSTNAME:'John',LASTNAME:'Locke',BIRTHDATE:12312312312}, | |
{FIRSTNAME:'Matt',LASTNAME:'Zandstra',BIRTHDATE:12312312312} | |
] | |
@expectedChildren = [ | |
new Childcarepro.Child(@response[0]) | |
new Childcarepro.Child(@response[1]) | |
] | |
describe "Ajax loading of children", -> | |
beforeEach -> @request = jQuery.getJSON.mostRecentCall | |
it "calls the children api", -> expect(@request.args[0]).toBe '/children.json' | |
it "loads all the children", -> | |
@request.args[2] {children: @response}, 200 | |
expect(@subject.children().length).toBe 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment