Skip to content

Commit cbd62c7

Browse files
committed
test that highlights issue mroderick#106
where unsubscribing from the top level does not work if only child messages are subscribed
1 parent 2c3c878 commit cbd62c7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/test-unsubscribe.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,28 @@
122122
refute(spyC.called);
123123
},
124124

125+
'with parent topic argument, must clear all child subscriptions': function() {
126+
var topic = TestHelper.getUniqueString(),
127+
topicA = topic + '.a',
128+
topicB = topic + '.a.b',
129+
topicC = topic + '.a.b.c',
130+
spyB = sinon.spy(),
131+
spyC = sinon.spy();
132+
133+
// subscribe only to children:
134+
PubSub.subscribe(topicB, spyB);
135+
PubSub.subscribe(topicC, spyC);
136+
137+
// but unsubscribe from a parent:
138+
PubSub.unsubscribe(topicA);
139+
140+
PubSub.publishSync(topicB, TestHelper.getUniqueString());
141+
PubSub.publishSync(topicC, TestHelper.getUniqueString());
142+
143+
refute(spyB.called);
144+
refute(spyC.called);
145+
},
146+
125147
'must not throw exception when unsubscribing as part of publishing' : function(){
126148
refute.exception(function(){
127149
var topic = TestHelper.getUniqueString(),

0 commit comments

Comments
 (0)