-
-
Save wycats/2138c7bf20da83e823e8 to your computer and use it in GitHub Desktop.
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
test("something", function() { | |
expect(1); | |
stop(); | |
setTimeout(function() { | |
start(); | |
ok(true); | |
}, 1000); | |
}); | |
// must() returns a function that MUST be called (simple impl: stop() and | |
// wrap the function with a start()) | |
test("something", function() { | |
setTimeout(must(function() { | |
ok(true); | |
}), 1000) | |
Ember.something(mustNot); | |
}) | |
// the basic idea is that often you use expect() simply to assert that some | |
// function is actually called (or not called). | |
must = function(callback) { | |
stop(); | |
return function() { | |
start(); | |
callback.apply(this, arguments); | |
} | |
}; | |
mustNot = function() { | |
return function() { | |
ok(false, "WAT"); | |
} | |
}; | |
// this is for cases where you basically need a function that throws... | |
// perhaps there could be some async version with a timeout? | |
mustNot = function(timeout) { | |
// incorrect implementation | |
stop(); | |
var f = function() { | |
ok(false, "WAT"); | |
}; | |
var timer = setTimeout(f, timeout); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment