2018-03-11 18:17:57 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const expect = require("chai").expect;
|
|
|
|
const Helper = require("../../src/helper");
|
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
describe("Hostmask", function () {
|
|
|
|
it(".parseHostmask", function () {
|
2018-03-11 18:17:57 +00:00
|
|
|
expect(Helper.parseHostmask("nick").nick).to.equal("nick");
|
|
|
|
expect(Helper.parseHostmask("nick").ident).to.equal("*");
|
|
|
|
expect(Helper.parseHostmask("nick").hostname).to.equal("*");
|
|
|
|
|
|
|
|
expect(Helper.parseHostmask("!user").nick).to.equal("*");
|
|
|
|
expect(Helper.parseHostmask("!user").ident).to.equal("user");
|
|
|
|
expect(Helper.parseHostmask("!user").hostname).to.equal("*");
|
|
|
|
|
|
|
|
expect(Helper.parseHostmask("@host").nick).to.equal("*");
|
|
|
|
expect(Helper.parseHostmask("@host").ident).to.equal("*");
|
|
|
|
expect(Helper.parseHostmask("@host").hostname).to.equal("host");
|
|
|
|
|
|
|
|
expect(Helper.parseHostmask("!").nick).to.equal("*");
|
|
|
|
expect(Helper.parseHostmask("!").ident).to.equal("*");
|
|
|
|
expect(Helper.parseHostmask("!").hostname).to.equal("*");
|
|
|
|
|
|
|
|
expect(Helper.parseHostmask("@").nick).to.equal("*");
|
|
|
|
expect(Helper.parseHostmask("@").ident).to.equal("*");
|
|
|
|
expect(Helper.parseHostmask("@").hostname).to.equal("*");
|
|
|
|
|
|
|
|
expect(Helper.parseHostmask("!@").nick).to.equal("*");
|
|
|
|
expect(Helper.parseHostmask("!@").ident).to.equal("*");
|
|
|
|
expect(Helper.parseHostmask("!@").hostname).to.equal("*");
|
|
|
|
|
|
|
|
expect(Helper.parseHostmask("nick!user@host").nick).to.equal("nick");
|
|
|
|
expect(Helper.parseHostmask("nick!user@host").ident).to.equal("user");
|
|
|
|
expect(Helper.parseHostmask("nick!user@host").hostname).to.equal("host");
|
|
|
|
|
|
|
|
expect(Helper.parseHostmask("nick!!!!@thing@@host").nick).to.equal("nick");
|
|
|
|
expect(Helper.parseHostmask("nick!!!!@thing@@host").ident).to.equal("*");
|
|
|
|
expect(Helper.parseHostmask("nick!!!!@thing@@host").hostname).to.equal("thing");
|
|
|
|
|
|
|
|
expect(Helper.parseHostmask("!!!!@thing@@host").nick).to.equal("*");
|
|
|
|
expect(Helper.parseHostmask("!!!!@thing@@host").ident).to.equal("*");
|
|
|
|
expect(Helper.parseHostmask("!!!!@thing@@host").hostname).to.equal("thing");
|
|
|
|
|
|
|
|
expect(Helper.parseHostmask("NiCK!uSEr@HOST").nick).to.equal("nick");
|
|
|
|
expect(Helper.parseHostmask("NiCK!uSEr@HOST").ident).to.equal("user");
|
|
|
|
expect(Helper.parseHostmask("NiCK!uSEr@HOST").hostname).to.equal("host");
|
|
|
|
});
|
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
it(".compareHostmask (wildcard)", function () {
|
2018-03-11 18:17:57 +00:00
|
|
|
const a = Helper.parseHostmask("nick!user@host");
|
|
|
|
const b = Helper.parseHostmask("nick!*@*");
|
|
|
|
expect(Helper.compareHostmask(b, a)).to.be.true;
|
|
|
|
expect(Helper.compareHostmask(a, b)).to.be.false;
|
|
|
|
});
|
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
it(".compareHostmask", function () {
|
2018-03-11 18:17:57 +00:00
|
|
|
const a = Helper.parseHostmask("nick!user@host");
|
|
|
|
const b = Helper.parseHostmask("NiCK!useR@HOST");
|
|
|
|
expect(Helper.compareHostmask(b, a)).to.be.true;
|
|
|
|
expect(Helper.compareHostmask(a, b)).to.be.true;
|
|
|
|
});
|
|
|
|
});
|