2
0
mirror of https://github.com/tenrok/BBob.git synced 2026-05-15 11:59:37 +03:00

fix(html): add more tests

This commit is contained in:
Nikolay Kostyurin
2018-08-09 10:06:00 +02:00
parent 10f6ff9ff1
commit 4ebc512732
2 changed files with 19 additions and 3 deletions
+2 -2
View File
@@ -20,7 +20,7 @@ const renderNode = (node, { stripTags = false }) => {
if (type === 'object') {
if (stripTags === true) {
// eslint-disable-next-line no-use-before-define
return renderNodes(node.content);
return renderNodes(node.content, { stripTags });
}
if (node.content === null) {
@@ -33,7 +33,7 @@ const renderNode = (node, { stripTags = false }) => {
if (Array.isArray(node)) {
// eslint-disable-next-line no-use-before-define
return renderNodes(node);
return renderNodes(node, { stripTags });
}
return '';
+17 -1
View File
@@ -1,7 +1,7 @@
const render = require('../lib/index');
const parse = require('@bbob/parser');
const process = input => render(parse(input));
const process = (input, params) => render(parse(input), params);
describe('@bbob/html', () => {
test('render bbcode tag with single param as html tag', () => {
@@ -24,4 +24,20 @@ describe('@bbob/html', () => {
expect(process(input)).toBe(result);
});
test('strip tags', () => {
const input = '[url]https://ru.wikipedia.org[/url]';
const result = 'https://ru.wikipedia.org';
expect(process(input, { stripTags: true })).toBe(result);
});
test('array of nodes', () => {
const input = [
'https://ru.wikipedia.org'
];
const result = 'https://ru.wikipedia.org';
expect(render(input)).toBe(result);
});
});