2
0
mirror of https://github.com/tenrok/BBob.git synced 2026-05-24 14:04:06 +03:00
Files
bbob/packages/bbob-parser/test/Parser.test.js
T
2018-06-25 00:53:49 +02:00

40 lines
821 B
JavaScript

const Parser = require('../lib/Parser');
const parse = input => (new Parser(input).parse());
describe('Parser', () => {
test('parse paired tags tokens', () => {
const ast = parse('[best name=value]Foo Bar[/best]');
expect(ast).toBeInstanceOf(Array);
expect(ast).toEqual([
{
tag: 'best',
attrs: {
name: 'value',
},
content: [
'Foo',
' ',
'Bar',
],
},
]);
});
test('parse tag with value param', () => {
const ast = parse('[url=https://github.com/jilizart/bbob]BBob[/url]');
expect(ast).toBeInstanceOf(Array);
expect(ast).toEqual([
{
tag: 'url',
attrs: {
url: 'https://github.com/jilizart/bbob',
},
content: ['BBob'],
},
]);
});
});