[Test] Add a test and some updtes

This commit is contained in:
syuilo 2018-11-17 12:52:20 +09:00
parent 70385ca670
commit 6c72545fc8
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69

View file

@ -168,7 +168,7 @@ describe('Text', () => {
}], tokens); }], tokens);
}); });
it('ignore trailing dot', () => { it('ignore trailing period', () => {
const tokens = analyze('https://example.com.'); const tokens = analyze('https://example.com.');
assert.deepEqual([{ assert.deepEqual([{
type: 'url', type: 'url',
@ -220,6 +220,19 @@ describe('Text', () => {
type: 'text', content: ')' type: 'text', content: ')'
}], tokens); }], tokens);
}); });
it('ignore parent brackets with internal brackets', () => {
const tokens = analyze('(https://example.com/foo(bar))');
assert.deepEqual([{
type: 'text', content: '('
}, {
type: 'url',
content: 'https://example.com/foo(bar)',
url: 'https://example.com/foo(bar)'
}, {
type: 'text', content: ')'
}], tokens);
});
}); });
it('link', () => { it('link', () => {
@ -265,7 +278,7 @@ describe('Text', () => {
}); });
it('math', () => { it('math', () => {
const fomula = 'x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}.'; const fomula = 'x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}';
const text = `\\(${fomula}\\)`; const text = `\\(${fomula}\\)`;
const tokens = analyze(text); const tokens = analyze(text);
assert.deepEqual([ assert.deepEqual([