2017-08-15 09:58:28 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const expect = require("chai").expect;
|
2017-09-28 08:58:43 +00:00
|
|
|
const cleanIrcMessage = require("../../../../../../client/js/libs/handlebars/ircmessageparser/cleanIrcMessage");
|
2017-08-15 09:58:28 +00:00
|
|
|
|
2017-09-28 08:58:43 +00:00
|
|
|
describe("cleanIrcMessage", function() {
|
2017-08-15 09:58:28 +00:00
|
|
|
it("should remove all formatting", function() {
|
|
|
|
const testCases = [{
|
|
|
|
input: "\x0303",
|
2017-11-15 06:35:15 +00:00
|
|
|
expected: "",
|
2017-08-15 09:58:28 +00:00
|
|
|
}, {
|
|
|
|
input: "\x02bold",
|
2017-11-15 06:35:15 +00:00
|
|
|
expected: "bold",
|
2017-08-15 09:58:28 +00:00
|
|
|
}, {
|
|
|
|
input: "\x038yellowText",
|
2017-11-15 06:35:15 +00:00
|
|
|
expected: "yellowText",
|
2017-08-15 09:58:28 +00:00
|
|
|
}, {
|
|
|
|
input: "\x030,0white,white",
|
2017-11-15 06:35:15 +00:00
|
|
|
expected: "white,white",
|
2017-08-15 09:58:28 +00:00
|
|
|
}, {
|
|
|
|
input: "\x034,8yellowBGredText",
|
2017-11-15 06:35:15 +00:00
|
|
|
expected: "yellowBGredText",
|
2017-08-15 09:58:28 +00:00
|
|
|
}, {
|
|
|
|
input: "\x1ditalic",
|
2017-11-15 06:35:15 +00:00
|
|
|
expected: "italic",
|
2017-12-08 19:09:23 +00:00
|
|
|
}, {
|
|
|
|
input: "\x1estrikethrough",
|
|
|
|
expected: "strikethrough",
|
|
|
|
}, {
|
|
|
|
input: "\x11monospace",
|
|
|
|
expected: "monospace",
|
|
|
|
}, {
|
|
|
|
input: "\x16reset color",
|
|
|
|
expected: "reset color",
|
2017-08-15 09:58:28 +00:00
|
|
|
}, {
|
|
|
|
input: "\x1funderline",
|
2017-11-15 06:35:15 +00:00
|
|
|
expected: "underline",
|
2017-08-15 09:58:28 +00:00
|
|
|
}, {
|
|
|
|
input: "\x02bold\x038yellow\x02nonBold\x03default",
|
2017-11-15 06:35:15 +00:00
|
|
|
expected: "boldyellownonBolddefault",
|
2017-08-15 09:58:28 +00:00
|
|
|
}, {
|
|
|
|
input: "\x02bold\x02 \x02bold\x02",
|
2017-11-15 06:35:15 +00:00
|
|
|
expected: "bold bold",
|
2017-08-15 09:58:28 +00:00
|
|
|
}, {
|
|
|
|
input: "\x02irc\x0f://\x1dfreenode.net\x0f/\x034,8thelounge",
|
2017-11-15 06:35:15 +00:00
|
|
|
expected: "irc://freenode.net/thelounge",
|
2017-08-15 09:58:28 +00:00
|
|
|
}, {
|
|
|
|
input: "\x02#\x038,9thelounge",
|
2017-11-15 06:35:15 +00:00
|
|
|
expected: "#thelounge",
|
2017-11-22 14:03:59 +00:00
|
|
|
}, {
|
|
|
|
input: "\x04DDEEAA,BBEEFF#\x038,9thelou\x04FFAACC\x0311\x04nge",
|
|
|
|
expected: "#thelounge",
|
|
|
|
}, {
|
|
|
|
input: "\x04ddEEffhex\x04 color\x04EEffCC,AAaaCC clean",
|
|
|
|
expected: "hex color clean",
|
|
|
|
}, {
|
|
|
|
input: "\x04 AAaaAA\x03 11 \x04Invalid,Hex ",
|
|
|
|
expected: "AAaaAA 11 Invalid,Hex",
|
2017-08-15 09:58:28 +00:00
|
|
|
}];
|
|
|
|
|
2017-09-28 08:58:43 +00:00
|
|
|
const actual = testCases.map((testCase) => cleanIrcMessage(testCase.input));
|
2017-08-15 09:58:28 +00:00
|
|
|
const expected = testCases.map((testCase) => testCase.expected);
|
|
|
|
|
|
|
|
expect(actual).to.deep.equal(expected);
|
|
|
|
});
|
|
|
|
});
|