import * as assert from "assert"; import * as mfm from "mfm-js"; import { toHtml } from "../src/mfm/to-html.js"; import { fromHtml } from "../src/mfm/from-html.js"; describe("toHtml", () => { it("br", () => { const input = "foo\nbar\nbaz"; const output = "
foo
bar
baz
foo
bar
baz
a
b
"), "a\n\nb"); }); it("block element", async () => { assert.deepStrictEqual(await fromHtml("a\nb
"),
"```\na\nb\n```",
);
});
it("inline code", async () => {
assert.deepStrictEqual(await fromHtml("a
"), "`a`");
});
it("quote", async () => {
assert.deepStrictEqual(
await fromHtml("a\nb"), "> a\n> b", ); }); it("br", async () => { assert.deepStrictEqual(await fromHtml("
abc
d
a c d
'), "a [c](https://iceshrimp.dev/b) d", ); }); it("link with different text, but not encoded", async () => { assert.deepStrictEqual( await fromHtml('a c d
'), "a [c](a https://joiniceshrimp.org/b d
', ), "a https://joiniceshrimp.org/b d", ); }); it("link with same text, but not encoded", async () => { assert.deepStrictEqual( await fromHtml( 'a https://joiniceshrimp.org/ä d
', ), "aa c d
'), "a [c](b) d", ); }); it("link without href", async () => { assert.deepStrictEqual(await fromHtml("a c d
"), "a c d"); }); it("link without text", async () => { assert.deepStrictEqual( await fromHtml(''), "a https://joiniceshrimp.org/b d", ); }); it("link without both", async () => { assert.deepStrictEqual(await fromHtml(""), "a d"); }); it("mention", async () => { assert.deepStrictEqual( await fromHtml( 'a @user d
', undefined, false ), "a @user@joiniceshrimp.org d", ); }); it("hashtag", async () => { assert.deepStrictEqual( await fromHtml('a #a d
', [ "#a", ]), "a #a d", ); }); });