2022-06-19 00:25:21 +00:00
|
|
|
import {expect} from "chai";
|
2023-01-29 16:57:27 +00:00
|
|
|
import {cleanIrcMessage} from "../../shared/irc";
|
2017-08-15 09:58:28 +00:00
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
describe("cleanIrcMessage", function () {
|
|
|
|
it("should remove all formatting", function () {
|
2019-07-17 09:33:59 +00:00
|
|
|
const testCases = [
|
|
|
|
{
|
|
|
|
input: "\x0303",
|
|
|
|
expected: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: "\x02bold",
|
|
|
|
expected: "bold",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: "\x038yellowText",
|
|
|
|
expected: "yellowText",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: "\x030,0white,white",
|
|
|
|
expected: "white,white",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: "\x034,8yellowBGredText",
|
|
|
|
expected: "yellowBGredText",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: "\x1ditalic",
|
|
|
|
expected: "italic",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: "\x1estrikethrough",
|
|
|
|
expected: "strikethrough",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: "\x11monospace",
|
|
|
|
expected: "monospace",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: "\x16reset color",
|
|
|
|
expected: "reset color",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: "\x1funderline",
|
|
|
|
expected: "underline",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: "\x02bold\x038yellow\x02nonBold\x03default",
|
|
|
|
expected: "boldyellownonBolddefault",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: "\x02bold\x02 \x02bold\x02",
|
|
|
|
expected: "bold bold",
|
|
|
|
},
|
|
|
|
{
|
2021-05-26 11:43:06 +00:00
|
|
|
input: "\x02irc\x0f://\x1dirc.example.com\x0f/\x034,8thelounge",
|
|
|
|
expected: "irc://irc.example.com/thelounge",
|
2019-07-17 09:33:59 +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
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|