Skip to content

Commit

Permalink
adding units for getConnections
Browse files Browse the repository at this point in the history
  • Loading branch information
brozeph committed Aug 14, 2017
1 parent bb7662a commit 6148ea5
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions test/src/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,37 @@ describe('Server', () => {
});

describe('#getConnections', () => {
// should support callback
it('should support callback', (done) => {
let server = new Server(mockPath, mockServices);

// should return 0 with no connections
server.listen(() => {
let client = new Client(mockPath);
client.call('b.lowerCasePromise', 'TESTING');
});

// should return count of active connections
server.on('connection', () => {
return server.getConnections((err, count) => {
should.not.exist(err);
should.exist(count);
count.should.equal(1);

return server.close(done);
});
});
});

it('should return 0 with no connections', async () => {
// setup the server
let server = new Server(mockPath, mockServices);
await server.listen();

let count = await server.getConnections();
should.exist(count);
count.should.equal(0);

// close the server
await server.close();
});
});

describe('#listen', () => {
Expand Down

0 comments on commit 6148ea5

Please sign in to comment.