2014-11-08 11:11:18 -07:00
|
|
|
{ assert } = require 'chai'
|
2014-10-29 21:56:53 -06: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'
|
2014-11-08 11:11:18 -07:00
|
|
|
assert ctx.called, 1
|
2014-10-29 21:56:53 -06:00
|
|
|
do view.teardown
|
|
|
|
view.publish '!event'
|
2014-11-08 11:11:18 -07:00
|
|
|
assert ctx.called, 1
|
2014-10-29 21:56:53 -06:00
|
|
|
|
|
|
|
do done
|