-
Notifications
You must be signed in to change notification settings - Fork 0
/
test6.js
41 lines (35 loc) · 913 Bytes
/
test6.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
40
41
// ### Test Case 6: Advanced Templating with Loop
// **Description**: Test with a template that includes a loop to list items.
const sendEmail = require("./program1.js")
const cleanString = str => str.replace(/\s/g, '');
const assert = require('assert');
const templateCode5 = `
<html>
<body>
<h1>Shopping List:</h1>
<ul>
{% for item in items %}
<li>{{item}}</li>
{% endfor %}
</ul>
</body>
</html>
`;
const contextData5 = {
items: ['Milk', 'Bread', 'Eggs']
};
const expectedOutput5 = `
<html>
<body>
<h1>Shopping List:</h1>
<ul>
<li>Milk</li>
<li>Bread</li>
<li>Eggs</li>
</ul>
</body>
</html>
`;
const result5 = sendEmail(null, '[email protected]', contextData5, templateCode5, []);
assert.strictEqual(cleanString(result5.renderedHtml), cleanString(expectedOutput5), 'Test Case 6 Failed');
console.log('Test Case 6 Passed');