import * as assert from 'assert'; import * as mfm from 'mfm-js'; import { toHtml } from '../src/mfm/to-html'; import { fromHtml } from '../src/mfm/from-html'; 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://example.com/b) d'); }); it('link with different text, but not encoded', () => { assert.deepStrictEqual(fromHtml('a c d
'), 'a [c](a 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://example.com/b d'); }); it('link without both', () => { assert.deepStrictEqual(fromHtml(''), 'a d'); }); it('mention', () => { assert.deepStrictEqual(fromHtml('a @user d
'), 'a @user@example.com d'); }); it('hashtag', () => { assert.deepStrictEqual(fromHtml('a #a d
', ['#a']), 'a #a d'); }); });