Created
November 29, 2012 08:54
-
-
Save fgalassi/4167685 to your computer and use it in GitHub Desktop.
test.coffee
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 "wait after pressButton", -> | |
before (done)-> | |
brains.get "/two-timers-only-the-first-useful", (req,res)-> | |
res.send """ | |
<html> | |
<body> | |
<button id="pressMe">press me</button> | |
<script> | |
var button = document.getElementById("pressMe") | |
button.addEventListener("click", function(ev) { | |
ev.preventDefault() | |
setTimeout(function() { | |
window.useful = true | |
}, 1000) | |
setTimeout(function() { | |
console.log("useless!") | |
}, 3000) | |
}, false) | |
</script> | |
</body> | |
</html> | |
""" | |
brains.ready done | |
it "shoudnt wait 3 seconds", (done)-> | |
@browser = new Browser() | |
@browser.visit("/two-timers-only-the-first-useful") | |
.then => | |
@browser.startTime = new Date() | |
@browser.pressButton("#pressMe") | |
.then => | |
@browser.wait function: -> @browser.window.useful is true | |
.then => | |
timeElapsed = new Date() - @browser.startTime | |
assert(timeElapsed < 3000, "time elapsed is bigger than 3 seconds") | |
.then(done, done) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment