Files
thelounge/test/shared/cleanIrcMessage.ts
Max Leiter 0fe011235e remove webpack, babel, mocha; switch to vite/vitest (#5064)
```
Webpack vs Vite Build Comparison

  ┌────────────┬──────────────────────┬────────────────────┬───────────────┐
  │   Metric   │      Webpack 5       │ Vite 8 (Rolldown)  │    Change     │
  ├────────────┼──────────────────────┼────────────────────┼───────────────┤
  │ Build time │ 1,961ms (2.96s wall) │ 612ms (0.82s wall) │ 3.2x faster   │
  ├────────────┼──────────────────────┼────────────────────┼───────────────┤
  │ CPU time   │ 11.0s user           │ 1.3s user          │ 8.5x less CPU │
  └────────────┴──────────────────────┴────────────────────┴───────────────┘

  Bundle sizes (gzipped)

  ┌────────────────┬─────────┬────────┬────────┐
  │     Asset      │ Webpack │  Vite  │ Change │
  ├────────────────┼─────────┼────────┼────────┤
  │ App JS         │ 152.6K  │ 104.9K │ -31%   │
  ├────────────────┼─────────┼────────┼────────┤
  │ Vendor JS      │ 251.1K  │ 81.6K  │ -68%   │
  ├────────────────┼─────────┼────────┼────────┤
  │ Runtime JS     │ —       │ 0.5K   │ new    │
  ├────────────────┼─────────┼────────┼────────┤
  │ Total JS       │ 403.7K  │ 187.0K │ -54%   │
  ├────────────────┼─────────┼────────┼────────┤
  │ CSS            │ 12.5K   │ 11.9K  │ -5%    │
  ├────────────────┼─────────┼────────┼────────┤
  │ Total transfer │ 416.2K  │ 198.9K │ -52%   │
  └────────────────┴─────────┴────────┴────────┘

  Raw (uncompressed)

  ┌───────────────┬─────────┬──────┬────────┐
  │     Asset     │ Webpack │ Vite │ Change │
  ├───────────────┼─────────┼──────┼────────┤
  │ App JS        │ 1.3M    │ 304K │ -77%   │
  ├───────────────┼─────────┼──────┼────────┤
  │ Vendor JS     │ 1.1M    │ 236K │ -79%   │
  ├───────────────┼─────────┼──────┼────────┤
  │ CSS           │ 64K     │ 56K  │ -13%   │
  ├───────────────┼─────────┼──────┼────────┤
  │ Total public/ │ 5.1M    │ 3.4M │ -33%   │
  └───────────────┴─────────┴──────┴────────┘
```

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-06-01 09:02:09 -07:00

83 lines
1.7 KiB
TypeScript

import {expect} from "vitest";
import {cleanIrcMessage} from "../../shared/irc";
describe("cleanIrcMessage", function () {
it("should remove all formatting", function () {
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",
},
{
input: "\x02irc\x0f://\x1dirc.example.com\x0f/\x034,8thelounge",
expected: "irc://irc.example.com/thelounge",
},
{
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",
},
];
const actual = testCases.map((testCase) => cleanIrcMessage(testCase.input));
const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected);
});
});