Created
November 18, 2011 21:25
-
-
Save searls/1377803 to your computer and use it in GitHub Desktop.
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
mainWidget = | |
show: -> "Pretend this shows main widget" | |
login = -> | |
$.ajax | |
success: (response) -> | |
mainWidget.show() unless response == "fail" | |
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
beforeEach -> | |
jasmine.Spy.prototype.mostRecentConfig = -> | |
this.mostRecentCall.args[0] | |
describe "#login", -> | |
beforeEach -> | |
spyOn($,"ajax") | |
login("davemo", "password123") | |
describe "~ the success callback", -> | |
beforeEach -> spyOn(mainWidget,"show") | |
context "correct login info", -> | |
beforeEach -> | |
$.ajax.mostRecentConfig()['success']("win") | |
it "shows the main widget", -> | |
expect(mainWidget.show).toHaveBeenCalled() | |
context "incorrect login info", -> | |
beforeEach -> | |
$.ajax.mostRecentConfig()['success']("fail") | |
it "does not show main widget", -> | |
expect(mainWidget.show).not.toHaveBeenCalled() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment