mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-08 08:42:17 +02:00
[ts-migrate][client] Run TS Migrate
Co-authored-by: ts-migrate <>
This commit is contained in:
parent
a4b0a1daa1
commit
1560b07f36
|
@ -1,6 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
// Recursively load all JS files (test files) in the `js` folder
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'context' does not exist on type 'NodeReq... Remove this comment to see the full error message
|
||||
const context = require.context("./js", true, /.+\.js$/);
|
||||
context.keys().forEach(context);
|
||||
|
||||
|
|
|
@ -1,30 +1,43 @@
|
|||
"use strict";
|
||||
|
||||
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'expect'.
|
||||
const expect = require("chai").expect;
|
||||
const stub = require("sinon").stub;
|
||||
const Auth = require("../../../client/js/auth").default;
|
||||
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'localStora... Remove this comment to see the full error message
|
||||
const localStorage = require("../../../client/js/localStorage").default;
|
||||
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'location'.
|
||||
const location = require("../../../client/js/location").default;
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe("Auth", function () {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe(".signout", function () {
|
||||
// @ts-expect-error ts-migrate(2304) FIXME: Cannot find name 'beforeEach'.
|
||||
beforeEach(function () {
|
||||
stub(localStorage, "clear");
|
||||
stub(location, "reload");
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2304) FIXME: Cannot find name 'afterEach'.
|
||||
afterEach(function () {
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'restore' does not exist on type '() => v... Remove this comment to see the full error message
|
||||
localStorage.clear.restore();
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'restore' does not exist on type '{ (): v... Remove this comment to see the full error message
|
||||
location.reload.restore();
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should empty the local storage", function () {
|
||||
Auth.signout();
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'calledOnce' does not exist on type '() =... Remove this comment to see the full error message
|
||||
expect(localStorage.clear.calledOnce).to.be.true;
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should reload the page", function () {
|
||||
Auth.signout();
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'calledOnce' does not exist on type '{ ()... Remove this comment to see the full error message
|
||||
expect(location.reload.calledOnce).to.be.true;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,15 +1,21 @@
|
|||
"use strict";
|
||||
|
||||
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'expect'.
|
||||
const expect = require("chai").expect;
|
||||
const constants = require("../../../client/js/constants");
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe("client-side constants", function () {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe(".colorCodeMap", function () {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should be a non-empty array", function () {
|
||||
expect(constants.colorCodeMap).to.be.an("array").of.length(16);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should be made of pairs of strings", function () {
|
||||
// @ts-expect-error ts-migrate(7031) FIXME: Binding element 'code' implicitly has an 'any' typ... Remove this comment to see the full error message
|
||||
constants.colorCodeMap.forEach(([code, name]) => {
|
||||
expect(code)
|
||||
.to.be.a("string")
|
||||
|
@ -19,19 +25,25 @@ describe("client-side constants", function () {
|
|||
});
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe(".condensedTypes", function () {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should be a non-empty array", function () {
|
||||
expect(constants.condensedTypes).to.be.an.instanceof(Set).that.is.not.empty;
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should only contain ASCII strings", function () {
|
||||
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'type' implicitly has an 'any' type.
|
||||
constants.condensedTypes.forEach((type) => {
|
||||
expect(type).to.be.a("string").that.does.match(/^\w+$/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe(".timeFormats", function () {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should be objects of strings", function () {
|
||||
expect(constants.timeFormats.msgDefault).to.be.an("string").that.is.not.empty;
|
||||
expect(constants.timeFormats.msgWithSeconds).to.be.an("string").that.is.not.empty;
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'expect'.
|
||||
const expect = require("chai").expect;
|
||||
const friendlysize = require("../../../../client/js/helpers/friendlysize").default;
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe("friendlysize helper", function () {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should render human-readable version", function () {
|
||||
expect(friendlysize(51200)).to.equal("50 KiB");
|
||||
expect(friendlysize(2)).to.equal("2 Bytes");
|
||||
|
@ -15,14 +18,17 @@ describe("friendlysize helper", function () {
|
|||
expect(friendlysize(Math.pow(1024, 5))).to.equal("1 PiB");
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should round with 1 digit", function () {
|
||||
expect(friendlysize(1234567)).to.equal("1.2 MiB");
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should render special case 0 as 0 Bytes", function () {
|
||||
expect(friendlysize(0)).to.equal("0 Bytes");
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should render max safe integer as petabytes", function () {
|
||||
expect(friendlysize(Number.MAX_SAFE_INTEGER)).to.equal("8 PiB");
|
||||
});
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
"use strict";
|
||||
|
||||
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'expect'.
|
||||
const expect = require("chai").expect;
|
||||
const anyIntersection =
|
||||
require("../../../../../client/js/helpers/ircmessageparser/anyIntersection").default;
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe("anyIntersection", () => {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not intersect on edges", () => {
|
||||
const a = {start: 1, end: 2};
|
||||
const b = {start: 2, end: 3};
|
||||
|
@ -13,6 +16,7 @@ describe("anyIntersection", () => {
|
|||
expect(anyIntersection(b, a)).to.equal(false);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should intersect on overlapping", () => {
|
||||
const a = {start: 0, end: 3};
|
||||
const b = {start: 1, end: 2};
|
||||
|
@ -21,6 +25,7 @@ describe("anyIntersection", () => {
|
|||
expect(anyIntersection(b, a)).to.equal(true);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not intersect", () => {
|
||||
const a = {start: 0, end: 1};
|
||||
const b = {start: 2, end: 3};
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'expect'.
|
||||
const expect = require("chai").expect;
|
||||
const cleanIrcMessage = require("../../../../../client/js/helpers/ircmessageparser/cleanIrcMessage");
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe("cleanIrcMessage", function () {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should remove all formatting", function () {
|
||||
const testCases = [
|
||||
{
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
"use strict";
|
||||
|
||||
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'expect'.
|
||||
const expect = require("chai").expect;
|
||||
const fill = require("../../../../../client/js/helpers/ircmessageparser/fill").default;
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe("fill", () => {
|
||||
const text = "01234567890123456789";
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should return an entry for the unmatched end of string", () => {
|
||||
const existingEntries = [
|
||||
{start: 0, end: 10},
|
||||
|
@ -19,6 +22,7 @@ describe("fill", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should return an entry per unmatched areas of the text", () => {
|
||||
const existingEntries = [
|
||||
{start: 0, end: 5},
|
||||
|
@ -35,6 +39,7 @@ describe("fill", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not return anything when entries match all text", () => {
|
||||
const existingEntries = [
|
||||
{start: 0, end: 10},
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
"use strict";
|
||||
|
||||
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'expect'.
|
||||
const expect = require("chai").expect;
|
||||
const findChannels =
|
||||
require("../../../../../client/js/helpers/ircmessageparser/findChannels").default;
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe("findChannels", () => {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find single letter channel", () => {
|
||||
const input = "#a";
|
||||
const expected = [
|
||||
|
@ -20,6 +23,7 @@ describe("findChannels", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find utf8 channels", () => {
|
||||
const input = "#äöü";
|
||||
const expected = [
|
||||
|
@ -35,6 +39,7 @@ describe("findChannels", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find inline channel", () => {
|
||||
const input = "inline #channel text";
|
||||
const expected = [
|
||||
|
@ -50,6 +55,7 @@ describe("findChannels", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should stop at \\0x07", () => {
|
||||
const input = "#chan\x07nel";
|
||||
const expected = [
|
||||
|
@ -65,6 +71,7 @@ describe("findChannels", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should allow classics pranks", () => {
|
||||
const input = "#1,000";
|
||||
const expected = [
|
||||
|
@ -80,6 +87,7 @@ describe("findChannels", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should work with whois responses", () => {
|
||||
const input = "@#a";
|
||||
const expected = [
|
||||
|
@ -95,6 +103,7 @@ describe("findChannels", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should work with IRCv3.1 multi-prefix", () => {
|
||||
const input = "!@%+#a";
|
||||
const expected = [
|
||||
|
@ -110,6 +119,7 @@ describe("findChannels", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should work with custom channelPrefixes", () => {
|
||||
const input = "@a";
|
||||
const expected = [
|
||||
|
@ -125,6 +135,7 @@ describe("findChannels", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should handle multiple channelPrefix correctly", () => {
|
||||
const input = "##test";
|
||||
const expected = [
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'expect'.
|
||||
const expect = require("chai").expect;
|
||||
const findEmoji = require("../../../../../client/js/helpers/ircmessageparser/findEmoji").default;
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe("findEmoji", () => {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find default emoji presentation character", () => {
|
||||
const input = "test \u{231A} test";
|
||||
const expected = [
|
||||
|
@ -19,6 +22,7 @@ describe("findEmoji", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find default text presentation character rendered as emoji", () => {
|
||||
const input = "test \u{2194}\u{FE0F} test";
|
||||
const expected = [
|
||||
|
@ -34,6 +38,7 @@ describe("findEmoji", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find emoji modifier base", () => {
|
||||
const input = "test\u{1F469}test";
|
||||
const expected = [
|
||||
|
@ -49,6 +54,7 @@ describe("findEmoji", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find emoji modifier base followed by a modifier", () => {
|
||||
const input = "test\u{1F469}\u{1F3FF}test";
|
||||
const expected = [
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
"use strict";
|
||||
|
||||
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'expect'.
|
||||
const expect = require("chai").expect;
|
||||
const {
|
||||
findLinks,
|
||||
findLinksWithSchema,
|
||||
} = require("../../../../../client/js/helpers/ircmessageparser/findLinks");
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe("findLinks", () => {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find url", () => {
|
||||
const input = "irc://irc.example.com/thelounge";
|
||||
const expected = [
|
||||
|
@ -22,6 +25,7 @@ describe("findLinks", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find urls with www", () => {
|
||||
const input = "www.nooooooooooooooo.com";
|
||||
const expected = [
|
||||
|
@ -37,6 +41,7 @@ describe("findLinks", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find urls in strings", () => {
|
||||
const input = "look at https://thelounge.chat/ for more information";
|
||||
const expected = [
|
||||
|
@ -52,6 +57,7 @@ describe("findLinks", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find urls in strings starting with www", () => {
|
||||
const input = "use www.duckduckgo.com for privacy reasons";
|
||||
const expected = [
|
||||
|
@ -67,6 +73,7 @@ describe("findLinks", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find urls with odd surroundings", () => {
|
||||
const input = "<https://theos.kyriasis.com/~kyrias/stats/archlinux.html>";
|
||||
const expected = [
|
||||
|
@ -82,6 +89,7 @@ describe("findLinks", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find urls with starting with http:// and odd surroundings", () => {
|
||||
const input = ".:http://www.github.com:. .:www.github.com:.";
|
||||
const expected = [
|
||||
|
@ -97,15 +105,19 @@ describe("findLinks", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not find urls", () => {
|
||||
const input = "text www. text";
|
||||
// @ts-expect-error ts-migrate(7034) FIXME: Variable 'expected' implicitly has type 'any[]' in... Remove this comment to see the full error message
|
||||
const expected = [];
|
||||
|
||||
const actual = findLinks(input);
|
||||
|
||||
// @ts-expect-error ts-migrate(7005) FIXME: Variable 'expected' implicitly has an 'any[]' type... Remove this comment to see the full error message
|
||||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should handle multiple www. correctly", () => {
|
||||
const input = "www.www.test.com";
|
||||
const expected = [
|
||||
|
@ -121,6 +133,7 @@ describe("findLinks", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find domains without www. but valid tld", () => {
|
||||
const input = "google.com google.lv google.museum";
|
||||
const expected = [
|
||||
|
@ -146,6 +159,7 @@ describe("findLinks", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find .onion domains", () => {
|
||||
const input = "facebookcorewwwi.onion/test?url";
|
||||
const expected = [
|
||||
|
@ -161,15 +175,19 @@ describe("findLinks", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not consider invalid TLDs as domains", () => {
|
||||
const input = "google.wtfgugl google.xx www.google.wtfgugl www.google.xx";
|
||||
// @ts-expect-error ts-migrate(7034) FIXME: Variable 'expected' implicitly has type 'any[]' in... Remove this comment to see the full error message
|
||||
const expected = [];
|
||||
|
||||
const actual = findLinks(input);
|
||||
|
||||
// @ts-expect-error ts-migrate(7005) FIXME: Variable 'expected' implicitly has an 'any[]' type... Remove this comment to see the full error message
|
||||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should consider invalid TLDs as domains if protocol is specified", () => {
|
||||
const input =
|
||||
"http://google.wtfgugl http://google.xx http://www.google.wtfgugl http://www.google.xx";
|
||||
|
@ -201,6 +219,7 @@ describe("findLinks", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should correctly stop at punctuation", () => {
|
||||
// Issue #2351
|
||||
const input =
|
||||
|
@ -260,6 +279,7 @@ describe("findLinks", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should correctly stop at apostrophe", () => {
|
||||
const input = "https://www.google.com's www.google.com's google.com's"; // Issue #1302
|
||||
const expected = [
|
||||
|
@ -285,6 +305,7 @@ describe("findLinks", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("does not find invalid urls", () => {
|
||||
const input = "www.example.com ssh://-oProxyCommand=whois"; // Issue #1412
|
||||
const expected = [
|
||||
|
@ -318,6 +339,7 @@ describe("findLinks", () => {
|
|||
expect(actual2).to.deep.equal(expected2);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("keeps parsing after finding an invalid url", () => {
|
||||
const input = "www.example.com http://a:%p@c http://thelounge.chat";
|
||||
const expected = [
|
||||
|
@ -343,6 +365,7 @@ describe("findLinks", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should add protocol to protocol-aware urls", () => {
|
||||
const input = "//example.com";
|
||||
const expected = [
|
||||
|
@ -358,6 +381,7 @@ describe("findLinks", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not return urls with no schema if flag is specified", () => {
|
||||
const input = "https://example.global //example.com http://example.group example.py";
|
||||
const expected = [
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'expect'.
|
||||
const expect = require("chai").expect;
|
||||
const findNames = require("../../../../../client/js/helpers/ircmessageparser/findNames").default;
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe("findNames", () => {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find nicks in text", () => {
|
||||
const input = "<MaxLeiter>: Hello, xPaw, how's it going?";
|
||||
const expected = [
|
||||
|
@ -24,6 +27,7 @@ describe("findNames", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not find nicks as part of a bigger string (issue #1776)", () => {
|
||||
const input = "you're very unlucky, luck";
|
||||
const expected = [
|
||||
|
@ -39,6 +43,7 @@ describe("findNames", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find nicks as short as one character (issue #1885)", () => {
|
||||
const input = "aaa aa abc a";
|
||||
const expected = [
|
||||
|
@ -54,6 +59,7 @@ describe("findNames", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find same nick multiple times", () => {
|
||||
const input = "xPaw xPaw xPaw";
|
||||
const expected = [
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'expect'.
|
||||
const expect = require("chai").expect;
|
||||
const merge = require("../../../../../client/js/helpers/ircmessageparser/merge").default;
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe("merge", () => {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should split style information", () => {
|
||||
const textParts = [
|
||||
{
|
||||
|
@ -81,6 +84,7 @@ describe("merge", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not drop clean text", () => {
|
||||
const textParts = [
|
||||
{
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'expect'.
|
||||
const expect = require("chai").expect;
|
||||
const parseStyle = require("../../../../../client/js/helpers/ircmessageparser/parseStyle").default;
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe("parseStyle", () => {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should replace control codes", () => {
|
||||
const input = "text\x01with\x04control\x05codes";
|
||||
const expected = [
|
||||
|
@ -29,6 +32,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should parse bold", () => {
|
||||
const input = "\x02bold";
|
||||
const expected = [
|
||||
|
@ -54,6 +58,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should parse strikethrough", () => {
|
||||
const input = "\x1estrikethrough text\x1e";
|
||||
const expected = [
|
||||
|
@ -79,6 +84,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should parse monospace", () => {
|
||||
const input = "\x11monospace text\x1e";
|
||||
const expected = [
|
||||
|
@ -104,6 +110,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should toggle monospace correctly", () => {
|
||||
const input = "toggling \x11on and \x11off and \x11on again\x11";
|
||||
const expected = [
|
||||
|
@ -174,6 +181,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should parse monospace and underline", () => {
|
||||
const input =
|
||||
"\x1funderline formatting \x11with monospace\x1f no underline \x11 and vanilla";
|
||||
|
@ -245,6 +253,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should parse monospace and text colors", () => {
|
||||
const input = "\x037,9\x11text with color and monospace\x11\x03";
|
||||
const expected = [
|
||||
|
@ -270,6 +279,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should parse strikethrough and italics", () => {
|
||||
const input = "\x1ditalic formatting \x1ewith strikethrough\x1d no italic \x1e and vanilla";
|
||||
const expected = [
|
||||
|
@ -340,6 +350,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should parse strikethrough and text colors", () => {
|
||||
const input = "\x031,2text with color \x1eand strikethrough\x1e\x03";
|
||||
const expected = [
|
||||
|
@ -380,6 +391,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should correctly parse multiple unclosed format tokens", () => {
|
||||
const input = "\x1e\x02\x1d\x033,4string with multiple unclosed formats";
|
||||
const expected = [
|
||||
|
@ -405,6 +417,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should toggle strikethrough correctly", () => {
|
||||
const input = "toggling \x1eon and \x1eoff and \x1eon again\x1e";
|
||||
const expected = [
|
||||
|
@ -475,6 +488,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should parse textColor", () => {
|
||||
const input = "\x038yellowText";
|
||||
const expected = [
|
||||
|
@ -500,6 +514,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should parse textColor and background", () => {
|
||||
const input = "\x034,8yellowBG redText";
|
||||
const expected = [
|
||||
|
@ -525,6 +540,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should parse extended colors", () => {
|
||||
const input = "\x0370,99some text";
|
||||
const expected = [
|
||||
|
@ -550,6 +566,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should parse italic", () => {
|
||||
const input = "\x1ditalic";
|
||||
const expected = [
|
||||
|
@ -575,6 +592,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should parse hex colors", () => {
|
||||
const input =
|
||||
"test \x04FFFFFFnice \x02\x04RES006 \x0303,04\x04ff00FFcolored\x04eeeaFF,001122 background\x04\x03\x02?";
|
||||
|
@ -676,6 +694,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should reverse and format color", () => {
|
||||
const input = "\x032,9text with fg and bg \x16with text reversed";
|
||||
const expected = [
|
||||
|
@ -716,6 +735,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should toggle reverse correctly", () => {
|
||||
const input = "\x0305,11text \x16reversed and \x16back again and \x16reversed";
|
||||
const expected = [
|
||||
|
@ -786,6 +806,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should escape reverse when a new style is applied", () => {
|
||||
const input = "\x0311,02text \x16 reversed \x0304,05 and new style";
|
||||
const expected = [
|
||||
|
@ -841,6 +862,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not reverse if color is specified after reverse tag", () => {
|
||||
const input = "\x16\x032,9text with fg and bg";
|
||||
const expected = [
|
||||
|
@ -866,6 +888,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should reverse, bold, and italics", () => {
|
||||
const input = "\x034,13\x16\x02some text with \x1ditalics";
|
||||
const expected = [
|
||||
|
@ -906,6 +929,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should carry state correctly forward", () => {
|
||||
const input = "\x02bold\x038yellow\x02nonBold\x03default";
|
||||
const expected = [
|
||||
|
@ -976,6 +1000,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should toggle bold correctly", () => {
|
||||
const input = "\x02bold\x02 \x02bold\x02";
|
||||
const expected = [
|
||||
|
@ -1031,6 +1056,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should reset all styles", () => {
|
||||
const input = "\x11\x1e\x02\x034\x16\x1d\x1ffull\x0fnone";
|
||||
const expected = [
|
||||
|
@ -1071,6 +1097,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not emit empty fragments", () => {
|
||||
const input = "\x031\x031,2\x031\x031,2\x031\x031,2\x03a";
|
||||
const expected = [
|
||||
|
@ -1096,6 +1123,7 @@ describe("parseStyle", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should optimize fragments", () => {
|
||||
const rawString = "oh hi test text";
|
||||
const colorCode = "\x0312";
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'expect'.
|
||||
const expect = require("chai").expect;
|
||||
const localetime = require("../../../../client/js/helpers/localetime").default;
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe("localetime helper", () => {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should render a human-readable date", () => {
|
||||
// 12PM in UTC time
|
||||
const date = new Date("2014-05-22T12:00:00Z");
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
const expect = require("chai").expect;
|
||||
|
||||
import {renderToString} from "@vue/server-test-utils";
|
||||
// @ts-expect-error ts-migrate(2307) FIXME: Cannot find module '../../components/ParsedMessage... Remove this comment to see the full error message
|
||||
import ParsedMessageTestWrapper from "../../components/ParsedMessageTestWrapper.vue";
|
||||
|
||||
async function getParsedMessageContents(text, message) {
|
||||
async function getParsedMessageContents(text: any, message: any) {
|
||||
let contents = await renderToString(ParsedMessageTestWrapper, {
|
||||
propsData: {
|
||||
text,
|
||||
|
@ -19,7 +20,9 @@ async function getParsedMessageContents(text, message) {
|
|||
return contents;
|
||||
}
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe("IRC formatted message parser", () => {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not introduce xss", async () => {
|
||||
const testCases = [
|
||||
{
|
||||
|
@ -35,6 +38,7 @@ describe("IRC formatted message parser", () => {
|
|||
];
|
||||
|
||||
const actual = await Promise.all(
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
testCases.map((testCase) => getParsedMessageContents(testCase.input))
|
||||
);
|
||||
const expected = testCases.map((testCase) => testCase.expected);
|
||||
|
@ -42,6 +46,7 @@ describe("IRC formatted message parser", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should skip all <32 ASCII codes except linefeed", async () => {
|
||||
const testCases = [
|
||||
{
|
||||
|
@ -52,6 +57,7 @@ describe("IRC formatted message parser", () => {
|
|||
];
|
||||
|
||||
const actual = await Promise.all(
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
testCases.map((testCase) => getParsedMessageContents(testCase.input))
|
||||
);
|
||||
const expected = testCases.map((testCase) => testCase.expected);
|
||||
|
@ -59,6 +65,7 @@ describe("IRC formatted message parser", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find urls", async () => {
|
||||
const testCases = [
|
||||
{
|
||||
|
@ -103,6 +110,7 @@ describe("IRC formatted message parser", () => {
|
|||
];
|
||||
|
||||
const actual = await Promise.all(
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
testCases.map((testCase) => getParsedMessageContents(testCase.input))
|
||||
);
|
||||
const expected = testCases.map((testCase) => testCase.expected);
|
||||
|
@ -110,6 +118,7 @@ describe("IRC formatted message parser", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("url with a dot parsed correctly", async () => {
|
||||
const input =
|
||||
"bonuspunkt: your URL parser misparses this URL: https://msdn.microsoft.com/en-us/library/windows/desktop/ms644989(v=vs.85).aspx";
|
||||
|
@ -119,11 +128,13 @@ describe("IRC formatted message parser", () => {
|
|||
"https://msdn.microsoft.com/en-us/library/windows/desktop/ms644989(v=vs.85).aspx" +
|
||||
"</a>";
|
||||
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
const actual = await getParsedMessageContents(input);
|
||||
|
||||
expect(actual).to.deep.equal(correctResult);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should balance brackets", async () => {
|
||||
const testCases = [
|
||||
{
|
||||
|
@ -161,6 +172,7 @@ describe("IRC formatted message parser", () => {
|
|||
];
|
||||
|
||||
const actual = await Promise.all(
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
testCases.map((testCase) => getParsedMessageContents(testCase.input))
|
||||
);
|
||||
const expected = testCases.map((testCase) => testCase.expected);
|
||||
|
@ -168,6 +180,7 @@ describe("IRC formatted message parser", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not find urls", async () => {
|
||||
const testCases = [
|
||||
{
|
||||
|
@ -181,6 +194,7 @@ describe("IRC formatted message parser", () => {
|
|||
];
|
||||
|
||||
const actual = await Promise.all(
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
testCases.map((testCase) => getParsedMessageContents(testCase.input))
|
||||
);
|
||||
const expected = testCases.map((testCase) => testCase.expected);
|
||||
|
@ -188,6 +202,7 @@ describe("IRC formatted message parser", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find channels", async () => {
|
||||
const testCases = [
|
||||
{
|
||||
|
@ -238,6 +253,7 @@ describe("IRC formatted message parser", () => {
|
|||
];
|
||||
|
||||
const actual = await Promise.all(
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
testCases.map((testCase) => getParsedMessageContents(testCase.input))
|
||||
);
|
||||
const expected = testCases.map((testCase) => testCase.expected);
|
||||
|
@ -245,6 +261,7 @@ describe("IRC formatted message parser", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not find channels", async () => {
|
||||
const testCases = [
|
||||
{
|
||||
|
@ -258,6 +275,7 @@ describe("IRC formatted message parser", () => {
|
|||
];
|
||||
|
||||
const actual = await Promise.all(
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
testCases.map((testCase) => getParsedMessageContents(testCase.input))
|
||||
);
|
||||
const expected = testCases.map((testCase) => testCase.expected);
|
||||
|
@ -356,11 +374,14 @@ describe("IRC formatted message parser", () => {
|
|||
'<span class="irc-bold">bold</span>' + " " + '<span class="irc-bold">bold</span>',
|
||||
},
|
||||
].forEach(({name, input, expected}) => {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it(`should handle style characters: ${name}`, async () => {
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
expect(await getParsedMessageContents(input)).to.equal(expected);
|
||||
});
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find nicks", async () => {
|
||||
const testCases = [
|
||||
{
|
||||
|
@ -384,6 +405,7 @@ describe("IRC formatted message parser", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not find nicks", async () => {
|
||||
const testCases = [
|
||||
{
|
||||
|
@ -405,6 +427,7 @@ describe("IRC formatted message parser", () => {
|
|||
];
|
||||
|
||||
const actual = await Promise.all(
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
testCases.map((testCase) => getParsedMessageContents(testCase.input))
|
||||
);
|
||||
const expected = testCases.map((testCase) => testCase.expected);
|
||||
|
@ -412,6 +435,7 @@ describe("IRC formatted message parser", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should go bonkers like mirc", async () => {
|
||||
const testCases = [
|
||||
{
|
||||
|
@ -436,6 +460,7 @@ describe("IRC formatted message parser", () => {
|
|||
];
|
||||
|
||||
const actual = await Promise.all(
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
testCases.map((testCase) => getParsedMessageContents(testCase.input))
|
||||
);
|
||||
const expected = testCases.map((testCase) => testCase.expected);
|
||||
|
@ -512,11 +537,14 @@ describe("IRC formatted message parser", () => {
|
|||
'<span dir="auto" role="button" tabindex="0" class="inline-channel">#i❤️thelounge</span>',
|
||||
},
|
||||
].forEach(({name, input, expected}) => {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it(`should find emoji: ${name}`, async () => {
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
expect(await getParsedMessageContents(input)).to.equal(expected);
|
||||
});
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should optimize generated html", async () => {
|
||||
const testCases = [
|
||||
{
|
||||
|
@ -530,6 +558,7 @@ describe("IRC formatted message parser", () => {
|
|||
];
|
||||
|
||||
const actual = await Promise.all(
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
testCases.map((testCase) => getParsedMessageContents(testCase.input))
|
||||
);
|
||||
const expected = testCases.map((testCase) => testCase.expected);
|
||||
|
@ -537,6 +566,7 @@ describe("IRC formatted message parser", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should trim common protocols", async () => {
|
||||
const testCases = [
|
||||
{
|
||||
|
@ -558,6 +588,7 @@ describe("IRC formatted message parser", () => {
|
|||
];
|
||||
|
||||
const actual = await Promise.all(
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
testCases.map((testCase) => getParsedMessageContents(testCase.input))
|
||||
);
|
||||
const expected = testCases.map((testCase) => testCase.expected);
|
||||
|
@ -565,6 +596,7 @@ describe("IRC formatted message parser", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not find channel in fragment", async () => {
|
||||
const testCases = [
|
||||
{
|
||||
|
@ -577,6 +609,7 @@ describe("IRC formatted message parser", () => {
|
|||
];
|
||||
|
||||
const actual = await Promise.all(
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
testCases.map((testCase) => getParsedMessageContents(testCase.input))
|
||||
);
|
||||
const expected = testCases.map((testCase) => testCase.expected);
|
||||
|
@ -584,8 +617,10 @@ describe("IRC formatted message parser", () => {
|
|||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not overlap parts", async () => {
|
||||
const input = "Url: http://example.com/path Channel: ##channel";
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
const actual = await getParsedMessageContents(input);
|
||||
|
||||
expect(actual).to.equal(
|
||||
|
@ -594,8 +629,10 @@ describe("IRC formatted message parser", () => {
|
|||
);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should handle overlapping parts by using first starting", async () => {
|
||||
const input = "#test-https://example.com";
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
const actual = await getParsedMessageContents(input);
|
||||
|
||||
expect(actual).to.equal(
|
||||
|
@ -605,8 +642,10 @@ describe("IRC formatted message parser", () => {
|
|||
);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should find links separated by tab character", async () => {
|
||||
const input = "example.com\texample.org";
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
const actual = await getParsedMessageContents(input);
|
||||
|
||||
expect(actual).to.equal(
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'expect'.
|
||||
const expect = require("chai").expect;
|
||||
const parseIrcUri = require("../../../../client/js/helpers/parseIrcUri").default;
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe("parseIrcUri helper", function () {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should parse irc:// without port", function () {
|
||||
expect(parseIrcUri("irc://example.com")).to.deep.equal({
|
||||
tls: false,
|
||||
|
@ -14,6 +17,7 @@ describe("parseIrcUri helper", function () {
|
|||
});
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should parse ircs:// without port", function () {
|
||||
expect(parseIrcUri("ircs://example.com")).to.deep.equal({
|
||||
tls: true,
|
||||
|
@ -24,6 +28,7 @@ describe("parseIrcUri helper", function () {
|
|||
});
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should parse irc:// with port", function () {
|
||||
expect(parseIrcUri("irc://example.com:1337")).to.deep.equal({
|
||||
tls: false,
|
||||
|
@ -34,6 +39,7 @@ describe("parseIrcUri helper", function () {
|
|||
});
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should parse ircs:// with port", function () {
|
||||
expect(parseIrcUri("ircs://example.com:1337")).to.deep.equal({
|
||||
tls: true,
|
||||
|
@ -44,14 +50,17 @@ describe("parseIrcUri helper", function () {
|
|||
});
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not parse invalid port", function () {
|
||||
expect(parseIrcUri("ircs://example.com:lol")).to.deep.equal({});
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not parse plus in port", function () {
|
||||
expect(parseIrcUri("irc://example.com:+6697")).to.deep.equal({});
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should not channel on empty query and hash", function () {
|
||||
const obj = {
|
||||
tls: false,
|
||||
|
@ -66,6 +75,7 @@ describe("parseIrcUri helper", function () {
|
|||
expect(parseIrcUri("irc://example.com/#")).to.deep.equal(obj);
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should parse multiple channels", function () {
|
||||
const obj = {
|
||||
tls: true,
|
||||
|
|
|
@ -1,21 +1,27 @@
|
|||
"use strict";
|
||||
|
||||
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'expect'.
|
||||
const expect = require("chai").expect;
|
||||
const roundBadgeNumber = require("../../../../client/js/helpers/roundBadgeNumber").default;
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'describe'. Do you need to instal... Remove this comment to see the full error message
|
||||
describe("roundBadgeNumber helper", function () {
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should return any number under 1000 as a string", function () {
|
||||
expect(roundBadgeNumber(123)).to.equal("123");
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should return numbers above 999 in thousands", function () {
|
||||
expect(roundBadgeNumber(1000)).to.be.equal("1.0k");
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should round and not floor", function () {
|
||||
expect(roundBadgeNumber(9999)).to.be.equal("10.0k");
|
||||
});
|
||||
|
||||
// @ts-expect-error ts-migrate(2582) FIXME: Cannot find name 'it'. Do you need to install type... Remove this comment to see the full error message
|
||||
it("should always include a single digit when rounding up", function () {
|
||||
expect(roundBadgeNumber(1234)).to.be.equal("1.2k");
|
||||
expect(roundBadgeNumber(12345)).to.be.equal("12.3k");
|
||||
|
|
Loading…
Reference in a new issue