2
0
mirror of https://github.com/tenrok/BBob.git synced 2026-05-24 14:04:06 +03:00
Files
bbob/packages/bbob-react/test/index.test.tsx
T
Nikolay Kost 8797f7f363 feat: typescript support (#185)
* feat: initial typescript support

* feat: typescript support

* feat(plugin-helper): move files to typescript

* chore: update lock files

* feat: preset types

* fix: build

* fix: benchmark

* fix: remove pnpm cache

* fix: bench action

* fix: pnpm recursive install

* fix: nx cache

* fix: lock file

* fix: workflows

* fix: lerna support in pnpm

* fix: pnpm workspace

* fix: remove unused files

* fix: pnpm lock file

* fix: update lerna for support pnpm

* fix: lerna bootstrap

* fix: rollup build

* fix: update nx

* fix: build

* fix: add nx dep target

* fix: remove nx cache

* fix: workflow run on push only for master

* fix: test workflow run on push only for master

* fix: remove parallel for gen types

* fix: benchmark

* fix: benchmark imports

* fix: pnpm

* fix: types errors and pnpm

* fix: types

* fix: types

* refactor: parser

* fix(parser): tests

* fix: preset tests

* fix: react types

* fix: react type declarations

* fix: pnpm lock file

* fix: react preset types

* fix: lock file

* fix: vue2 types

* feat: dev container support

* fix: types

* fix: types

* refactor: rewrite pkg-task, add nx gen-types deps, fix react/render.ts

* refactor: types

* fix: types

* fix: rename gen-types to types

* fix: nx build order

* fix: nx reset

* fix: define nx deps explicit

* fix: build

* fix: nx

* fix: nx order build

* fix: nx deps

* fix: bbob cli tests

* fix: tests

* fix: cli tests and import

* fix: test cover

* fix: cli cover
2024-04-23 21:11:14 +02:00

63 lines
1.9 KiB
TypeScript

/**
* @jest-environment jsdom
*/
import React from 'react';
import preset from '@bbob/preset-react';
import '@testing-library/jest-dom'
import { render } from '@testing-library/react'
import BBCode from '../src';
const renderBBCode = (input, options) => render(
<BBCode plugins={[preset()]} options={options}>{input}</BBCode>
).container.innerHTML;
describe('@bbob/react', () => {
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>')
});
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>')
});
});
});