Created
July 19, 2012 17:19
-
-
Save kalebdf/3145434 to your computer and use it in GitHub Desktop.
Check deferred helper (promises) for Jasmine calls
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
### | |
Stellar Module Test - Assumes jasmine is global | |
@author: Kaleb Fulgham | |
@license: MIT | |
### | |
define [ | |
'../specs/helpers/TestHelpers' | |
'modules/StellarModule' | |
], | |
(TestHelpers, StellarModule) -> | |
describe "StellarModule", -> | |
describe "ItemView", -> | |
it "should do foo bar baz with view", -> | |
itemView = new ItemView() | |
promise = itemView.render() | |
TestHelpers.checkDeferred promise, -> | |
expect(itemView.$el).toBeDefined(); | |
# more expectations |
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
### | |
TestHelpers | |
@author: Kaleb Fulgham | |
@license: MIT | |
### | |
define [], -> | |
TestHelpers = | |
checkDeferred: (df, callback) -> | |
### | |
Wait for the deferred object to finish and execute the callback once done. | |
### | |
spy = jasmine.createSpy() | |
df.then(spy) | |
waitsFor -> | |
spy.callCount > 0 | |
, "Async call never occurred", 1000 | |
runs -> | |
callback.apply @, spy.mostRecentCall.args if callback | |
TestHelpers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment