Skip to content

Commit

Permalink
remove socket io tes
Browse files Browse the repository at this point in the history
  • Loading branch information
evantahler committed Mar 5, 2013
1 parent 7e47dce commit 93a09b2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 24 deletions.
45 changes: 32 additions & 13 deletions test/action_chat.js
Expand Up @@ -2,12 +2,8 @@ describe('Action: chat', function(){
var specHelper = require('../helpers/specHelper.js').specHelper; var specHelper = require('../helpers/specHelper.js').specHelper;
var apiObj = {}; var apiObj = {};
var should = require("should"); var should = require("should");
var io = require('socket.io-client');
var socketURL = "http://localhost:9000"; var socketURL = "http://localhost:9000";
var io_options ={ var net = require('net')
transports: ['websocket'],
'force new connection': true
};


before(function(done){ before(function(done){
specHelper.prepare(0, function(api){ specHelper.prepare(0, function(api){
Expand Down Expand Up @@ -104,16 +100,39 @@ describe('Action: chat', function(){


it('action should only be valid for http/s clients', function(done){ it('action should only be valid for http/s clients', function(done){
this.timeout(5000) this.timeout(5000)
var client = io.connect(socketURL, io_options);
client.on('welcome', function(data){ function makeSocketRequest(thisClient, message, cb){
client.on('response', function(data){ var rsp = function(d){
client.removeListener('response', this); var lines = d.split("\n");
data.error.should.equal("Error: this action does not support the webSocketconnection type"); var lastLine = lines[(lines.length - 1)];
client.disconnect(); if(lastLine == ""){ lastLine = lines[(lines.length - 2)]; }
var parsed = JSON.parse(lastLine);
thisClient.removeListener('data', rsp);
cb(parsed);
};
thisClient.on('data', rsp);
thisClient.write(message + "\r\n");
}

client = net.connect(specHelper.params[0].tcpServer.port, function(){
client.setEncoding('utf8');
var rsp = function(d){
var lines = d.split("\n");
var lastLine = lines[(lines.length - 1)];
if(lastLine == ""){ lastLine = lines[(lines.length - 2)]; }
var parsed = JSON.parse(lastLine);
client.removeListener('data', rsp);

parsed.error.should.equal("Error: this action does not support the socket connection type");
done(); done();
}); };
client.emit('action', {action: 'chat'});
setTimeout(function(){
client.on('data', rsp);
client.write("chat" + "\r\n");
}, 1000);
}); });

}); });


}); });
Expand Down
20 changes: 10 additions & 10 deletions test/client_socket.js
Expand Up @@ -12,16 +12,16 @@ describe('Client: Socket', function(){
var client3 = {}; var client3 = {};


function makeSocketRequest(thisClient, message, cb){ function makeSocketRequest(thisClient, message, cb){
var rsp = function(d){ var rsp = function(d){
var lines = d.split("\n"); var lines = d.split("\n");
var lastLine = lines[(lines.length - 1)]; var lastLine = lines[(lines.length - 1)];
if(lastLine == ""){ lastLine = lines[(lines.length - 2)]; } if(lastLine == ""){ lastLine = lines[(lines.length - 2)]; }
var parsed = JSON.parse(lastLine); var parsed = JSON.parse(lastLine);
thisClient.removeListener('data', rsp); thisClient.removeListener('data', rsp);
cb(parsed); cb(parsed);
}; };
thisClient.on('data', rsp); thisClient.on('data', rsp);
thisClient.write(message + "\r\n"); thisClient.write(message + "\r\n");
} }


before(function(done){ before(function(done){
Expand Down
1 change: 0 additions & 1 deletion test/client_webSockets.js
Expand Up @@ -2,7 +2,6 @@ describe('Client: Web Sockets', function(){
var specHelper = require('../helpers/specHelper.js').specHelper; var specHelper = require('../helpers/specHelper.js').specHelper;
var apiObj = {}; var apiObj = {};
var should = require("should"); var should = require("should");
var io = require('socket.io-client');
var socketURL = "http://localhost:9000"; var socketURL = "http://localhost:9000";
var io_options ={ var io_options ={
transports: ['websocket'], transports: ['websocket'],
Expand Down

0 comments on commit 93a09b2

Please sign in to comment.