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:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user