girc
Version:
IRC Client library
62 lines (58 loc) • 2.85 kB
JavaScript
/*jslint node: true, vars: true*/
/*global describe, it*/
;
describe('plugins/kick.js', function () {
var stream = new (require('stream').PassThrough)();
var cmngr = new (require('../../lib/connectionManager'))({id: "test_plugin_kick", nick: "testnick"}, stream);
var con = cmngr.getConnection('test_plugin_kick');
stream.emit('connect');
describe('kick(channel, user, reason)', function () {
it('should kick <user> from the <channel> with <reason>', function (done) {
stream.once('data', function (chunk) {
chunk.toString().should.equal('KICK #channel user :example reason\r\n');
done();
});
con.kick('#channel', 'user', 'example reason');
});
it('should also work if <user> is an array of users', function (done) {
stream.once('data', function (chunk) {
chunk.toString().should.equal('KICK #channel user1,user2,user3 :example reason\r\n');
done();
});
con.kick('#channel', ['user1', 'user2', 'user3'], 'example reason');
});
it('should also work if <channel> is an array of channels', function (done) {
stream.once('data', function (chunk) {
chunk.toString().should.equal('KICK #channel1,#channel2,#channel3 user :example reason\r\n');
done();
});
con.kick(['#channel1', '#channel2', '#channel3'], 'user', 'example reason');
});
it('should also work if <user> is a user instance', function (done) {
stream.once('data', function (chunk) {
chunk.toString().should.equal('KICK #channel user :example reason\r\n');
done();
});
con.kick('#channel', con.getUser('user'), 'example reason');
});
it('should also work if <channel> is a channel instance', function (done) {
stream.once('data', function (chunk) {
chunk.toString().should.equal('KICK #channel user :example reason\r\n');
done();
});
con.kick(con.getChannel('#channel'), 'user', 'example reason');
});
});
describe('on KICK', function () {
it('should emit "kick"', function (done) {
con.once('kick', function (event) {
event.channel.getName().should.equal('#foo');
event.user.getNick().should.equal('targetnick');
event.by.getNick().should.equal('testnick');
event.reason.should.equal('goodbye cruel world');
done();
});
stream.write(':testnick!testuser@testhost.com KICK #foo targetnick :goodbye cruel world\r\n');
});
});
});