burnchart/test/ractive.coffee

31 lines
741 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
do view.render()
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