-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.js
39 lines (36 loc) · 1.05 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const assert = require('assert');
const htmlFormatter = require('./render/html-formatter')
const testRawContent = `
<html>
<p>$shortTextPlaceholder$</p>
<b>$numberPlaceholder$</b>
<i>$emptyPlaceholder$</i>
<u>$undefinedPlaceholder$</u>
<div style="color: $nullPlaceholder$"></div>
<span>$longTextPlaceholder$</span>
</html>
`;
const formattedContent = `
<html>
<p>My name is Elvis</p>
<b>5</b>
<i></i>
<u></u>
<div style="color: "></div>
<span>Lorem ipsum pisum masum apsium thatsum</span>
</html>
`;
it('should replace all specifed all placeholders with values and remove nulls', () => {
const returnValue = htmlFormatter.getFormattedContent(
testRawContent,
{
"shortTextPlaceholder": "My name is Elvis",
"numberPlaceholder": 5,
"emptyPlaceholder": "",
"nullPlaceholder": null,
// undefined placeholder is well, undefined "undefinedPlaceholder": undefined
"longTextPlaceholder": "Lorem ipsum pisum masum apsium thatsum"
}
);
assert.equal(returnValue, formattedContent)
})