-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.js
31 lines (28 loc) · 877 Bytes
/
test2.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
// ### Test Case 2: Missing Context Variable
// **Description**: Test how the function handles a missing context variable:
const sendEmail = require("./program1.js")
const cleanString = str => str.replace(/\s/g, '');
const assert = require('assert');
const templateCode2 = `
<html>
<body>
<h1>Hello, {{first_name}} {{last_name}}!</h1>
<p>Thank you for registering with {{company}}.</p>
</body>
</html>
`;
const contextData2 = {
first_name: 'John',
company: 'Techdome'
};
const expectedOutput2 = `
<html>
<body>
<h1>Hello, John {{last_name}}!</h1>
<p>Thank you for registering with Techdome.</p>
</body>
</html>
`;
const result2 = sendEmail(null, '[email protected]', contextData2, templateCode2, []);
assert.strictEqual(cleanString(result2.renderedHtml), cleanString(expectedOutput2), 'Test Case 2 Failed');
console.log('Test Case 2 Passed');