From 93a09b240936d81b03642e8709a996872e537785 Mon Sep 17 00:00:00 2001 From: Evan Tahler Date: Mon, 4 Mar 2013 22:14:27 -0800 Subject: [PATCH] remove socket io tes --- test/action_chat.js | 45 ++++++++++++++++++++++++++++----------- test/client_socket.js | 20 ++++++++--------- test/client_webSockets.js | 1 - 3 files changed, 42 insertions(+), 24 deletions(-) diff --git a/test/action_chat.js b/test/action_chat.js index d8c2e7a36..1cb05e981 100644 --- a/test/action_chat.js +++ b/test/action_chat.js @@ -2,12 +2,8 @@ describe('Action: chat', function(){ var specHelper = require('../helpers/specHelper.js').specHelper; var apiObj = {}; var should = require("should"); - var io = require('socket.io-client'); var socketURL = "http://localhost:9000"; - var io_options ={ - transports: ['websocket'], - 'force new connection': true - }; + var net = require('net') before(function(done){ specHelper.prepare(0, function(api){ @@ -104,16 +100,39 @@ describe('Action: chat', function(){ it('action should only be valid for http/s clients', function(done){ this.timeout(5000) - var client = io.connect(socketURL, io_options); - client.on('welcome', function(data){ - client.on('response', function(data){ - client.removeListener('response', this); - data.error.should.equal("Error: this action does not support the webSocketconnection type"); - client.disconnect(); + + function makeSocketRequest(thisClient, message, cb){ + 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); + 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(); - }); - client.emit('action', {action: 'chat'}); + }; + + setTimeout(function(){ + client.on('data', rsp); + client.write("chat" + "\r\n"); + }, 1000); }); + }); }); diff --git a/test/client_socket.js b/test/client_socket.js index c4cef87c7..df7b29008 100644 --- a/test/client_socket.js +++ b/test/client_socket.js @@ -12,16 +12,16 @@ describe('Client: Socket', function(){ var client3 = {}; function makeSocketRequest(thisClient, message, cb){ - 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); - thisClient.removeListener('data', rsp); - cb(parsed); - }; - thisClient.on('data', rsp); - thisClient.write(message + "\r\n"); + 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); + thisClient.removeListener('data', rsp); + cb(parsed); + }; + thisClient.on('data', rsp); + thisClient.write(message + "\r\n"); } before(function(done){ diff --git a/test/client_webSockets.js b/test/client_webSockets.js index 479acdbde..d5172b29e 100644 --- a/test/client_webSockets.js +++ b/test/client_webSockets.js @@ -2,7 +2,6 @@ describe('Client: Web Sockets', function(){ var specHelper = require('../helpers/specHelper.js').specHelper; var apiObj = {}; var should = require("should"); - var io = require('socket.io-client'); var socketURL = "http://localhost:9000"; var io_options ={ transports: ['websocket'],