Skip to content
Snippets Groups Projects
Commit 5ab1b261 authored by syuilo's avatar syuilo
Browse files

test: add link test

parent 54a4c457
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ import assert from 'assert';
import { extract, inspect, parse, parsePlain, toString } from '../built/index';
import { createNode } from '../built/util';
import {
TEXT, CENTER, FN, UNI_EMOJI, MENTION, EMOJI_CODE, HASHTAG, N_URL, BOLD, SMALL, ITALIC, STRIKE, QUOTE, MATH_BLOCK, SEARCH, CODE_BLOCK
TEXT, CENTER, FN, UNI_EMOJI, MENTION, EMOJI_CODE, HASHTAG, N_URL, BOLD, SMALL, ITALIC, STRIKE, QUOTE, MATH_BLOCK, SEARCH, CODE_BLOCK, LINK
} from './node';
describe('text', () => {
......@@ -423,7 +423,41 @@ describe('url', () => {
});
});
// link
describe('link', () => {
it('basic', () => {
const input = '[official instance](https://misskey.io/@ai).';
const output = [
LINK(false, 'https://misskey.io/@ai', [
TEXT('official instance')
]),
TEXT('.')
];
assert.deepStrictEqual(parse(input), output);
});
it('silent flag', () => {
const input = '?[official instance](https://misskey.io/@ai).';
const output = [
LINK(true, 'https://misskey.io/@ai', [
TEXT('official instance')
]),
TEXT('.')
];
assert.deepStrictEqual(parse(input), output);
});
it('do not yield url node even if label is recognisable as a url', () => {
const input = 'official instance: [https://misskey.io/@ai](https://misskey.io/@ai).';
const output = [
TEXT('official instance: '),
LINK(false, 'https://misskey.io/@ai', [
TEXT('https://misskey.io/@ai')
]),
TEXT('.')
];
assert.deepStrictEqual(parse(input), output);
});
});
describe('fn', () => {
it('basic', () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment