2023-08-21 19:37:33 +02:00
|
|
|
import htmlUtils, { extractHtmlBody } from './htmlUtils';
|
2022-01-15 18:53:24 +02:00
|
|
|
|
|
|
|
describe('htmlUtils', () => {
|
|
|
|
|
|
|
|
test('should strip off HTML', () => {
|
|
|
|
const testCases = [
|
|
|
|
[
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'<b>test</b>',
|
|
|
|
'test',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'Joplin®',
|
|
|
|
'Joplin®',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'<b>test</b>',
|
|
|
|
'<b>test</b>',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
for (const t of testCases) {
|
|
|
|
const [input, expected] = t;
|
|
|
|
const actual = htmlUtils.stripHtml(input);
|
|
|
|
expect(actual).toBe(expected);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-08-21 19:37:33 +02:00
|
|
|
test('should extract the HTML body', () => {
|
|
|
|
const testCases: [string, string][] = [
|
|
|
|
[
|
|
|
|
'Just <b>testing</b>',
|
|
|
|
'Just <b>testing</b>',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'<html><head></head><meta bla><body>Here is the body<img src="test.png"/></body></html>',
|
|
|
|
'Here is the body<img src="test.png"/>',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
for (const [input, expected] of testCases) {
|
|
|
|
const actual = extractHtmlBody(input);
|
|
|
|
expect(actual).toBe(expected);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-01-15 18:53:24 +02:00
|
|
|
});
|