Skip to content

Commit 323d6a2

Browse files
committed
Merge pull request #796 from NodeRedis/753-example
added test for psubscribe
2 parents e2e507e + d1558ed commit 323d6a2

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)