2
0
mirror of https://github.com/tenrok/BBob.git synced 2026-06-17 19:21:20 +03:00

feat: new @bbob/html api (#4)

This commit is contained in:
Nikolay Kostyurin
2018-10-12 00:43:20 +02:00
committed by GitHub
parent bf993813fc
commit 575c1bb932
12 changed files with 66 additions and 45 deletions
+2 -3
View File
@@ -1,17 +1,16 @@
import render from '@bbob/html'
import { TagNode } from '@bbob/parser'
import core from '../src'
const stringify = val => JSON.stringify(val);
const process = (plugins, input) => core(plugins).process(input, { render });
const process = (plugins, input) => core(plugins).process(input, { render: stringify });
describe('@bbob/core', () => {
test('parse bbcode string to ast and html', () => {
const res = process([], '[style size="15px"]Large Text[/style]');
const ast = res.tree;
expect(res.html).toBe(`<style size="15px">Large Text</style>`);
expect(res.html).toBe('[{"tag":"style","attrs":{"size":"15px"},"content":["Large"," ","Text"]}]');
expect(ast).toBeInstanceOf(Array);
expect(stringify(ast)).toEqual(stringify([
{