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:
committed by
GitHub
parent
bf993813fc
commit
575c1bb932
@@ -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([
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user