2
0
mirror of https://github.com/tenrok/BBob.git synced 2026-06-05 16:42:27 +03:00

refactor(parser): better jsdoc, some behavior fixes, more tests

— all operations on nodes moved to `createList` function
- fixed problem with single tags with value only like `[url=value]` fixes #6
- write tests for `Token` class
- moved all node arrays to parse func, now parser supports many instances
- add jsdoc to critical parts of the parser to better understanding how it works
This commit is contained in:
Nikolay Kostyurin
2019-03-04 02:24:12 +02:00
parent ef6a778f45
commit 8cb1d495dd
7 changed files with 379 additions and 220 deletions
+17 -1
View File
@@ -50,7 +50,9 @@ describe('Parser', () => {
expectOutput(ast, [
{
attrs: {},
attrs: {
name: 'value'
},
tag: 'h1',
content: []
},
@@ -96,6 +98,20 @@ describe('Parser', () => {
]);
});
test('parse single tag with params', () => {
const ast = parse('[url=https://github.com/jilizart/bbob]');
expectOutput(ast, [
{
tag: 'url',
attrs: {
'https://github.com/jilizart/bbob': 'https://github.com/jilizart/bbob',
},
content: [],
},
]);
});
test('detect inconsistent tag', () => {
const onError = jest.fn();
const ast = parse('[c][/c][b]hello[/c][/b][b]', { onError });