Skip to content

Commit 4a95a6d

Browse files
author
Devendra
committed
running same mocha tests on browser and node
1 parent b26e612 commit 4a95a6d

File tree

9 files changed

+8122
-2409
lines changed

9 files changed

+8122
-2409
lines changed

node.js/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ build: $(PUBNUB_JS)
1212
$(PUBNUB_JS): $(PUBNUB_COMMON_JS) $(PUBNUB_NODE_JS)
1313
$(ECHO) "// Version: $(VERSION)" > $(PUBNUB_JS)
1414
cat $(PUBNUB_COMMON_JS) $(PUBNUB_PLATFORM_JS) >> $(PUBNUB_JS)
15+
cat tests/tests-include.js tests/test.js > tests/tests.js
1516
sed -i -e "s/VERSION/\'$(VERSION)\'/g" $(PUBNUB_JS)
1617
sed -i -e "s/PLATFORM/\'$(PLATFORM)\'/g" $(PUBNUB_JS)
1718

@@ -21,6 +22,6 @@ clean:
2122

2223
.PHONY: test
2324
test:
24-
mocha -R spec tests/test.js
25+
mocha -R spec tests/tests.js
2526

2627
include ../Makefile.post

node.js/tests/test.js

+38-36
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
var assert = require('assert');
2-
var PUBNUB = require('../pubnub.js');
3-
var _ = require("underscore");
4-
51
var pubnub = PUBNUB.init({
62
publish_key : 'ds',
73
subscribe_key : 'ds',
@@ -2245,17 +2241,19 @@ describe('Pubnub', function() {
22452241
assert.deepEqual(channels.split(','), r.channels);
22462242
pubnub.channel_group_remove_channel({
22472243
callback : function(r) {
2248-
pubnub.channel_group_list_channels({
2249-
channel_group : channel_group,
2250-
callback : function(r) {
2251-
assert.deepEqual([], r.channels);
2252-
done();
2253-
},
2254-
error : function(r) {
2255-
assert.ok(false, "Error occurred in getting group " + JSON.stringify(r));
2256-
done();
2257-
}
2258-
});
2244+
setTimeout(function(){
2245+
pubnub.channel_group_list_channels({
2246+
channel_group : channel_group,
2247+
callback : function(r) {
2248+
assert.deepEqual([], r.channels);
2249+
done();
2250+
},
2251+
error : function(r) {
2252+
assert.ok(false, "Error occurred in getting group " + JSON.stringify(r));
2253+
done();
2254+
}
2255+
});
2256+
}, 5000);
22592257
},
22602258
error : function(r) {
22612259
assert.ok(false, "Error occurred in adding channel to group " + JSON.stringify(r));
@@ -2296,17 +2294,19 @@ describe('Pubnub', function() {
22962294
assert.deepEqual(channels.split(','), r.channels);
22972295
pubnub.channel_group_remove_channel({
22982296
callback : function(r) {
2299-
pubnub.channel_group_list_channels({
2300-
channel_group : channel_group,
2301-
callback : function(r) {
2302-
assert.deepEqual([], r.channels);
2303-
done();
2304-
},
2305-
error : function(r) {
2306-
assert.ok(false, "Error occurred in getting group " + JSON.stringify(r));
2307-
done();
2308-
}
2309-
});
2297+
setTimeout(function(){
2298+
pubnub.channel_group_list_channels({
2299+
channel_group : channel_group,
2300+
callback : function(r) {
2301+
assert.deepEqual([], r.channels);
2302+
done();
2303+
},
2304+
error : function(r) {
2305+
assert.ok(false, "Error occurred in getting group " + JSON.stringify(r));
2306+
done();
2307+
}
2308+
});
2309+
}, 5000);
23102310
},
23112311
error : function(r) {
23122312
assert.ok(false, "Error occurred in adding channel to group " + JSON.stringify(r));
@@ -2449,16 +2449,18 @@ describe('Pubnub', function() {
24492449
pubnub.channel_group_remove_namespace({
24502450
namespace : namespace,
24512451
callback : function(r) {
2452-
pubnub.channel_group_list_namespaces({
2453-
callback : function(r) {
2454-
assert.ok(!in_list_deep(r.namespaces, namespace), "namespace not deleted");
2455-
done();
2456-
},
2457-
error : function(r) {
2458-
assert.ok(false, "Error occurred in getting all registry " + JSON.stringify(r));
2459-
done();
2460-
}
2461-
});
2452+
setTimeout(function(){
2453+
pubnub.channel_group_list_namespaces({
2454+
callback : function(r) {
2455+
assert.ok(!in_list_deep(r.namespaces, namespace), "namespace not deleted");
2456+
done();
2457+
},
2458+
error : function(r) {
2459+
assert.ok(false, "Error occurred in getting all registry " + JSON.stringify(r));
2460+
done();
2461+
}
2462+
});
2463+
}, 5000);
24622464
},
24632465
error : function(r) {
24642466
assert.ok(false, "Error occurred in getting all registry " + JSON.stringify(r));

node.js/tests/tests-include.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
var assert = require('assert');
3+
var PUBNUB = require('../pubnub.js');
4+
var _ = require("underscore");

0 commit comments

Comments
 (0)