Skip to content

Commit d1558ed

Browse files
author
Benjamin Coe
committed
add test demonstrating psubscribe, and pmessage
1 parent e2e507e commit d1558ed

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/pubsub.spec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,20 @@ describe("publish/subscribe", function () {
208208
});
209209
});
210210

211+
describe('psubscribe', function () {
212+
// test motivated by issue #753
213+
it('allows all channels to be subscribed to using a * pattern', function (done) {
214+
sub.psubscribe('*');
215+
sub.on("pmessage", function(pattern, channel, message) {
216+
assert.strictEqual(pattern, '*');
217+
assert.strictEqual(channel, '/foo');
218+
assert.strictEqual(message, 'hello world');
219+
return done();
220+
})
221+
pub.publish('/foo', 'hello world');
222+
});
223+
});
224+
211225
describe('punsubscribe', function () {
212226
it('does not complain when punsubscribe is called and there are no subscriptions', function () {
213227
sub.punsubscribe()

0 commit comments

Comments
 (0)