2
0
mirror of https://github.com/tenrok/BBob.git synced 2026-05-15 11:59:37 +03:00
Files
bbob/packages/bbob-html/test/index.test.ts
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

44 lines
1.4 KiB
TypeScript

import toHTML, { BBobHTMLOptions, render } from '../src';
const process = (input: string, params?: BBobHTMLOptions) => toHTML(input, [], params);
describe('@bbob/html', () => {
test('render bbcode tag with single param as html tag', () => {
const input = '[url=https://ru.wikipedia.org]Text[/url]';
const expected = '<url https://ru.wikipedia.org="https://ru.wikipedia.org">Text</url>';
const result = process(input);
expect(result).toBe(expected);
});
test('render bbcode tag with multiple params as html tag', () => {
const input = '[url href=https://ru.wikipedia.org target=_blank text="Foo Bar"]Text[/url]';
const result = '<url href="https://ru.wikipedia.org" target="_blank" text="Foo Bar">Text</url>';
expect(process(input)).toBe(result);
});
test('render bbcode tag without params as html tag', () => {
const input = '[url]https://ru.wikipedia.org[/url]';
const result = '<url>https://ru.wikipedia.org</url>';
expect(process(input)).toBe(result);
});
test('strip tags', () => {
const input = '[url]https://ru.wikipedia.org[/url]';
const result = 'https://ru.wikipedia.org';
expect(process(input, { stripTags: true })).toBe(result);
});
test('array of nodes', () => {
const input = [
'https://ru.wikipedia.org'
];
const result = 'https://ru.wikipedia.org';
expect(render(input)).toBe(result);
});
});