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