Minor modifications (readme, tests)

Prep for server test dispatch interface by tying socket events to server events.

Link to gun in the readme.

Not really much in this commit.
This commit is contained in:
Jesse Gibson
2016-03-15 16:02:59 -06:00
parent 53faba380b
commit 758a8fc8d6
4 changed files with 26 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
# Panic
A distributed testing framework designed for and built by the team at gunDB.
A distributed testing framework designed for and built by the team at [gunDB](https://github.com/amark/gun).
### *under development*

View File

@@ -7,6 +7,12 @@ var io = require('socket.io');
var server;
function subscribe(socket) {
socket.on('connection', function (client) {
server.events.emit('join', client);
});
}
function open(port) {
// set default port
@@ -20,6 +26,8 @@ function open(port) {
// update state
server.port = port;
server.socket = io(port);
subscribe(server.socket);
return server.socket;
}

View File

@@ -8,6 +8,7 @@ process.argv[2] = 3000;
var server = require('../../server');
var Emitter = require('events');
var Socket = require('socket.io');
var io = require('socket.io-client');
describe('The socket server', function () {
it('should have an event emitter', function () {
@@ -53,4 +54,19 @@ describe('The socket server', function () {
it('should expose the port number', function () {
expect(server.hasOwnProperty('port')).toBe(true);
});
it('should notify when clients join', function (done) {
server.open(8080);
server.events.on('join', done);
io('http://localhost:8080');
});
it('should pass the client obj on join', function (done) {
server.open(8080);
server.events.on('join', function (client) {
expect(client).toEqual(jasmine.any(Object));
done();
});
io('http://localhost:8080');
});
});

View File

@@ -3,6 +3,7 @@
var Emitter = require('events');
var assign = require('object-assign-deep');
var server = require('../server');
var stack;
function push(test) {