girc
Version:
IRC Client library
45 lines (42 loc) • 1.83 kB
JavaScript
/*jslint node: true, vars: true*/
/*global describe, it*/
;
describe('plugins/channel.js', function () {
var stream = new (require('stream').PassThrough)();
var cmngr = new (require('../../lib/connectionManager'))({id: "test_plugin_channel", nick: "testnick"}, stream);
var con = cmngr.getConnection('test_plugin_channel');
stream.emit('connect');
describe('getChannel(name)', function () {
it('should return Channel object', function (done) {
var channel = con.getChannel('#foo');
channel.getName().should.equal('#foo');
done();
});
});
describe('isChannel()', function () {
it('should return true', function (done) {
var channel = con.getChannel('#foo');
con.isChannel(channel).should.equal(true);
done();
});
it('should return false', function (done) {
con.isChannel(undefined).should.equal(false);
done();
});
});
describe('getChannellist()', function () {
it('should return List of channels that we are in', function (done) {
stream.write(':testnick!testuser@testhost.com JOIN :#foo\r\n');
stream.write(':testnick!testuser@testhost.com JOIN :#bar\r\n');
stream.write(':testnick!testuser@testhost.com JOIN :#baz\r\n');
stream.write(':testnick!testuser@testhost.com PART #bar :So long!\r\n');
process.nextTick(function () {
var chanlist = con.getChannellist();
chanlist.should.be.instanceof(Array).and.have.lengthOf(2);
chanlist[0].should.equal('#foo');
chanlist[1].should.equal('#baz');
done();
});
});
});
});