/**
* @jest-environment jsdom
*/
import preset from '@bbob/preset-vue';
import { render } from '@testing-library/vue'
import Component from '../src/Component'
const renderBBCode = (input, options) => {
const { html } = render(Component, {
props: {
plugins: [preset()],
options,
},
slots: {
default: input
}
})
return html()
}
describe('@bbob/vue2', () => {
test('[b]bolded text[/b]', () => {
const html = renderBBCode('[b]bolded text[/b]');
expect(html).toBe('bolded text')
});
test('[i]italicized text[/i]', () => {
const html = renderBBCode('[i]italicized text[/i]');
expect(html).toBe('italicized text')
});
test('[u]underlined text[/u]', () => {
const html = renderBBCode('[u]underlined text[/u]');
expect(html).toBe('underlined text')
});
test('[s]strikethrough text[/s]', () => {
const html = renderBBCode('[s]strikethrough text[/s]');
expect(html).toBe('strikethrough text')
});
test('[url]https://en.wikipedia.org[/url]', () => {
const html = renderBBCode('[url]https://en.wikipedia.org[/url]');
expect(html).toBe('https://en.wikipedia.org')
});
test('[b]Testing[/b][hr]', () => {
const html = renderBBCode('[b]Testing[/b][hr]');
expect(html).toBe(`Testing
`)
});
test('render empty ', () => {
const { html } = render(Component, {
props: {
plugins: [preset()],
}
})
expect(html()).toBe('')
})
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('[Super Feature] and super')
});
});
})