mirror of
https://github.com/tenrok/BBob.git
synced 2026-06-05 16:42:27 +03:00
da6709d437
* feat: use swc.rs instead of babel * BREAKING CHANGE: now we use swc.rs as main bundler and transpiler instead of babel - jest now uses swc - rollup now uses swc * feat: benchmark now separate package with `npm start` and colored output - benchmark as separate package with error throw if package drops performance * feat: all lerna packages now using scripts/pkg-task * feat(github): publish to npm and github registry - when release was created this action automaticly publish packages to npm and github * feat(github): move all from Travis CI to Github Actions - code analysis and tests now using github actions * test: increase tests coverage - add more tests for @bbob/react, @bbob/vue2 and @bbob/parser
79 lines
2.1 KiB
JavaScript
79 lines
2.1 KiB
JavaScript
/**
|
|
* @jest-environment jsdom
|
|
*/
|
|
|
|
import preset from '@bbob/preset-vue';
|
|
import { render, fireEvent } 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('<span><span style="font-weight: bold;">bolded text</span></span>')
|
|
});
|
|
|
|
test('[i]italicized text[/i]', () => {
|
|
const html = renderBBCode('[i]italicized text[/i]');
|
|
|
|
expect(html).toBe('<span><span style="font-style: italic;">italicized text</span></span>')
|
|
});
|
|
|
|
test('[u]underlined text[/u]', () => {
|
|
const html = renderBBCode('[u]underlined text[/u]');
|
|
|
|
expect(html).toBe('<span><span style="text-decoration: underline;">underlined text</span></span>')
|
|
});
|
|
|
|
test('[s]strikethrough text[/s]', () => {
|
|
const html = renderBBCode('[s]strikethrough text[/s]');
|
|
|
|
expect(html).toBe('<span><span style="text-decoration: line-through;">strikethrough text</span></span>')
|
|
});
|
|
|
|
test('[url]https://en.wikipedia.org[/url]', () => {
|
|
const html = renderBBCode('[url]https://en.wikipedia.org[/url]');
|
|
|
|
expect(html).toBe('<span><a href="https://en.wikipedia.org">https://en.wikipedia.org</a></span>')
|
|
});
|
|
|
|
test('[b]Testing[/b][hr]', () => {
|
|
const html = renderBBCode('[b]Testing[/b][hr]');
|
|
|
|
expect(html).toBe(`<span><span style="font-weight: bold;">Testing</span>
|
|
<hr></span>`)
|
|
});
|
|
|
|
test('render empty <slot></slot>', () => {
|
|
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('<span>[Super Feature] and <span style="font-style: italic;">super</span></span>')
|
|
});
|
|
});
|
|
})
|