more tests

This commit is contained in:
Guillermo Rauch
2014-02-13 14:44:25 -08:00
parent a34d4e54dc
commit dc2afa4bc1
2 changed files with 36 additions and 3 deletions

View File

@@ -3,11 +3,27 @@ var io = require('../');
describe('connection', function() {
this.timeout(10000);
var socket = io();
it('should connect to localhost', function(done) {
var socket = io();
socket.emit('hi');
socket.on('hi', function(data){
socket.close();
done();
});
});
it('should work with acks', function(done){
socket.emit('ack');
socket.on('ack', function(fn){
fn(5, { test: true });
});
socket.on('got it', done);
});
it('should work with false', function(done){
socket.emit('false');
socket.on('false', function(f){
expect(f).to.be(false);
done();
});
});

View File

@@ -5,5 +5,22 @@ var io = require('socket.io');
var server = io(process.env.ZUUL_PORT);
server.on('connection', function(socket){
socket.emit('hi');
// simple test
socket.on('hi', function(){
socket.emit('hi');
});
// ack tests
socket.on('ack', function(){
socket.emit('ack', function(a, b){
if (a == 5 && b.test) {
socket.emit('got it');
}
});
});
// false test
socket.on('false', function(){
socket.emit('false', false);
});
});