diff --git a/README.md b/README.md index ee97988a2..ac06a3d3a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ + +[![browser support](http://ci.testling.com/devendram/javascript.png)](http://ci.testling.com/devendram/javascript) + # YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API. Create an account at http://www.pubnub.com/account diff --git a/empty.js b/empty.js new file mode 100644 index 000000000..e69de29bb diff --git a/package.json b/package.json new file mode 100644 index 000000000..d4aa1c771 --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "pubnub-javascript", + "version": "0.0.0", + "devDependencies": { + "mocha": "~1.7.4", + "assert": "~0.4.9" + }, + "testling": { + "browsers": ["iexplore/6.0","iexplore/7.0","iexplore/8.0","iexplore/10.0","iexplore/9.0","chrome/6.0", + "chrome/7.0","chrome/8.0","chrome/9.0","chrome/10.0","chrome/11.0", + "chrome/12.0","chrome/13.0","chrome/14.0","chrome/15.0","chrome/16.0","chrome/17.0","chrome/18.0", + "chrome/19.0","chrome/20.0","chrome/21.0","chrome/22.0","chrome/23.0","chrome/24.0","chrome/25.0", + "firefox/3.5","firefox/3.6","firefox/4.0","firefox/5.0","firefox/6.0","firefox/7.0", + "firefox/8.0","firefox/9.0","firefox/10.0","firefox/11.0","firefox/12.0","firefox/13.0","firefox/14.0", + "firefox/15.0","firefox/16.0","firefox/17.0","firefox/18.0","firefox/19.0","opera/10.0","opera/10.5", + "opera/11.0","opera/11.5","opera/11.6","opera/12.0","safari/5.0.5","safari/5.1","iphone/6.0","ipad/6.0","safari/6.0"], + "harness" : "mocha", + "scripts" : "web/pubnub-3.4.2.js", + "files": "web/tests/test.js" + }, + "license": "MIT" +} diff --git a/web/tests/test.js b/web/tests/test.js new file mode 100644 index 000000000..6d39e824a --- /dev/null +++ b/web/tests/test.js @@ -0,0 +1,76 @@ + var empty = require('../../../empty'); + var assert = require('assert'); + + + var pubnub = PUBNUB.init({ + publish_key : 'demo', + subscribe_key : 'demo' + }); + + var pubnub_enc = PUBNUB.init({ + publish_key : 'demo', + subscribe_key : 'demo', + secret_key : 'demo', + cipher_key : 'demo' + }); + + var channel = 'javascript-test-channel'; + var channel_enc = 'javascript-encrypted-test-channel'; + + var message_string = 'Hi from Javascript'; + var message_jsono = {'message': 'Hi Hi from Javascript'}; + var message_jsona = ['message' , 'Hi Hi from javascript']; + + describe('Pubnub', function() { + this.timeout(10000); + describe('#publish()', function(){ + it('should publish strings without error', function(done){ + pubnub.publish({channel: channel , message : message_string, + callback : function(response) { + assert.equal(response[0],1); + done(); + } + }) + }) + it('should publish json objects without error', function(done){ + pubnub.publish({channel: channel , message : message_jsono, + callback : function(response) { + assert.equal(response[0],1); + done(); + } + }) + }) + it('should publish json arrays without error', function(done){ + pubnub.publish({channel: channel , message : message_jsona, + callback : function(response) { + assert.equal(response[0],1); + done(); + } + }) + }) + it('should publish strings with encryption enabled without error', function(done){ + pubnub_enc.publish({channel: channel_enc , message : message_string, + callback : function(response) { + assert.equal(response[0],1); + done(); + } + }) + }) + it('should publish json objects with encryption enabled without error', function(done){ + pubnub_enc.publish({channel: channel_enc , message : message_jsono, + callback : function(response) { + assert.equal(response[0],1); + done(); + } + }) + }) + it('should publish json arrays with encryption enabled without error', function(done){ + pubnub_enc.publish({channel: channel_enc , message : message_jsona, + callback : function(response) { + assert.equal(response[0],1); + done(); + } + }) + }) + }) + })