summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/mfm.ts22
1 files changed, 20 insertions, 2 deletions
diff --git a/test/mfm.ts b/test/mfm.ts
index 706c4c549a..a015092f0c 100644
--- a/test/mfm.ts
+++ b/test/mfm.ts
@@ -1,6 +1,7 @@
import * as assert from 'assert';
import analyze from '../src/mfm/parse';
+import toHtml from '../src/mfm/html';
import syntaxhighlighter from '../src/mfm/parse/core/syntax-highlighter';
describe('Text', () => {
@@ -70,11 +71,20 @@ describe('Text', () => {
});
it('hashtag', () => {
- const tokens = analyze('Strawberry Pasta #alice');
+ const tokens1 = analyze('Strawberry Pasta #alice');
assert.deepEqual([
{ type: 'text', content: 'Strawberry Pasta ' },
{ type: 'hashtag', content: '#alice', hashtag: 'alice' }
- ], tokens);
+ ], tokens1);
+
+ const tokens2 = analyze('Foo #bar, baz #piyo.');
+ assert.deepEqual([
+ { type: 'text', content: 'Foo ' },
+ { type: 'hashtag', content: '#bar', hashtag: 'bar' },
+ { type: 'text', content: ', baz ' },
+ { type: 'hashtag', content: '#piyo', hashtag: 'piyo' },
+ { type: 'text', content: '.' }
+ ], tokens2);
});
it('url', () => {
@@ -170,4 +180,12 @@ describe('Text', () => {
assert.equal(html, '<span class="symbol">/</span>');
});
});
+
+ describe('toHtml', () => {
+ it('br', () => {
+ const input = 'foo\nbar\nbaz';
+ const output = '<p>foo<br>bar<br>baz</p>';
+ assert.equal(toHtml(analyze(input)), output);
+ });
+ });
});