burnchart/-old-/test/ractive.coffee

31 lines
739 B
CoffeeScript
Raw Normal View History

{ assert } = require 'chai'
2014-10-30 03:56:53 +00:00
RactiveEventful = require '../src/utils/ractive/eventful.coffee'
module.exports = ->
# This represents a way for mediator subscriptions to get cancelled.
'mediator subscriptions get cancelled': (done) ->
# Need to be able to deal with custom context.
ctx = 'called': 0
view = new RactiveEventful
onconstruct: ->
# Track how many times we get called.
@subscribe '!event', ->
@called += 1
, ctx
onteardown: ->
# Need to deal with multiple teardown handlers
do this._super
2014-12-24 19:43:47 +00:00
do view.render
2014-10-30 03:56:53 +00:00
view.publish '!event'
assert ctx.called, 1
2014-10-30 03:56:53 +00:00
do view.teardown
view.publish '!event'
assert ctx.called, 1
2014-10-30 03:56:53 +00:00
do done