mirror of
https://github.com/gundb/panic-server.git
synced 2026-04-15 03:00:16 -04:00
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:
@@ -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*
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
var Emitter = require('events');
|
||||
var assign = require('object-assign-deep');
|
||||
var server = require('../server');
|
||||
var stack;
|
||||
|
||||
function push(test) {
|
||||
|
||||
Reference in New Issue
Block a user