import * as assert from "assert"; import * as mfm from "mfm-js"; import { fromHtml } from "../src/mfm/from-html.js"; import { toHtml } from "../src/mfm/to-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", () => { assert.deepStrictEqual(fromHtml("a\nb
"),
"```\na\nb\n```",
);
});
it("inline code", () => {
assert.deepStrictEqual(fromHtml("a
"), "`a`");
});
it("quote", () => {
assert.deepStrictEqual(
fromHtml("a\nb"), "> a\n> b", ); }); it("br", () => { assert.deepStrictEqual(fromHtml("
abc
d
a c d
'), "a [c](https://firefish.dev/firefish) d", ); }); it("link with different text, but not encoded", () => { assert.deepStrictEqual( fromHtml('a c d
'), "a [c](a https://firefish.dev/firefish/firefish d
', ), "a https://firefish.dev/firefish/firefish d", ); }); it("link with same text, but not encoded", () => { assert.deepStrictEqual( fromHtml( '', ), "aa c d
'), "a [c](b) d", ); }); it("link without href", () => { assert.deepStrictEqual(fromHtml("a c d
"), "a c d"); }); it("link without text", () => { assert.deepStrictEqual( fromHtml(''), "a https://firefish.dev/b d", ); }); it("link without both", () => { assert.deepStrictEqual(fromHtml(""), "a d"); }); it("mention", () => { assert.deepStrictEqual( fromHtml( 'a @firefish d
', ), "a @firefish@info.firefish.dev d", ); }); it("hashtag", () => { assert.deepStrictEqual( fromHtml('a #a d
', [ "#a", ]), "a #a d", ); }); });