aboutsummaryrefslogtreecommitdiffstats
path: root/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test
diff options
context:
space:
mode:
Diffstat (limited to 'signaling-server/node_modules/socket.io/node_modules/socket.io-client/test')
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/events.test.js120
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/io.test.js31
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/node/builder.common.js102
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/node/builder.test.js131
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/parser.test.js360
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/socket.test.js422
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/util.test.js156
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/worker.js20
8 files changed, 1342 insertions, 0 deletions
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/events.test.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/events.test.js
new file mode 100644
index 0000000..365c422
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/events.test.js
@@ -0,0 +1,120 @@
+
+/*!
+ * socket.io-node
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (module, io, should) {
+
+ module.exports = {
+
+ 'add listeners': function () {
+ var event = new io.EventEmitter
+ , calls = 0;
+
+ event.on('test', function (a, b) {
+ ++calls;
+ a.should().eql('a');
+ b.should().eql('b');
+ });
+
+ event.emit('test', 'a', 'b');
+ calls.should().eql(1);
+ event.on.should().eql(event.addListener);
+ },
+
+ 'remove listener': function () {
+ var event = new io.EventEmitter;
+ function empty () { }
+
+ event.on('test', empty);
+ event.on('test:more', empty);
+ event.removeAllListeners('test');
+
+ event.listeners('test').should().eql([]);
+ event.listeners('test:more').should().eql([empty]);
+ },
+
+ 'remove all listeners with no arguments': function () {
+ var event = new io.EventEmitter;
+ function empty () { }
+
+ event.on('test', empty);
+ event.on('test:more', empty);
+ event.removeAllListeners();
+
+ event.listeners('test').should().eql([]);
+ event.listeners('test:more').should().eql([]);
+ },
+
+ 'remove listeners functions': function () {
+ var event = new io.EventEmitter
+ , calls = 0;
+
+ function one () { ++calls }
+ function two () { ++calls }
+ function three () { ++calls }
+
+ event.on('one', one);
+ event.removeListener('one', one);
+ event.listeners('one').should().eql([]);
+
+ event.on('two', two);
+ event.removeListener('two', one);
+ event.listeners('two').should().eql([two]);
+
+ event.on('three', three);
+ event.on('three', two);
+ event.removeListener('three', three);
+ event.listeners('three').should().eql([two]);
+ },
+
+ 'number of arguments': function () {
+ var event = new io.EventEmitter
+ , number = [];
+
+ event.on('test', function () {
+ number.push(arguments.length);
+ });
+
+ event.emit('test');
+ event.emit('test', null);
+ event.emit('test', null, null);
+ event.emit('test', null, null, null);
+ event.emit('test', null, null, null, null);
+ event.emit('test', null, null, null, null, null);
+
+ [0, 1, 2, 3, 4, 5].should().eql(number);
+ },
+
+ 'once': function () {
+ var event = new io.EventEmitter
+ , calls = 0;
+
+ event.once('test', function (a, b) {
+ ++calls;
+ });
+
+ event.emit('test', 'a', 'b');
+ event.emit('test', 'a', 'b');
+ event.emit('test', 'a', 'b');
+
+ function removed () {
+ should().fail('not removed');
+ };
+
+ event.once('test:removed', removed);
+ event.removeListener('test:removed', removed);
+ event.emit('test:removed');
+
+ calls.should().eql(1);
+ }
+
+ };
+
+})(
+ 'undefined' == typeof module ? module = {} : module
+ , 'undefined' == typeof io ? require('socket.io-client') : io
+ , 'undefined' == typeof should || !should.fail ? require('should') : should
+);
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/io.test.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/io.test.js
new file mode 100644
index 0000000..d9f0b09
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/io.test.js
@@ -0,0 +1,31 @@
+
+/*!
+ * socket.io-node
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (module, io, should) {
+
+ module.exports = {
+
+ 'client version number': function () {
+ io.version.should().match(/([0-9]+)\.([0-9]+)\.([0-9]+)/);
+ },
+
+ 'socket.io protocol version': function () {
+ io.protocol.should().be.a('number');
+ io.protocol.toString().should().match(/^\d+$/);
+ },
+
+ 'socket.io available transports': function () {
+ (io.transports.length > 0).should().be_true;
+ }
+
+ };
+
+})(
+ 'undefined' == typeof module ? module = {} : module
+ , 'undefined' == typeof io ? require('socket.io-client') : io
+ , 'undefined' == typeof should ? require('should') : should
+);
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/node/builder.common.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/node/builder.common.js
new file mode 100644
index 0000000..fa8d46e
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/node/builder.common.js
@@ -0,0 +1,102 @@
+
+/*!
+ * socket.io-node
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+var vm = require('vm')
+ , should = require('should');
+
+/**
+ * Generates evn variables for the vm so we can `emulate` a browser.
+ * @returns {Object} evn variables
+ */
+
+exports.env = function env () {
+ var details = {
+ location: {
+ port: 8080
+ , host: 'www.example.org'
+ , hostname: 'www.example.org'
+ , href: 'http://www.example.org/example/'
+ , pathname: '/example/'
+ , protocol: 'http:'
+ , search: ''
+ , hash: ''
+ }
+ , console: {
+ log: function(){},
+ info: function(){},
+ warn: function(){},
+ error: function(){}
+ }
+ , navigator: {
+ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit'
+ + '/534.27 (KHTML, like Gecko) Chrome/12.0.716.0 Safari/534.27'
+ , appName: 'socket.io'
+ , platform: process.platform
+ , appVersion: process.version
+ , }
+ , name: 'socket.io'
+ , innerWidth: 1024
+ , innerHeight: 768
+ , length: 1
+ , outerWidth: 1024
+ , outerHeight: 768
+ , pageXOffset: 0
+ , pageYOffset: 0
+ , screenX: 0
+ , screenY: 0
+ , screenLeft: 0
+ , screenTop: 0
+ , scrollX: 0
+ , scrollY: 0
+ , scrollTop: 0
+ , scrollLeft: 0
+ , screen: {
+ width: 0
+ , height: 0
+ }
+ };
+
+ // circular references
+ details.window = details.self = details.contentWindow = details;
+
+ // callable methods
+ details.Image = details.scrollTo = details.scrollBy = details.scroll =
+ details.resizeTo = details.resizeBy = details.prompt = details.print =
+ details.open = details.moveTo = details.moveBy = details.focus =
+ details.createPopup = details.confirm = details.close = details.blur =
+ details.alert = details.clearTimeout = details.clearInterval =
+ details.setInterval = details.setTimeout = details.XMLHttpRequest =
+ details.getComputedStyle = details.trigger = details.dispatchEvent =
+ details.removeEventListener = details.addEventListener = function(){};
+
+ // frames
+ details.frames = [details];
+
+ // document
+ details.document = details;
+ details.document.domain = details.location.href;
+
+ return details;
+};
+
+/**
+ * Executes a script in a browser like env and returns
+ * the result
+ *
+ * @param {String} contents The script content
+ * @returns {Object} The evaluated script.
+ */
+
+exports.execute = function execute (contents) {
+ var env = exports.env()
+ , script = vm.createScript(contents);
+
+ // run the script with `browser like` globals
+ script.runInNewContext(env);
+
+ return env;
+};
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/node/builder.test.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/node/builder.test.js
new file mode 100644
index 0000000..989e2bc
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/node/builder.test.js
@@ -0,0 +1,131 @@
+/*!
+ * socket.io-node
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+/**
+ * Test dependencies.
+ */
+
+var builder = require('../../bin/builder')
+ , common = require('./builder.common')
+ , should = require('should');
+
+/**
+ * Tests.
+ */
+
+module.exports = {
+
+ 'version number': function () {
+ builder.version.should().match(/([0-9]+)\.([0-9]+)\.([0-9]+)/);
+ builder.version.should().equal(require('../../lib/io').version);
+ },
+
+ 'production build LOC': function () {
+ builder(function (err, result) {
+ should.strictEqual(err, null)
+
+ var lines = result.split('\n');
+ lines.length.should().be.below(5);
+ lines[0].should().match(/production/gi);
+ Buffer.byteLength(result).should().be.below(43000);
+ });
+ },
+
+ 'development build LOC': function () {
+ builder({ minify: false }, function (err, result) {
+ should.strictEqual(err, null)
+
+ var lines = result.split('\n');
+ lines.length.should().be.above(5);
+ lines[0].should().match(/development/gi);
+ Buffer.byteLength(result).should().be.above(35000);
+ });
+ },
+
+ 'default builds': function () {
+ builder(function (err, result) {
+ should.strictEqual(err, null);
+
+ var io = common.execute(result).io
+ , transports = Object.keys(io.Transport)
+ , defaults = Object.keys(builder.transports);
+
+ /* XHR transport is private, but still available */
+ transports.length.should().be.equal(defaults.length + 1);
+
+ defaults.forEach(function (transport) {
+ transports.indexOf(transport).should().be.above(-1);
+ })
+ });
+ },
+
+ 'custom build': function () {
+ builder(['websocket'], function (err, result) {
+ should.strictEqual(err, null);
+
+ var io = common.execute(result).io
+ , transports = Object.keys(io.Transport);
+
+ transports.should().have.length(1);
+ transports[0].should().eql('websocket');
+ });
+ },
+
+ 'custom code': function () {
+ var custom = 'var hello = "world";';
+ builder({ custom: [custom], minify: false }, function (err, result) {
+ should.strictEqual(err, null);
+
+ result.should().include.string(custom);
+ });
+ },
+
+ 'node if': function () {
+ var custom = '// if node \nvar hello = "world";\n'
+ + '// end node\nvar pew = "pew";';
+
+ builder({ custom: [custom], minify: false }, function (err, result) {
+ should.strictEqual(err, null);
+
+ result.should().not.include.string(custom);
+ result.should().not.include.string('// if node');
+ result.should().not.include.string('// end node');
+ result.should().not.include.string('"world"');
+
+ result.should().include.string('var pew = "pew"');
+ });
+ },
+
+ 'preserve the encoding during minification': function () {
+ builder(function (err, result) {
+ should.strictEqual(err, null);
+
+ result.should().match(/(\\ufffd)/g);
+ })
+ },
+
+ 'globals': function () {
+ builder(function (err, result) {
+ should.strictEqual(err, null);
+
+ var io = common.execute(result)
+ , env = common.env()
+ , allowed = ['io', 'swfobject', 'WEB_SOCKET_DISABLE_AUTO_INITIALIZATION'];
+
+ Array.prototype.push.apply(allowed, Object.keys(env));
+
+ Object.keys(io).forEach(function (global) {
+ var index = allowed.indexOf(global);
+
+ // the global is not allowed!
+ if (!~index) {
+ throw new Error('Global leak: ' + global);
+ }
+ });
+ })
+ }
+
+};
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/parser.test.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/parser.test.js
new file mode 100644
index 0000000..0022afb
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/parser.test.js
@@ -0,0 +1,360 @@
+
+/*!
+ * socket.io-node
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (module, io, should) {
+
+ var parser = io.parser;
+
+ module.exports = {
+
+ 'decoding error packet': function () {
+ parser.decodePacket('7:::').should().eql({
+ type: 'error'
+ , reason: ''
+ , advice: ''
+ , endpoint: ''
+ });
+ },
+
+ 'decoding error packet with reason': function () {
+ parser.decodePacket('7:::0').should().eql({
+ type: 'error'
+ , reason: 'transport not supported'
+ , advice: ''
+ , endpoint: ''
+ });
+ },
+
+ 'decoding error packet with reason and advice': function () {
+ parser.decodePacket('7:::2+0').should().eql({
+ type: 'error'
+ , reason: 'unauthorized'
+ , advice: 'reconnect'
+ , endpoint: ''
+ });
+ },
+
+ 'decoding error packet with endpoint': function () {
+ parser.decodePacket('7::/woot').should().eql({
+ type: 'error'
+ , reason: ''
+ , advice: ''
+ , endpoint: '/woot'
+ });
+ },
+
+ 'decoding ack packet': function () {
+ parser.decodePacket('6:::140').should().eql({
+ type: 'ack'
+ , ackId: '140'
+ , endpoint: ''
+ , args: []
+ });
+ },
+
+ 'decoding ack packet with args': function () {
+ parser.decodePacket('6:::12+["woot","wa"]').should().eql({
+ type: 'ack'
+ , ackId: '12'
+ , endpoint: ''
+ , args: ['woot', 'wa']
+ });
+ },
+
+ 'decoding ack packet with bad json': function () {
+ var thrown = false;
+
+ try {
+ parser.decodePacket('6:::1+{"++]').should().eql({
+ type: 'ack'
+ , ackId: '1'
+ , endpoint: ''
+ , args: []
+ });
+ } catch (e) {
+ thrown = true;
+ }
+
+ thrown.should().be_false;
+ },
+
+ 'decoding json packet': function () {
+ parser.decodePacket('4:::"2"').should().eql({
+ type: 'json'
+ , endpoint: ''
+ , data: '2'
+ });
+ },
+
+ 'decoding json packet with message id and ack data': function () {
+ parser.decodePacket('4:1+::{"a":"b"}').should().eql({
+ type: 'json'
+ , id: 1
+ , ack: 'data'
+ , endpoint: ''
+ , data: { a: 'b' }
+ });
+ },
+
+ 'decoding an event packet': function () {
+ parser.decodePacket('5:::{"name":"woot"}').should().eql({
+ type: 'event'
+ , name: 'woot'
+ , endpoint: ''
+ , args: []
+ });
+ },
+
+ 'decoding an event packet with message id and ack': function () {
+ parser.decodePacket('5:1+::{"name":"tobi"}').should().eql({
+ type: 'event'
+ , id: 1
+ , ack: 'data'
+ , endpoint: ''
+ , name: 'tobi'
+ , args: []
+ });
+ },
+
+ 'decoding an event packet with data': function () {
+ parser.decodePacket('5:::{"name":"edwald","args":[{"a": "b"},2,"3"]}')
+ .should().eql({
+ type: 'event'
+ , name: 'edwald'
+ , endpoint: ''
+ , args: [{a: 'b'}, 2, '3']
+ });
+ },
+
+ 'decoding a message packet': function () {
+ parser.decodePacket('3:::woot').should().eql({
+ type: 'message'
+ , endpoint: ''
+ , data: 'woot'
+ });
+ },
+
+ 'decoding a message packet with id and endpoint': function () {
+ parser.decodePacket('3:5:/tobi').should().eql({
+ type: 'message'
+ , id: 5
+ , ack: true
+ , endpoint: '/tobi'
+ , data: ''
+ });
+ },
+
+ 'decoding a heartbeat packet': function () {
+ parser.decodePacket('2:::').should().eql({
+ type: 'heartbeat'
+ , endpoint: ''
+ });
+ },
+
+ 'decoding a connection packet': function () {
+ parser.decodePacket('1::/tobi').should().eql({
+ type: 'connect'
+ , endpoint: '/tobi'
+ , qs: ''
+ });
+ },
+
+ 'decoding a connection packet with query string': function () {
+ parser.decodePacket('1::/test:?test=1').should().eql({
+ type: 'connect'
+ , endpoint: '/test'
+ , qs: '?test=1'
+ });
+ },
+
+ 'decoding a disconnection packet': function () {
+ parser.decodePacket('0::/woot').should().eql({
+ type: 'disconnect'
+ , endpoint: '/woot'
+ });
+ },
+
+ 'encoding error packet': function () {
+ parser.encodePacket({
+ type: 'error'
+ , reason: ''
+ , advice: ''
+ , endpoint: ''
+ }).should().eql('7::');
+ },
+
+ 'encoding error packet with reason': function () {
+ parser.encodePacket({
+ type: 'error'
+ , reason: 'transport not supported'
+ , advice: ''
+ , endpoint: ''
+ }).should().eql('7:::0');
+ },
+
+ 'encoding error packet with reason and advice': function () {
+ parser.encodePacket({
+ type: 'error'
+ , reason: 'unauthorized'
+ , advice: 'reconnect'
+ , endpoint: ''
+ }).should().eql('7:::2+0');
+ },
+
+ 'encoding error packet with endpoint': function () {
+ parser.encodePacket({
+ type: 'error'
+ , reason: ''
+ , advice: ''
+ , endpoint: '/woot'
+ }).should().eql('7::/woot');
+ },
+
+ 'encoding ack packet': function () {
+ parser.encodePacket({
+ type: 'ack'
+ , ackId: '140'
+ , endpoint: ''
+ , args: []
+ }).should().eql('6:::140');
+ },
+
+ 'encoding ack packet with args': function () {
+ parser.encodePacket({
+ type: 'ack'
+ , ackId: '12'
+ , endpoint: ''
+ , args: ['woot', 'wa']
+ }).should().eql('6:::12+["woot","wa"]');
+ },
+
+ 'encoding json packet': function () {
+ parser.encodePacket({
+ type: 'json'
+ , endpoint: ''
+ , data: '2'
+ }).should().eql('4:::"2"');
+ },
+
+ 'encoding json packet with message id and ack data': function () {
+ parser.encodePacket({
+ type: 'json'
+ , id: 1
+ , ack: 'data'
+ , endpoint: ''
+ , data: { a: 'b' }
+ }).should().eql('4:1+::{"a":"b"}');
+ },
+
+ 'encoding an event packet': function () {
+ parser.encodePacket({
+ type: 'event'
+ , name: 'woot'
+ , endpoint: ''
+ , args: []
+ }).should().eql('5:::{"name":"woot"}');
+ },
+
+ 'encoding an event packet with message id and ack': function () {
+ parser.encodePacket({
+ type: 'event'
+ , id: 1
+ , ack: 'data'
+ , endpoint: ''
+ , name: 'tobi'
+ , args: []
+ }).should().eql('5:1+::{"name":"tobi"}');
+ },
+
+ 'encoding an event packet with data': function () {
+ parser.encodePacket({
+ type: 'event'
+ , name: 'edwald'
+ , endpoint: ''
+ , args: [{a: 'b'}, 2, '3']
+ }).should().eql('5:::{"name":"edwald","args":[{"a":"b"},2,"3"]}');
+ },
+
+ 'encoding a message packet': function () {
+ parser.encodePacket({
+ type: 'message'
+ , endpoint: ''
+ , data: 'woot'
+ }).should().eql('3:::woot');
+ },
+
+ 'encoding a message packet with id and endpoint': function () {
+ parser.encodePacket({
+ type: 'message'
+ , id: 5
+ , ack: true
+ , endpoint: '/tobi'
+ , data: ''
+ }).should().eql('3:5:/tobi');
+ },
+
+ 'encoding a heartbeat packet': function () {
+ parser.encodePacket({
+ type: 'heartbeat'
+ , endpoint: ''
+ }).should().eql('2::');
+ },
+
+ 'encoding a connection packet': function () {
+ parser.encodePacket({
+ type: 'connect'
+ , endpoint: '/tobi'
+ , qs: ''
+ }).should().eql('1::/tobi');
+ },
+
+ 'encoding a connection packet with query string': function () {
+ parser.encodePacket({
+ type: 'connect'
+ , endpoint: '/test'
+ , qs: '?test=1'
+ }).should().eql('1::/test:?test=1');
+ },
+
+ 'encoding a disconnection packet': function () {
+ parser.encodePacket({
+ type: 'disconnect'
+ , endpoint: '/woot'
+ }).should().eql('0::/woot');
+ },
+
+ 'test decoding a payload': function () {
+ parser.decodePayload('\ufffd5\ufffd3:::5\ufffd7\ufffd3:::53d'
+ + '\ufffd3\ufffd0::').should().eql([
+ { type: 'message', data: '5', endpoint: '' }
+ , { type: 'message', data: '53d', endpoint: '' }
+ , { type: 'disconnect', endpoint: '' }
+ ]);
+ },
+
+ 'test encoding a payload': function () {
+ parser.encodePayload([
+ parser.encodePacket({ type: 'message', data: '5', endpoint: '' })
+ , parser.encodePacket({ type: 'message', data: '53d', endpoint: '' })
+ ]).should().eql('\ufffd5\ufffd3:::5\ufffd7\ufffd3:::53d')
+ },
+
+ 'test decoding newline': function () {
+ parser.decodePacket('3:::\n').should().eql({
+ type: 'message'
+ , endpoint: ''
+ , data: '\n'
+ });
+ }
+
+ };
+
+})(
+ 'undefined' == typeof module ? module = {} : module
+ , 'undefined' == typeof io ? require('socket.io-client') : io
+ , 'undefined' == typeof should ? require('should') : should
+);
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/socket.test.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/socket.test.js
new file mode 100644
index 0000000..eae4956
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/socket.test.js
@@ -0,0 +1,422 @@
+
+/*!
+ * socket.io-node
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (module, io, should) {
+
+ if ('object' == typeof global) {
+ return module.exports = { '': function () {} };
+ }
+
+ module.exports = {
+
+ 'test connecting the socket and disconnecting': function (next) {
+ var socket = create();
+
+ socket.on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.on('connect', function () {
+ socket.disconnect();
+ next();
+ });
+ },
+
+ 'test receiving messages': function (next) {
+ var socket = create()
+ , connected = false
+ , messages = 0;
+
+ socket.on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.on('connect', function () {
+ connected = true;
+ });
+
+ socket.on('message', function (i) {
+ String(++messages).should().equal(i);
+ });
+
+ socket.on('disconnect', function (reason) {
+ connected.should().be_true;
+ messages.should().equal(3);
+ reason.should().eql('booted');
+ next();
+ });
+ },
+
+ 'test sending messages': function (next) {
+ var socket = create();
+
+ socket.on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.on('connect', function () {
+ socket.send('echo');
+
+ socket.on('message', function (msg) {
+ msg.should().equal('echo');
+ socket.disconnect();
+ next();
+ });
+ });
+ },
+
+ 'test manual buffer flushing': function (next) {
+ var socket = create();
+
+ socket.socket.options['manualFlush'] = true;
+
+ socket.on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.on('connect', function () {
+ socket.socket.connected = false;
+ socket.send('buffered');
+ socket.socket.onConnect();
+ socket.socket.flushBuffer();
+
+ socket.on('message', function (msg) {
+ msg.should().equal('buffered');
+ socket.disconnect();
+ next();
+ });
+ });
+ },
+
+ 'test automatic buffer flushing': function (next) {
+ var socket = create();
+
+ socket.on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.on('connect', function () {
+ socket.socket.connected = false;
+ socket.send('buffered');
+ socket.socket.onConnect();
+
+ socket.on('message', function (msg) {
+ msg.should().equal('buffered');
+ socket.disconnect();
+ next();
+ });
+ });
+ },
+
+ 'test acks sent from client': function (next) {
+ var socket = create();
+
+ socket.on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.on('connect', function () {
+ socket.on('message', function (msg) {
+ if ('tobi 2' == msg) {
+ socket.disconnect();
+ next();
+ }
+ });
+ });
+ },
+
+ 'test acks sent from server': function (next) {
+ var socket = create();
+
+ socket.on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.on('connect', function () {
+ socket.send('ooo', function () {
+ socket.disconnect();
+ next();
+ });
+ });
+ },
+
+ 'test connecting to namespaces': function (next) {
+ var io = create()
+ , socket = io.socket
+ , namespaces = 2
+ , connect = 0;
+
+ function finish () {
+ socket.of('').disconnect();
+ connect.should().equal(3);
+ next();
+ }
+
+ socket.on('connect', function(){
+ connect++;
+ });
+
+ socket.of('/woot').on('connect', function () {
+ connect++;
+ }).on('message', function (msg) {
+ msg.should().equal('connected to woot');
+ --namespaces || finish();
+ }).on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.of('/chat').on('connect', function () {
+ connect++;
+ }).on('message', function (msg) {
+ msg.should().equal('connected to chat');
+ --namespaces || finish();
+ }).on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+ },
+
+ 'test disconnecting from namespaces': function (next) {
+ var socket = create().socket
+ , namespaces = 2
+ , disconnections = 0;
+
+ function finish () {
+ socket.of('').disconnect();
+ next();
+ };
+
+ socket.of('/a').on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.of('/a').on('connect', function () {
+ socket.of('/a').disconnect();
+ });
+
+ socket.of('/a').on('disconnect', function () {
+ --namespaces || finish();
+ });
+
+ socket.of('/b').on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.of('/b').on('connect', function () {
+ socket.of('/b').disconnect();
+ });
+
+ socket.of('/b').on('disconnect', function () {
+ --namespaces || finish();
+ });
+ },
+
+ 'test authorizing for namespaces': function (next) {
+ var socket = create().socket
+
+ function finish () {
+ socket.of('').disconnect();
+ next();
+ };
+
+ socket.of('/a')
+ .on('connect_failed', function (msg) {
+ next();
+ })
+ .on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+ },
+
+ 'test sending json from server': function (next) {
+ var socket = create();
+
+ socket.on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.on('message', function (msg) {
+ msg.should().eql(3141592);
+ socket.disconnect();
+ next();
+ });
+ },
+
+ 'test sending json from client': function (next) {
+ var socket = create();
+
+ socket.on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.json.send([1, 2, 3]);
+ socket.on('message', function (msg) {
+ msg.should().equal('echo');
+ socket.disconnect();
+ next();
+ });
+ },
+
+ 'test emitting an event from server': function (next) {
+ var socket = create();
+
+ socket.on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.on('woot', function () {
+ socket.disconnect();
+ next();
+ });
+ },
+
+ 'test emitting an event to server': function (next) {
+ var socket = create();
+
+ socket.on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.emit('woot');
+ socket.on('echo', function () {
+ socket.disconnect();
+ next();
+ })
+ },
+
+ 'test emitting multiple events at once to the server': function (next) {
+ var socket = create();
+
+ socket.on('connect', function () {
+ socket.emit('print', 'foo');
+ socket.emit('print', 'bar');
+ });
+
+ socket.on('done', function () {
+ socket.disconnect();
+ next();
+ });
+ },
+
+ 'test emitting an event from server and sending back data': function (next) {
+ var socket = create();
+
+ socket.on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.on('woot', function (a, fn) {
+ a.should().eql(1);
+ fn('test');
+
+ socket.on('done', function () {
+ socket.disconnect();
+ next();
+ });
+ });
+ },
+
+ 'test emitting an event to server and sending back data': function (next) {
+ var socket = create();
+
+ socket.on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.emit('tobi', 1, 2, function (a) {
+ a.should().eql({ hello: 'world' });
+ socket.disconnect();
+ next();
+ });
+ },
+
+ 'test encoding a payload': function (next) {
+ var socket = create('/woot');
+
+ socket.on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.on('connect', function () {
+ socket.socket.setBuffer(true);
+ socket.send('ñ');
+ socket.send('ñ');
+ socket.send('ñ');
+ socket.send('ñ');
+ socket.socket.setBuffer(false);
+ });
+
+ socket.on('done', function () {
+ socket.disconnect();
+ next();
+ });
+ },
+
+ 'test sending query strings to the server': function (next) {
+ var socket = create('?foo=bar');
+
+ socket.on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.on('message', function (data) {
+ data.query.foo.should().eql('bar');
+
+ socket.disconnect();
+ next();
+ });
+ },
+
+ 'test sending newline': function (next) {
+ var socket = create();
+
+ socket.on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.send('\n');
+
+ socket.on('done', function () {
+ socket.disconnect();
+ next();
+ });
+ },
+
+ 'test sending unicode': function (next) {
+ var socket = create();
+
+ socket.on('error', function (msg) {
+ throw new Error(msg || 'Received an error');
+ });
+
+ socket.json.send({ test: "☃" });
+
+ socket.on('done', function () {
+ socket.disconnect();
+ next();
+ });
+ },
+
+ 'test webworker connection': function (next) {
+ if (!window.Worker) {
+ return next();
+ }
+
+ var worker = new Worker('/test/worker.js');
+ worker.postMessage(uri());
+ worker.onmessage = function (ev) {
+ if ('done!' == ev.data) return next();
+ throw new Error('Unexpected message: ' + ev.data);
+ }
+ }
+
+ };
+
+})(
+ 'undefined' == typeof module ? module = {} : module
+ , 'undefined' == typeof io ? require('socket.io-client') : io
+ , 'undefined' == typeof should ? require('should-browser') : should
+);
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/util.test.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/util.test.js
new file mode 100644
index 0000000..30db5a6
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/util.test.js
@@ -0,0 +1,156 @@
+
+/*!
+ * socket.io-node
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (module, io, should) {
+
+ module.exports = {
+
+ 'parse uri': function () {
+ var http = io.util.parseUri('http://google.com')
+ , https = io.util.parseUri('https://www.google.com:80')
+ , query = io.util.parseUri('google.com:8080/foo/bar?foo=bar');
+
+ http.protocol.should().eql('http');
+ http.port.should().eql('');
+ http.host.should().eql('google.com');
+ https.protocol.should().eql('https');
+ https.port.should().eql('80');
+ https.host.should().eql('www.google.com');
+ query.port.should().eql('8080');
+ query.query.should().eql('foo=bar');
+ query.path.should().eql('/foo/bar');
+ query.relative.should().eql('/foo/bar?foo=bar');
+ },
+
+ 'unique uri': function () {
+ var protocol = io.util.parseUri('http://google.com')
+ , noprotocol = io.util.parseUri('google.com')
+ , https = io.util.parseUri('https://google.com')
+ , path = io.util.parseUri('https://google.com/google.com/com/?foo=bar');
+
+ if ('object' == typeof window) {
+ io.util.uniqueUri(protocol).should().eql('http://google.com:3000');
+ io.util.uniqueUri(noprotocol).should().eql('http://google.com:3000');
+ } else {
+ io.util.uniqueUri(protocol).should().eql('http://google.com:80');
+ io.util.uniqueUri(noprotocol).should().eql('http://google.com:80');
+ }
+
+ io.util.uniqueUri(https).should().eql('https://google.com:443');
+ io.util.uniqueUri(path).should().eql('https://google.com:443');
+ },
+
+ 'chunk query string': function () {
+ io.util.chunkQuery('foo=bar').should().be.a('object');
+ io.util.chunkQuery('foo=bar').foo.should().eql('bar');
+ },
+
+ 'merge query strings': function () {
+ var base = io.util.query('foo=bar', 'foo=baz')
+ , add = io.util.query('foo=bar', 'bar=foo')
+
+ base.should().eql('?foo=baz');
+ add.should().eql('?foo=bar&bar=foo');
+
+ io.util.query('','').should().eql('');
+ io.util.query('foo=bar', '').should().eql('?foo=bar');
+ io.util.query('', 'foo=bar').should().eql('?foo=bar');
+ },
+
+ 'request': function () {
+ var type = typeof io.util.request();
+ type.should().eql('object');
+ },
+
+ 'is array': function () {
+ io.util.isArray([]).should().be_true;
+ io.util.isArray({}).should().be_false;
+ io.util.isArray('str').should().be_false;
+ io.util.isArray(new Date).should().be_false;
+ io.util.isArray(true).should().be_false;
+ io.util.isArray(arguments).should().be_false;
+ },
+
+ 'merge, deep merge': function () {
+ var start = {
+ foo: 'bar'
+ , bar: 'baz'
+ }
+ , duplicate = {
+ foo: 'foo'
+ , bar: 'bar'
+ }
+ , extra = {
+ ping: 'pong'
+ }
+ , deep = {
+ level1:{
+ foo: 'bar'
+ , level2: {
+ foo: 'bar'
+ , level3:{
+ foo: 'bar'
+ , rescursive: deep
+ }
+ }
+ }
+ }
+ // same structure, but changed names
+ , deeper = {
+ foo: 'bar'
+ , level1:{
+ foo: 'baz'
+ , level2: {
+ foo: 'foo'
+ , level3:{
+ foo: 'pewpew'
+ , rescursive: deep
+ }
+ }
+ }
+ };
+
+ io.util.merge(start, duplicate);
+
+ start.foo.should().eql('foo');
+ start.bar.should().eql('bar');
+
+ io.util.merge(start, extra);
+ start.ping.should().eql('pong');
+ start.foo.should().eql('foo');
+
+ io.util.merge(deep, deeper);
+
+ deep.foo.should().eql('bar');
+ deep.level1.foo.should().eql('baz');
+ deep.level1.level2.foo.should().eql('foo');
+ deep.level1.level2.level3.foo.should().eql('pewpew');
+ },
+
+ 'defer': function (next) {
+ var now = +new Date;
+
+ io.util.defer(function () {
+ ((new Date - now) >= ( io.util.webkit ? 100 : 0 )).should().be_true();
+ next();
+ })
+ },
+
+ 'indexOf': function () {
+ var data = ['socket', 2, 3, 4, 'socket', 5, 6, 7, 'io'];
+ io.util.indexOf(data, 'socket', 1).should().eql(4);
+ io.util.indexOf(data, 'socket').should().eql(0);
+ io.util.indexOf(data, 'waffles').should().eql(-1);
+ }
+
+ };
+
+})(
+ 'undefined' == typeof module ? module = {} : module
+ , 'undefined' == typeof io ? require('socket.io-client') : io
+ , 'undefined' == typeof should ? require('should') : should
+);
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/worker.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/worker.js
new file mode 100644
index 0000000..c542632
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/test/worker.js
@@ -0,0 +1,20 @@
+importScripts('/socket.io/socket.io.js');
+
+self.onmessage = function (ev) {
+ var url = ev.data
+ , socket = io.connect(url);
+
+ socket.on('done', function () {
+ self.postMessage('done!');
+ });
+
+ socket.on('connect_failed', function () {
+ self.postMessage('connect failed');
+ });
+
+ socket.on('error', function () {
+ self.postMessage('error');
+ });
+
+ socket.send('woot');
+}