UNPKG

girc

Version:
54 lines (50 loc) 2.69 kB
/*jslint node: true, vars: true*/ /*global describe, it*/ "use strict"; describe('plugins/notice.js', function () { var stream = new (require('stream').PassThrough)(); var cmngr = new (require('../../lib/connectionManager'))({id: "test_plugin_notice", nick: "testnick"}, stream); var con = cmngr.getConnection('test_plugin_notice'); stream.emit('connect'); describe('notice(target, [...])', function () { it('should send notice if target is string', function (done) { stream.once('data', function (chunk) { chunk.toString().should.equal('NOTICE testnick :The quick brown fox jumps over the lazy dog\r\n'); done(); }); con.notice('testnick', 'The quick brown fox jumps over the lazy dog'); }); it('should send notice if target is user', function (done) { stream.once('data', function (chunk) { chunk.toString().should.equal('NOTICE testnick :The quick brown fox jumps over the lazy dog\r\n'); done(); }); con.notice(con.getUser('testnick'), 'The quick brown fox jumps over the lazy dog'); }); it('should send notice if target is channel', function (done) { stream.once('data', function (chunk) { chunk.toString().should.equal('NOTICE #channel :The quick brown fox jumps over the lazy dog\r\n'); done(); }); con.notice(con.getChannel('#channel'), 'The quick brown fox jumps over the lazy dog'); }); it('should format with util.format', function (done) { stream.once('data', function (chunk) { chunk.toString().should.equal('NOTICE target :The quick brown fox jumps over the lazy dog\r\n'); done(); }); con.notice('target', 'The %s brown %s jumps over the lazy %s', 'quick', 'fox', 'dog'); }); }); describe('on NOTICE', function () { it('should emit "notice"', function (done) { con.once('notice', function (event) { event.from.getNick().should.equal('NickServ'); event.to.should.equal('foo'); event.message.should.equal('This nickname is registered. Please choose a different nickname, or identify via /msg NickServ identify <password>.'); done(); }); stream.write(':NickServ!NickServ@services. NOTICE foo :This nickname is registered. Please choose a different nickname, or identify via /msg NickServ identify <password>.\r\n'); }); }); });