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

136 lines
4.1 KiB
TypeScript

import html, { render } from '@bbob/html'
import core from '@bbob/core'
import preset from '../src'
const parse = (input: string) => {
const tree = core(preset()).process(input, { render })
return html(input, preset())
};
describe('@bbob/preset-html5', () => {
test('[b]bolded text[/b]', () => {
const input = '[b]bolded text[/b]';
const result = '<span style="font-weight: bold;">bolded text</span>';
expect(parse(input)).toBe(result);
});
test('[i]italicized text[/i]', () => {
const input = '[i]italicized text[/i]';
const result = '<span style="font-style: italic;">italicized text</span>';
expect(parse(input)).toBe(result);
});
test('[u]underlined text[/u]', () => {
const input = '[u]underlined text[/u]';
const result = '<span style="text-decoration: underline;">underlined text</span>';
expect(parse(input)).toBe(result);
});
test('[s]strikethrough text[/s]', () => {
const input = '[s]strikethrough text[/s]';
const result = '<span style="text-decoration: line-through;">strikethrough text</span>';
expect(parse(input)).toBe(result);
});
test('[url]https://en.wikipedia.org[/url]', () => {
const input = '[url]https://en.wikipedia.org[/url]';
const result = '<a href="https://en.wikipedia.org">https://en.wikipedia.org</a>';
expect(parse(input)).toBe(result);
});
test('[url=http://step.pgc.edu/]ECAT[/url]', () => {
const input = '[url=http://step.pgc.edu/]ECAT[/url]';
const result = '<a href="http://step.pgc.edu/">ECAT</a>';
expect(parse(input)).toBe(result);
});
test('[img]https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/Go-home-2.svg/100px-Go-home-2.svg.png[/img]', () => {
const input = '[img]https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/Go-home-2.svg/100px-Go-home-2.svg.png[/img]';
const result = '<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/Go-home-2.svg/100px-Go-home-2.svg.png"/>';
expect(parse(input)).toBe(result);
});
test('[quote="author"]quoted text[/quote]', () => {
const input = '[quote="author"]quoted text[/quote]';
const result = '<blockquote><p>quoted text</p></blockquote>';
expect(parse(input)).toBe(result);
});
test('[code]monospaced text[/code]', () => {
const input = '[code]monospaced text[/code]';
const result = '<pre>monospaced text</pre>';
expect(parse(input)).toBe(result);
});
test('[style size="15px"]Large Text[/style]', () => {
const input = '[style size="15px"]Large Text[/style]';
const result = '<span style="font-size:15px;">Large Text</span>';
expect(parse(input)).toBe(result);
});
test('[style color="red"]Red Text[/style]', () => {
const input = '[style color="red"]Red Text[/style]';
const result = '<span style="color:red;">Red Text</span>';
expect(parse(input)).toBe(result);
});
test('[color="red"]Red Text[/color]', () => {
const input = '[color="red"]Red Text[/color]';
const result = '<span style="color: red;">Red Text</span>';
expect(parse(input)).toBe(result);
});
test(`[list][*]Entry 1[/list]`, () => {
const input = `[list][*]Entry 1[*]Entry 2[/list]`;
const result = '<ul><li>Entry 1</li><li>Entry 2</li></ul>';
expect(parse(input)).toBe(result);
});
test(`[list]*Entry 1[/list]`, () => {
const input = `
[list]
*Entry 1
*Entry 2
[/list]`;
const result = `
<ul>
<li>Entry 1
</li><li>Entry 2
</li></ul>`;
expect(parse(input)).toBe(result);
});
test('[list=1][/list]', () => {
const input = `[list=1][/list]`;
const result = `<ol type="1"></ol>`;
expect(parse(input)).toBe(result);
});
test('[list=A][/list]', () => {
const input = `[list=A][/list]`;
const result = `<ol type="A"></ol>`;
expect(parse(input)).toBe(result);
});
test(`[table][/table]`, () => {
const input = `[table][tr][td]table 1[/td][td]table 2[/td][/tr][tr][td]table 3[/td][td]table 4[/td][/tr][/table]`;
const result = `<table><tr><td>table 1</td><td>table 2</td></tr><tr><td>table 3</td><td>table 4</td></tr></table>`;
expect(parse(input)).toBe(result);
});
});