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