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

chore(react): tests for options.onlyAllowTags

This commit is contained in:
Nikolay Kostyurin
2018-10-25 16:55:16 +02:00
parent 9d5c537436
commit 0f8071315d
2 changed files with 12 additions and 3 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ import { isTagNode, isStringNode } from '@bbob/plugin-helper';
const toAST = (source, plugins, options) => core(plugins)
.process(source, {
...options,
...options,
render: input => html.render(input, { stripTags: true }),
}).tree;
+11 -2
View File
@@ -8,8 +8,8 @@ import Adapter from 'enzyme-adapter-react-15';
import BBCode from '../src';
Enzyme.configure({ adapter: new Adapter() });
const renderBBCode = input => shallow(
<BBCode plugins={[preset()]}>{input}</BBCode>
const renderBBCode = (input, options) => shallow(
<BBCode plugins={[preset()]} options={options}>{input}</BBCode>
).html();
describe('@bbob/react', () => {
@@ -42,4 +42,13 @@ describe('@bbob/react', () => {
expect(html).toBe('<span><a href="https://en.wikipedia.org">https://en.wikipedia.org</a></span>')
});
describe('options.onlyAllowTags', () => {
test('render "[Super Feature] and [i]super[/i]" when only [i] allowed', () => {
const html = renderBBCode('[Super Feature] and [i]super[/i]', { onlyAllowTags: ['i'] });
expect(html).toBe('<span>[Super Feature] and <span style="font-style:italic;">super</span></span>')
});
});
});