Skip to content

Instantly share code, notes, and snippets.

@ritalin
Created August 30, 2012 16:27
Show Gist options
  • Save ritalin/3532387 to your computer and use it in GitHub Desktop.
Save ritalin/3532387 to your computer and use it in GitHub Desktop.
An Unit test for the client side socket.io, by mocha
//
// Test by mocha
//
XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
var cli = require('../client/js/socket.io'); // Socket.io client module
var should = require('should');
// The global.location is necessary
var page = "http://127.0.0.1:8888/hello.html";
global.location = require('url').parse(page);
describe("Test on the client side", function() {
var server;
describe("Connect the server with Socket.IO", function() {
it ("Should establish connection", function() {
var client = cli.connect(page);
client.should.be.ok;
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment