Beispiel #1
0
      it("should support convenient signatures", function() {
        let m = irc.message(COMMAND.LIST);
        m.should.be.an.instanceof(irc.Message);
        m.type.should.equal(COMMAND.LIST);
        should.equal(m.from, null);
        m.params.should.eql([]);

        m = irc.message(COMMAND.JOIN, [ "#jquery" ]);
        m.should.be.an.instanceof(irc.Message);
        m.type.should.equal(COMMAND.JOIN);
        should.equal(m.from, null);
        m.params.should.eql([ "#jquery"]);

        m = irc.message(COMMAND.PRIVMSG, [ "#jquery", ": Hey" ]);
        m.should.be.an.instanceof(irc.Message);
        m.type.should.equal(COMMAND.PRIVMSG);
        should.equal(m.from, null);
        m.params.should.eql([ "#jquery", ": Hey" ]);

        m = irc.message(irc.person("lol"), COMMAND.PRIVMSG, [ "#jquery", ": Hey" ]);
        m.should.be.an.instanceof(irc.Message);
        m.type.should.equal(COMMAND.PRIVMSG);
        m.from.should.eql(irc.person("lol"));
        m.params.should.eql([ "#jquery", ": Hey" ]);
      });
Beispiel #2
0
 it("should support convenient signatures", function() {
   let p = irc.person("lol1");
   p.should.be.an.instanceof(irc.Person);
   p.nick.should.equal("lol1");
   should.not.exist(p.user);
   should.not.exist(p.host);
   p = irc.person("lol2", "omg");
   p.should.be.an.instanceof(irc.Person);
   p.nick.should.equal("lol2");
   p.user.should.equal("omg");
   should.not.exist(p.host);
   p = irc.person("lol3", "omg", "wtf");
   p.should.be.an.instanceof(irc.Person);
   p.nick.should.equal("lol3");
   p.user.should.equal("omg");
   p.host.should.equal("wtf");
 });
Beispiel #3
0
 it("should serialize into its nick, user and host", function() {
   const p = irc.person("anick", "auser", "ahost");
   p.toString().should.equal("anick!auser@ahost");
   p.user = null;
   p.toString().should.equal("anick@ahost");
   p.host = null;
   p.toString().should.equal("anick");
 });
Beispiel #4
0
 bit("should get notified", function(done) {
   const person = irc.person("gf3");
   const notice = "Important announcement";
   person.client = this;
   server.on("message", function ok(m) {
     server.removeListener("message", ok);
     m.should.equal(f("NOTICE %s :%s\r\n", person, notice));
     done();
   });
   person.notify(notice);
 });
Beispiel #5
0
 bit("should get invited to a channel, by name or Channel object", function(done) {
   const prsn = irc.person("gf3", "eh", "canada");
   const chan = irc.channel("#america");
   prsn.client = this;
   server.on("message", function ok(m) {
     server.removeListener("message", ok);
     m.should.equal(f("INVITE %s %s\r\n", prsn.nick, chan));
     done();
   });
   prsn.inviteTo(chan);
 });
Beispiel #6
0
 bit("should reply to direct messages", function(done) {
   const msg = irc.message(irc.person("gf3"), COMMAND.PRIVMSG, [this.user.nick, ":wat"]);
   msg.client = this;
   server.on("message", function ok(m) {
     if (!/PRIVMSG gf3/.test(m)) {
       return;
     }
     server.removeListener("message", ok);
     m.should.equal("PRIVMSG gf3 :Is these a bug?\r\n");
     done();
   });
   msg.reply("Is these a bug?");
 });
Beispiel #7
0
 bit("should get kicked from a channel by name", function(done) {
   const prsn = irc.person("kicked1", "ki", "ck");
   const chan = "#namekick";
   prsn.client = this;
   server.on("message", function ok(m) {
     if (!/KICK/.test(m)) {
       return;
     }
     server.removeListener("message", ok);
     m.should.equal(f("KICK %s %s\r\n", chan, prsn.nick));
     done();
   });
   prsn.kickFrom(chan);
 });
Beispiel #8
0
 bit("should invite Person objects", function(done) {
   const chan = irc.channel("#objectified");
   const user = irc.person("obj", "lol", "omg");
   chan.client = this;
   server.on("message", function ok(m) {
     if (!/INVITE/.test(m)) {
       return;
     }
     server.removeListener("message", ok);
     m.should.equal(f("INVITE %s %s\r\n", user.nick, chan));
     done();
   });
   chan.invite(user);
 });
Beispiel #9
0
 bit("should kick Person objects", function(done) {
   const chan = irc.channel("#meanies");
   const user = irc.person("victim");
   chan.client = this;
   chan.join();
   server.on("message", function ok(m) {
     if (!/KICK/.test(m)) {
       return;
     }
     server.removeListener("message", ok);
     m.should.equal(f("KICK %s %s\r\n", chan, user.nick));
     done();
   });
   chan.kick(user);
 });
Beispiel #10
0
 bit("should get kicked from a Channel object", function(done) {
   const prsn = irc.person("kicked2", "bo", "om");
   const chan = irc.channel("#objkick");
   prsn.client = this;
   chan.client = this;
   chan.join();
   server.on("message", function ok(m) {
     if (!/KICK/.test(m)) {
       return;
     }
     server.removeListener("message", ok);
     m.should.equal(f("KICK %s %s\r\n", chan.name, prsn.nick));
     done();
   });
   prsn.kickFrom(chan);
 });