Permalink
Browse files

fixed pubsub all + tests #42

Signed-off-by: Valentin Zberea <valentin.zberea@gmail.com>
  • Loading branch information...
1 parent 1aa133e commit 96082ff4ce1a13d404a0bbe69e99398b87c3c946 @valentinzberea valentinzberea committed Mar 5, 2013
Showing with 30 additions and 2 deletions.
  1. +1 −2 core/pubsub.coffee
  2. +29 −0 tests/core/pubsub_tests.coffee
View
@@ -16,7 +16,6 @@ define [], () ->
constructor: ->
@_callbacks = {}
- @_callbacks['all'] = {}
initialize: ->
logger.info "Initializing PubSub"
@@ -98,4 +97,4 @@ define [], () ->
new_list.push(node)
calls[event] = new_list
- return PubSub
+ return PubSub
@@ -0,0 +1,29 @@
+define ['cs!tests/base_test', 'cs!pubsub'], (BaseTest, PubSub) ->
+
+ class PubSubTests extends BaseTest
+ testName: '[Core] PubSub'
+
+ test_async_pubsub_subscribers: ->
+ ###
+ Tests for pubsub functionality
+ ###
+ expect(8)
+
+ pubsub = new PubSub()
+
+ pubsub.subscribe('all', () ->
+ equal(arguments.length, 2)
+ )
+ pubsub.publish('delete blur', {id: 1}, {silent: true})
+
+ pubsub.subscribe('/change', (type, data) ->
+ equal(type, 'reset')
+ deepEqual(data, {change: 'value'})
+ )
+ pubsub.subscribe('/delete', (data, options) ->
+ deepEqual(data, {id: 1})
+ deepEqual(options, {silent: true})
+ start()
+ )
+ pubsub.publish('/change', 'reset', {change: 'value'})
+ pubsub.publish('/delete', {id: 1}, {silent: true})

0 comments on commit 96082ff

Please sign in to comment.