, , , - . , , , .
/mocha/client/lib.coffee, 100% Jasmine, . Coffeescript, coffeescript.org Javascript, .
, ( - , , ), Template to (re), Template.<your_template>.rendered, , . , lib.coffee:
@afterRendered = (template,f)->
cb = template.rendered
template.rendered = ->
cb?()
template.rendered = cb
f?()
return
return
? "" rendered , Template . , - , rendered, Meteor.
- :
it.only "should check stuff after routing", (done)->
try
Router.go "<somewhere>"
afterRendered Template.<expected_template>, ->
<your tests here>
done()
catch e
done(e)
try-catch, , , -.
, , , JS - "/". - -, " " , .
$.fn.visible = -> this.length > 0 and this.css('display') isnt 'none'
$.fn.onVisible = (fn,it)->
sel = this.selector
if this.visible()
console.log "Found immediately"
fn?(this)
else
counter = 0
timer = setInterval ->
counter++
el = $(sel)
if el.visible()
fn?(el)
clearInterval timer
console.log "Found on iteration #{counter}"
else
it?(el)
, 50
iterator it, , . - :
$('#modalId').onVisible (el)->
<tests here>
done()
, (el)->
console.log "Waiting for #{el.selector}"
, , it. , "display: hidden" (Bootstrap ). , / .
!