Created
December 11, 2012 01:30
-
-
Save tatsuro-ueda/4254988 to your computer and use it in GitHub Desktop.
Jasmine Async Test on CoffeeScript
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
# 「JS開発におけるTDDと自動テストツール利用の勘所 」より引用。 | |
# http://www.slideshare.net/KojiNakamura/jstdd | |
it "should be async", -> | |
# 非同期処理ブロックはruns()で定義される | |
runs -> | |
expect(true).toBeTruthy() | |
# waits()で次のブロック実行を、指定したミリ秒間保留する | |
waits(500) | |
spy = jasmine.createSpy() | |
runs -> | |
setTimeout spy, 1000 | |
# waitsFor()はコールバックがtrueを返すまで、次のブロック実行を保留する | |
waitsFor -> | |
spy.callCount > 0 | |
runs -> | |
expect(true).toBeTruthy() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment