Created
October 18, 2012 13:20
-
-
Save alrik11es/3911774 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var io = require('socket.io-client'); | |
var nano = require('nano')('http://localhost:5984'); | |
var server = 'http://localhost:8080'; | |
module.exports = { | |
setUp: function (callback) { | |
this.socket = io.connect(server, {'reconnect': false, 'force new connection': true}); | |
callback(); | |
}, | |
tearDown: function (callback) { | |
this.socket.disconnect(); | |
this.socket = null; | |
callback(); | |
}, | |
connection: function (test) { | |
this.socket.on('connect', function () { | |
test.ok(true); | |
test.done(); | |
}); | |
this.socket.on('error', function(socket){ | |
test.ok(false, 'No se puede conectar al servidor'); | |
test.done(); | |
}); | |
}, | |
register_with_bad_email: function (test) { | |
this.socket.emit('register',{nick: 'user', email: 'bad_email'}); | |
this.socket.on('register ok', function(){ | |
test.ok(false, 'Al introducir un email inválido deja registrarse'); | |
test.done(); | |
}); | |
this.socket.on('validation error', function(){ | |
test.ok(true); | |
test.done(); | |
}); | |
this.socket.on('disconnect', function(socket){ | |
test.ok(false, 'Error en el servidor'); | |
test.done(); | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment