Skip to content

Commit ef1c7e2

Browse files
committed
fix node.js subscribe test
1 parent fe96ceb commit ef1c7e2

File tree

1 file changed

+31
-15
lines changed

1 file changed

+31
-15
lines changed

node.js/tests/test.js

+31-15
Original file line numberDiff line numberDiff line change
@@ -133,28 +133,39 @@ describe('Pubnub', function () {
133133
pubnub_enc.unsubscribe({channel: ch});
134134
done();
135135
}
136-
137136
})
138137
});
139138

140139
it('should take an error callback which will be invoked if channel permission not there', function (done) {
141140
var channel = 'channel' + Date.now();
142141
var auth_key = 'abcd';
143-
pubnub_pam.subscribe({
144-
'auth_key': auth_key,
145-
'channel': channel,
146-
'error': function (r) {
147-
assert.deepEqual(r['message'], 'Forbidden');
148-
assert.ok(r['payload'], "Payload should be there in error response");
149-
assert.ok(r['payload']['channels'], "Channels should be there in error payload");
150-
assert.ok(in_list_deep(r['payload']['channels'], channel), "Channel should be there in channel list");
151-
pubnub_pam.unsubscribe({'channel': channel});
152-
done();
153-
},
154-
'callback': function () {
155-
done(new Error("Callback should not get invoked if permission not there"));
142+
143+
this.timeout(3000);
144+
145+
pubnub_pam.revoke({
146+
auth_key: auth_key,
147+
channel: channel,
148+
callback: function () {
149+
pubnub_pam.subscribe({
150+
auth_key: auth_key,
151+
channel: channel,
152+
error: function (r) {
153+
assert.deepEqual(r['message'], 'Forbidden');
154+
assert.ok(r['payload'], "Payload should be there in error response");
155+
assert.ok(r['payload']['channels'], "Channels should be there in error payload");
156+
assert.ok(in_list_deep(r['payload']['channels'], channel), "Channel should be there in channel list");
157+
pubnub_pam.unsubscribe({'channel': channel});
158+
done();
159+
},
160+
callback: function () {
161+
done(new Error("Callback should not get invoked if permission not there"));
162+
},
163+
connect: function () {
164+
done(new Error("Connect should not get invoked if permission not there"));
165+
}
166+
})
156167
}
157-
})
168+
});
158169
});
159170

160171
it("should not generate spurious presence events when adding new channels to subscribe in_list", function (done) {
@@ -839,6 +850,8 @@ describe('Pubnub', function () {
839850
build_u: true
840851
});
841852

853+
this.timeout(15000);
854+
842855
for (var i = 0; i < get_random(10); i++) {
843856
pubnub._add_param('a-' + get_random(1000), Date.now());
844857
}
@@ -1239,6 +1252,9 @@ describe('Pubnub', function () {
12391252
done(new Error("Unable to get history for the sub_key with granted read permissions"))
12401253
}
12411254
});
1255+
},
1256+
error: function () {
1257+
done(new Error("Error in audit"))
12421258
}
12431259
});
12441260
}

0 commit comments

Comments
 (0)