mirror of
https://github.com/tenrok/BBob.git
synced 2026-06-20 20:00:33 +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)
|
const toAST = (source, plugins, options) => core(plugins)
|
||||||
.process(source, {
|
.process(source, {
|
||||||
...options,
|
...options,
|
||||||
render: input => html.render(input, { stripTags: true }),
|
render: input => html.render(input, { stripTags: true }),
|
||||||
}).tree;
|
}).tree;
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import Adapter from 'enzyme-adapter-react-15';
|
|||||||
import BBCode from '../src';
|
import BBCode from '../src';
|
||||||
Enzyme.configure({ adapter: new Adapter() });
|
Enzyme.configure({ adapter: new Adapter() });
|
||||||
|
|
||||||
const renderBBCode = input => shallow(
|
const renderBBCode = (input, options) => shallow(
|
||||||
<BBCode plugins={[preset()]}>{input}</BBCode>
|
<BBCode plugins={[preset()]} options={options}>{input}</BBCode>
|
||||||
).html();
|
).html();
|
||||||
|
|
||||||
describe('@bbob/react', () => {
|
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>')
|
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