UNPKG

girc

Version:
68 lines (66 loc) 2.71 kB
/*jslint node: true, vars: true*/ /*global describe, it*/ "use strict"; var Stream = require('stream').PassThrough; var ConManagr = require('../lib/connectionManager'); var Connection = require('../lib/connection'); describe('connectionManager.js', function () { var stream = new Stream(); var cmngr = new ConManagr({id: "test_girc_1"}, stream); describe('new ConnectionManager({options})', function () { it('should have the right id', function (done) { cmngr.getConnection('test_girc_1').getId().should.equal('test_girc_1'); done(); }); }); describe('new ConnectionManager([{options}])', function () { var _cmngr = new ConManagr([ {id: "test_girc_3"}, {id: "test_girc_4"} ], new Stream()); it('should have created 2 connections', function (done) { var connection = _cmngr.getConnection(); Object.keys(connection).should.containEql('test_girc_3'); Object.keys(connection).should.containEql('test_girc_4'); done(); }); }); describe('createConnection({options})', function () { var connection = cmngr.createConnection({id: "test_girc_2"}, stream); it('should return connection object', function (done) { connection.should.be.an.instanceof(Connection); done(); }); it('should have the right id', function (done) { connection.getId().should.equal('test_girc_2'); done(); }); }); describe('getConnection(id)', function () { var connection = cmngr.getConnection('test_girc_2'); it('should return connection object', function (done) { connection.should.be.an.instanceof(Connection); done(); }); it('should have the right id', function (done) { connection.getId().should.equal('test_girc_2'); done(); }); }); describe('getConnection()', function () { it('should return connection list', function (done) { var connections = cmngr.getConnection(); Object.keys(connections).should.containEql('test_girc_1'); Object.keys(connections).should.containEql('test_girc_2'); done(); }); }); describe('removeConnection(id)', function () { it('should remove the connection', function (done) { cmngr.removeConnection('test_girc_2', function () { (cmngr.getConnection('test_girc_2') === null).should.be.true; done(); }); }); }); });