thelounge/test/tests/cleanircmessages.js

49 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-08-15 11:58:28 +02:00
"use strict";
const expect = require("chai").expect;
const Helper = require("../../src/helper");
describe("Clean IRC messages", function() {
it("should remove all formatting", function() {
const testCases = [{
input: "\x0303",
expected: "",
2017-08-15 11:58:28 +02:00
}, {
input: "\x02bold",
expected: "bold",
2017-08-15 11:58:28 +02:00
}, {
input: "\x038yellowText",
expected: "yellowText",
2017-08-15 11:58:28 +02:00
}, {
input: "\x030,0white,white",
expected: "white,white",
2017-08-15 11:58:28 +02:00
}, {
input: "\x034,8yellowBGredText",
expected: "yellowBGredText",
2017-08-15 11:58:28 +02:00
}, {
input: "\x1ditalic",
expected: "italic",
2017-08-15 11:58:28 +02:00
}, {
input: "\x1funderline",
expected: "underline",
2017-08-15 11:58:28 +02:00
}, {
input: "\x02bold\x038yellow\x02nonBold\x03default",
expected: "boldyellownonBolddefault",
2017-08-15 11:58:28 +02:00
}, {
input: "\x02bold\x02 \x02bold\x02",
expected: "bold bold",
2017-08-15 11:58:28 +02:00
}, {
input: "\x02irc\x0f://\x1dfreenode.net\x0f/\x034,8thelounge",
expected: "irc://freenode.net/thelounge",
2017-08-15 11:58:28 +02:00
}, {
input: "\x02#\x038,9thelounge",
expected: "#thelounge",
2017-08-15 11:58:28 +02:00
}];
const actual = testCases.map((testCase) => Helper.cleanIrcMessage(testCase.input));
const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected);
});
});