mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-10-02 08:07:40 -05:00
@@ -1,5 +1,9 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { pathnameFromPotentialURL, truncateBySentence } from "./strings";
|
||||
import {
|
||||
pathnameFromPotentialURL,
|
||||
removeMarkdown,
|
||||
truncateBySentence,
|
||||
} from "./strings";
|
||||
|
||||
describe("pathnameFromPotentialURL()", () => {
|
||||
test("Resolves path name from valid URL", () => {
|
||||
@@ -44,3 +48,30 @@ describe("truncateBySentence()", () => {
|
||||
expect(truncateBySentence(text, 20)).toBe("First line");
|
||||
});
|
||||
});
|
||||
|
||||
describe("removeMarkdown()", () => {
|
||||
test("Decodes entities and collapses runs", () => {
|
||||
const text = " Global Gauntlet is an event";
|
||||
expect(removeMarkdown(text)).toBe("Global Gauntlet is an event");
|
||||
});
|
||||
|
||||
test("Decodes common named HTML entities", () => {
|
||||
expect(removeMarkdown("Tom & Jerry <3 "hi"")).toBe(
|
||||
'Tom & Jerry <3 "hi"',
|
||||
);
|
||||
});
|
||||
|
||||
test("Decodes numeric HTML entities", () => {
|
||||
expect(removeMarkdown("café & tea")).toBe("café & tea");
|
||||
});
|
||||
|
||||
test("Leaves unknown named entities untouched", () => {
|
||||
expect(removeMarkdown("AT&T &fakeentity; rules")).toBe(
|
||||
"AT&T &fakeentity; rules",
|
||||
);
|
||||
});
|
||||
|
||||
test("Strips HTML tags and markdown emphasis", () => {
|
||||
expect(removeMarkdown("<p>Hello **world**!</p>")).toBe("Hello world!");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user