UNPKG

girc

Version:
84 lines (80 loc) 3.5 kB
/*jslint node: true, vars: true*/ /*global describe, it*/ "use strict"; var Stream = require('stream').PassThrough; describe('user.js', function () { var stream = new Stream(); var ConManagr = require('../lib/connectionManager'); var cmngr = new ConManagr({id: "test_lib_user", nick: "testnick", username: "testuser", realname: "testrealname"}, stream); var con = cmngr.getConnection('test_lib_user'); stream.emit('connect'); var user = con.getUser('testnick'); stream.write(':example.irc.net 301 foo testnick :Auto away at Tue Aug 5 13:43:42 2014\r\n'); stream.write(':example.irc.net 307 foo testnick :is a registered nick\r\n'); stream.write(':example.irc.net 311 foo testnick testuser testhost.com * :testrealname\r\n'); stream.write(':example.irc.net 312 foo testnick example.irc.net :Server Info\r\n'); stream.write(':example.irc.net 313 foo testnick :is a NetAdmin on example.irc.net\r\n'); stream.write(':example.irc.net 317 foo testnick 1076 1390235346 :seconds idle, signon time\r\n'); stream.write(':example.irc.net 319 foo testnick :~#chan1 @#chan2 #chan3\r\n'); stream.write(':example.irc.net 330 foo testnick loggedinnick :is logged in as\r\n'); stream.write(':example.irc.net 671 foo testnick :is using a secure connection\r\n'); stream.write(':example.irc.net 318 foo testnick :End of /WHOIS list.\r\n'); describe('toString()', function () { it('should return nick!user@host', function (done) { user.toString().should.equal('testnick!testuser@testhost.com'); done(); }); }); describe('getNick()', function () { it('should return nick', function (done) { user.getNick().should.equal('testnick'); done(); }); }); describe('getUsername()', function () { it('should return username', function (done) { user.getUsername().should.equal('testuser'); done(); }); }); describe('getRealname()', function () { it('should return realname', function (done) { user.getRealname().should.equal('testrealname'); done(); }); }); describe('getHostname()', function () { it('should return hostname', function (done) { user.getHostname().should.equal('testhost.com'); done(); }); }); describe('getChannels()', function () { it('should return list of channels', function (done) { user.getChannels().should.be.an.instanceOf(Object).and.have.properties({ '#chan1': ['~'], '#chan2': ['@'], '#chan3': [] }); done(); }); }); describe('getServer()', function () { it('should return name of connected server', function (done) { user.getServer().should.equal('example.irc.net'); done(); }); }); describe('getServerInfo()', function () { it('should return info of connected server', function (done) { user.getServerInfo().should.equal('Server Info'); done(); }); }); describe('getAway()', function () { it('should return away msg', function (done) { user.getAway().should.equal('Auto away at Tue Aug 5 13:43:42 2014'); done(); }); }); });