forked from pubnub/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
69 lines (58 loc) · 1.54 KB
/
Copy pathtest.js
File metadata and controls
69 lines (58 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var test = require('testling');
var PUBNUB = require('./pubnub.min');
var channel = 'unit-test-pubnub-channel';
test('PUBNUB JavaScript API', function (test) {
var pubnub = PUBNUB({
publish_key : 'demo',
subscribe_key : 'demo'
});
test.plan(14);
test.ok(PUBNUB);
test.ok(pubnub);
test.ok(pubnub.publish);
test.ok(pubnub.subscribe);
test.ok(pubnub.history);
test.ok(pubnub.time);
function publish_test() {
pubnub.publish({
channel : channel,
message : { test : "test" },
callback : function(response) {
test.ok(response[0]);
test.equal( response[1], 'Demo' );
}
});
}
function time_test() {
pubnub.time(function(time){
test.ok(time);
uuid_test();
});
}
function uuid_test() {
pubnub.uuid(function(uuid){
test.ok(uuid);
history_test();
});
}
function history_test(history) {
pubnub.history({
limit : 1,
channel : channel,
callback : function(messages) {
test.ok(messages);
test.equal( messages[0].test, "test" );
test.end();
}
});
}
pubnub.subscribe({
channel : channel,
connect : publish_test,
callback : function(message) {
test.ok(message);
test.equal( message.test, "test" );
time_test();
}
});
});