Skip to content

Commit

Permalink
adding tests for unplug signals.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Feb 12, 2012
1 parent 7f69a81 commit ea0f1b3
Showing 1 changed file with 47 additions and 6 deletions.
53 changes: 47 additions & 6 deletions tests/test-all.js
Expand Up @@ -88,7 +88,7 @@ exports['test unplug unplugs dependents'] = function(assert) {

exports['test for hooks'] = function(assert) {
var a = {
name: 'Ga6',
name: 'a6',
onplug: function(event) {
a.plugs.push(event)
},
Expand Down Expand Up @@ -123,15 +123,15 @@ exports['test for hooks'] = function(assert) {
type: 'plug',
plugin: a,
plugins: [ a ]
}], 'event was signaled')
}], 'event was signaled on a')

hub.plug(b)

assert.deepEqual(b.plugs, [{
type: 'plug',
plugin: b,
plugins: [ a, b ]
}], 'second event was signaled')
}], 'second event was signaled on b')


assert.deepEqual(a.plugs, [{
Expand All @@ -142,7 +142,7 @@ exports['test for hooks'] = function(assert) {
type: 'plug',
plugin: b,
plugins: [ a, b ]
}], 'second event was signaled')
}], 'second event was signaled on a')

hub.plug(c)

Expand All @@ -160,7 +160,7 @@ exports['test for hooks'] = function(assert) {
type: 'plug',
plugin: c,
plugins: [ a, b, c ]
}], 'third event was signaled')
}], 'third event was signaled on a')

assert.deepEqual(b.plugs, [{
type: 'plug',
Expand All @@ -171,11 +171,52 @@ exports['test for hooks'] = function(assert) {
type: 'plug',
plugin: c,
plugins: [ a, b, c ]
}], 'third event was signaled')
}], 'third event was signaled on b')

hub.uninstall('a6@0.0.0')

assert.deepEqual(a.unplugs, [{
type: 'unplug',
plugin: a
}], 'first unplug event was signaled on a')

assert.deepEqual(b.unplugs, [{
type: 'unplug',
plugin: a
}], 'first unplug event was signaled on b')

hub.unplug('b6@0.0.0')

assert.deepEqual(a.unplugs, [{
type: 'unplug',
plugin: a
}], 'unplugged plugin does not gets signal')

assert.deepEqual(b.unplugs, [{
type: 'unplug',
plugin: a
},
{
type: 'unplug',
plugin: b
}], 'second unplug event was signaled')

hub.uninstall('b6@0.0.0')
hub.uninstall('c6@0.0.0')

assert.deepEqual(a.unplugs, [{
type: 'unplug',
plugin: a
}], 'unplugged plugin is not signaled')

assert.deepEqual(b.unplugs, [{
type: 'unplug',
plugin: a
},
{
type: 'unplug',
plugin: b
}], 'second unplugged plugin is not signaled')
}

if (module == require.main)
Expand Down

0 comments on commit ea0f1b3

Please sign in to comment.