2016-05-12 11:30:23 +00:00
|
|
|
"use strict";
|
|
|
|
|
2018-01-11 11:33:36 +00:00
|
|
|
const expect = require("chai").expect;
|
2016-05-12 11:30:23 +00:00
|
|
|
|
2018-01-11 11:33:36 +00:00
|
|
|
const Network = require("../../src/models/network");
|
2016-05-12 11:30:23 +00:00
|
|
|
|
2018-01-11 11:33:36 +00:00
|
|
|
const network = new Network({name: "networkName"});
|
2016-05-12 11:30:23 +00:00
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
describe("Nickname highlights", function () {
|
|
|
|
it("should NOT highlight nickname", function () {
|
2016-05-12 11:30:23 +00:00
|
|
|
network.setNick("lounge-bot");
|
|
|
|
|
|
|
|
expect("").to.not.match(network.highlightRegex);
|
|
|
|
expect(" ").to.not.match(network.highlightRegex);
|
|
|
|
expect("completely unrelated sentence").to.not.match(network.highlightRegex);
|
|
|
|
expect("foobarlounge-bot").to.not.match(network.highlightRegex);
|
|
|
|
expect("lounge-botfoobar").to.not.match(network.highlightRegex);
|
|
|
|
expect("\x03123lounge-bot").to.not.match(network.highlightRegex);
|
|
|
|
expect("lo\x0312unge-bot").to.not.match(network.highlightRegex);
|
|
|
|
expect("123lounge-bot").to.not.match(network.highlightRegex);
|
|
|
|
expect("lounge-botz").to.not.match(network.highlightRegex);
|
|
|
|
expect("lounge-bot123").to.not.match(network.highlightRegex);
|
|
|
|
expect("lounge- bot").to.not.match(network.highlightRegex);
|
|
|
|
expect("lounge_bot").to.not.match(network.highlightRegex);
|
|
|
|
expect("lounge- bot").to.not.match(network.highlightRegex);
|
|
|
|
expect("Alounge-bot").to.not.match(network.highlightRegex);
|
|
|
|
expect("lounge-botW").to.not.match(network.highlightRegex);
|
|
|
|
});
|
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
it("should highlight nickname", function () {
|
2016-05-12 11:30:23 +00:00
|
|
|
network.setNick("lounge-bot");
|
|
|
|
|
|
|
|
expect("lounge-bot").to.match(network.highlightRegex);
|
|
|
|
expect("LoUnge-Bot").to.match(network.highlightRegex);
|
|
|
|
expect("LoUnge-Bot:hello").to.match(network.highlightRegex);
|
|
|
|
expect("lounge-bot, hello").to.match(network.highlightRegex);
|
|
|
|
expect("lounge-bot: hello").to.match(network.highlightRegex);
|
|
|
|
expect("lounge-bot hello").to.match(network.highlightRegex);
|
|
|
|
expect("\x0312lounge-bot").to.match(network.highlightRegex);
|
|
|
|
expect("lounge-bot\x0312 test").to.match(network.highlightRegex);
|
|
|
|
expect("|lounge-bot").to.match(network.highlightRegex);
|
|
|
|
expect("www.lounge-bot.example.com").to.match(network.highlightRegex);
|
|
|
|
expect(" lounge-bot").to.match(network.highlightRegex);
|
|
|
|
expect("@lounge-bot").to.match(network.highlightRegex);
|
|
|
|
expect("+lounge-bot").to.match(network.highlightRegex);
|
|
|
|
expect("lounge-bot_, hey").to.match(network.highlightRegex);
|
|
|
|
expect("lounge-bot-, hey").to.match(network.highlightRegex);
|
|
|
|
expect("lounge-bot|sleep, hey").to.match(network.highlightRegex);
|
|
|
|
expect("LOUNGE-bot|sleep, hey").to.match(network.highlightRegex);
|
|
|
|
});
|
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
it("changing name should update regex", function () {
|
2016-05-12 11:30:23 +00:00
|
|
|
network.setNick("lounge-bot");
|
|
|
|
|
|
|
|
expect("lounge-bot, hello").to.match(network.highlightRegex);
|
|
|
|
expect("cool_person, hello").to.not.match(network.highlightRegex);
|
|
|
|
|
|
|
|
network.setNick("cool_person");
|
|
|
|
|
|
|
|
expect("lounge-bot, hello").to.not.match(network.highlightRegex);
|
|
|
|
expect("cool_person, hello").to.match(network.highlightRegex);
|
|
|
|
});
|
|
|
|
});
|