Add nick highlight tests
This commit is contained in:
parent
aa8c3f6419
commit
8a7d1e880b
@ -10,6 +10,7 @@ describe("Network", function() {
|
||||
|
||||
it("should produce an valid object", function() {
|
||||
var network = new Network({name: "networkName"});
|
||||
network.setNick("chillin`");
|
||||
network.channels.push(new Chan({name: "#thelounge"}));
|
||||
network.channels.push(new Chan({name: "&foobar"}));
|
||||
|
||||
@ -22,7 +23,7 @@ describe("Network", function() {
|
||||
username: "",
|
||||
realname: "",
|
||||
commands: [],
|
||||
nick: "",
|
||||
nick: "chillin`",
|
||||
join: "#thelounge,&foobar",
|
||||
ip: null,
|
||||
hostname: null
|
||||
|
63
test/tests/nickhighlights.js
Normal file
63
test/tests/nickhighlights.js
Normal file
@ -0,0 +1,63 @@
|
||||
"use strict";
|
||||
|
||||
var expect = require("chai").expect;
|
||||
|
||||
var Network = require("../../src/models/network");
|
||||
|
||||
var network = new Network({name: "networkName"});
|
||||
|
||||
describe("Nickname highlights", function() {
|
||||
it("should NOT highlight nickname", function() {
|
||||
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);
|
||||
});
|
||||
|
||||
it("should highlight nickname", function() {
|
||||
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);
|
||||
});
|
||||
|
||||
it("changing name should update regex", function() {
|
||||
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);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user