<commit_before>var coffea = require('../..');
var Stream = require('stream').PassThrough;

describe('nick.js', function() {
	describe('on NICK', function() {
		it('should emit "nick" [single-network]', function (done) {
			var st1 = new Stream();
			var client = coffea(st1);

			client.on("nick", function (event) {
				event.user.getNick().should.equal('evilop');
                event.oldNick.should.equal('troll');
				done();
			});

			st2.write(':troll!<EMAIL> NICK evilop\r\n');
		});

		it('should emit "nick" [multi-network]', function (done) {
			var st1 = new Stream();
			var st2 = new Stream();
			var client = coffea(st1);
			client.useStream(st2);

			client.on("nick", function (event) {
				if (event.network === 0) {
					event.user.getNick().should.equal('ChanServ');
                	event.oldNick.should.equal('NickServ');
				} else {
					event.user.getNick().should.equal('evilop');
                	event.oldNick.should.equal('troll');
				}
			});

			st1.write(':NickServ!NickServ@services. NICK ChanServ\r\n');
			st2.write(':troll!<EMAIL> NICK evilop\r\n');
		
			done();
		});

		it('should emit "{network}:nick" [multi-network]', function (done) {
			var st1 = new Stream();
			var st2 = new Stream();
			var client = coffea(st1);
			client.useStream(st2);

			client.on("0:nick", function (event) {
				event.user.getNick().should.equal('ChanServ');
                event.oldNick.should.equal('NickServ');
			});

			client.on("1:nick", function (event) {
				event.user.getNick().should.equal('evilop');
                event.oldNick.should.equal('troll');
			});

			st1.write(':NickServ!NickServ@services. NICK ChanServ\r\n');
			st2.write(':troll!<EMAIL> NICK evilop\r\n');			st2.write(':troll!<EMAIL> NICK evilop\r\n');
		
			done();
		});
	});

	describe("on ERR_NICKNAMEINUSE", function() {
		it("should add _ to nickname", function(done) {
			var st1 = new Stream();
			var client = coffea(st1);

			client.nick('bar');
			st1.write(':irc.local 433 * foo :Nickname is already in use.\r\n');

			process.nextTick(function () {
				client.getUser.getNick.should.equal('foo_');
				st1.write(':irc.local 433 * foo_ :Nickname is already in use.\r\n');
				process.nextTick(function () {
					client.getUser.getNick.should.equal('foo__');
					done();
				});
			});
		});
	});
});<commit_msg>fix errors and change tabs to spaces<commit_after>var coffea = require('../..');
var Stream = require('stream').PassThrough;

describe('nick.js', function() {
    describe('on NICK', function() {
        it('should emit "nick" [single-network]', function (done) {
            var st1 = new Stream();
            var client = coffea(st1);

            client.on("nick", function (event) {
                event.user.getNick().should.equal('evilop');
                event.oldNick.should.equal('troll');
                done();
            });

            st1.write(':troll!<EMAIL> NICK evilop\r\n');
        });

        it('should emit "nick" [multi-network]', function (done) {
            var st1 = new Stream();
            var st2 = new Stream();
            var client = coffea(st1);
            client.useStream(st2);

            client.on("nick", function (event) {
                if (event.network === 0) {
                    event.user.getNick().should.equal('ChanServ');
                    event.oldNick.should.equal('NickServ');
                } else {
                    event.user.getNick().should.equal('evilop');
                    event.oldNick.should.equal('troll');
                }
            });

            st1.write(':NickServ!NickServ@services. NICK ChanServ\r\n');
            st2.write(':troll!<EMAIL> NICK evilop\r\n');
        
            done();
        });

        it('should emit "{network}:nick" [multi-network]', function (done) {
            var st1 = new Stream();
            var st2 = new Stream();
            var client = coffea(st1);
            client.useStream(st2);

            client.on("0:nick", function (event) {
                event.user.getNick().should.equal('ChanServ');
                event.oldNick.should.equal('NickServ');
            });

            client.on("1:nick", function (event) {
                event.user.getNick().should.equal('evilop');
                event.oldNick.should.equal('troll');
            });

            st1.write(':NickServ!NickServ@services. NICK ChanServ\r\n');
            st2.write(':troll!<EMAIL> NICK evilop\r\n');            st2.write(':troll!<EMAIL> NICK evilop\r\n');
        
            done();
        });
    });

    describe("on ERR_NICKNAMEINUSE", function() {
        it("should add _ to nickname", function(done) {
            var st1 = new Stream();
            var client = coffea(st1);

            client.nick('bar');
            st1.write(':irc.local 433 * foo :Nickname is already in use.\r\n');

            process.nextTick(function () {
                client.getUser.getNick.should.equal('foo_');
                st1.write(':irc.local 433 * foo_ :Nickname is already in use.\r\n');
                process.nextTick(function () {
                    client.getUser.getNick.should.equal('foo__');
                    done();
                });
            });
        });
    });
});
{'fraction_non_alphanumeric': 0.17522427944264174, 'fraction_numerical': 0.011070815041038367, 'mean_word_length': 2.095097460129947, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5798295', 'n_tokens_mistral': 1868, 'n_tokens_neox': 1625, 'n_words': 294}