hardlounge/test/client/js/libs/handlebars/ircmessageparser/cleanIrcMessage.js

58 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-08-15 09:58:28 +00:00
"use strict";
const expect = require("chai").expect;
const cleanIrcMessage = require("../../../../../../client/js/libs/handlebars/ircmessageparser/cleanIrcMessage");
2017-08-15 09:58:28 +00:00
describe("cleanIrcMessage", function() {
2017-08-15 09:58:28 +00:00
it("should remove all formatting", function() {
const testCases = [{
input: "\x0303",
expected: "",
2017-08-15 09:58:28 +00:00
}, {
input: "\x02bold",
expected: "bold",
2017-08-15 09:58:28 +00:00
}, {
input: "\x038yellowText",
expected: "yellowText",
2017-08-15 09:58:28 +00:00
}, {
input: "\x030,0white,white",
expected: "white,white",
2017-08-15 09:58:28 +00:00
}, {
input: "\x034,8yellowBGredText",
expected: "yellowBGredText",
2017-08-15 09:58:28 +00:00
}, {
input: "\x1ditalic",
expected: "italic",
2017-08-15 09:58:28 +00:00
}, {
input: "\x1funderline",
expected: "underline",
2017-08-15 09:58:28 +00:00
}, {
input: "\x02bold\x038yellow\x02nonBold\x03default",
expected: "boldyellownonBolddefault",
2017-08-15 09:58:28 +00:00
}, {
input: "\x02bold\x02 \x02bold\x02",
expected: "bold bold",
2017-08-15 09:58:28 +00:00
}, {
input: "\x02irc\x0f://\x1dfreenode.net\x0f/\x034,8thelounge",
expected: "irc://freenode.net/thelounge",
2017-08-15 09:58:28 +00:00
}, {
input: "\x02#\x038,9thelounge",
expected: "#thelounge",
}, {
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
}];
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);
});
});