1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-30 10:36:35 +02:00
joplin/packages/renderer/HtmlToHtml.test.ts

45 lines
992 B
TypeScript
Raw Normal View History

import { splitHtml, SplittedHtml } from './HtmlToHtml';
describe('HtmlToHtml', () => {
test('should split an HTML string into HTML and CSS', () => {
const testCases: [string, SplittedHtml][] = [
[
'',
{
html: '',
css: '',
},
],
[
'<style>b { font-weight: bold; }</style>\n<div>hello</div>\n<p>another line</p>',
{
html: '\n<div>hello</div>\n<p>another line</p>',
css: 'b { font-weight: bold; }',
},
],
[
'<STYLE>b { font-weight: bold; }</STYLE>\n<div>hello</div>',
{
html: '\n<div>hello</div>',
css: 'b { font-weight: bold; }',
},
],
[
'<html><head><STYLE>b { font-weight: bold; }</STYLE></head>\n<div>hello</div>',
{
html: '<html><head><STYLE>b { font-weight: bold; }</STYLE></head>\n<div>hello</div>',
css: '',
},
],
];
for (const t of testCases) {
const [input, expected] = t;
const actual = splitHtml(input);
expect(actual).toEqual(expected);
}
});
});