|
1 | 1 | var assert = require('chai').assert |
2 | 2 |
|
| 3 | +var helper = require('sendgrid').mail; |
| 4 | + |
3 | 5 | // Test the minimum required to send an email |
4 | 6 | describe('helloEmail', function () { |
5 | 7 | var helper = require('../../../lib/helpers/mail/mail.js') |
| 8 | + var fromEmail = new helper.Email('[email protected]'); |
| 9 | + var toEmail = new helper.Email('[email protected]'); |
| 10 | + var subject = 'Sending with SendGrid is Fun'; |
| 11 | + var content = new helper.Content('text/plain', 'and easy to do anywhere, even with Node.js'); |
| 12 | + var mail = new helper.Mail(fromEmail, subject, toEmail, content); |
6 | 13 |
|
7 | | - mail = new helper.Mail() |
8 | | - email = new helper.Email("[email protected]") |
9 | | - mail.setFrom(email) |
10 | | - |
11 | | - personalization = new helper.Personalization() |
12 | | - email = new helper.Email("[email protected]") |
13 | | - personalization.addTo(email) |
14 | | - mail.addPersonalization(personalization) |
15 | | - |
16 | | - mail.setSubject("Hello World from the SendGrid Node.js Library") |
17 | | - |
18 | | - content = new helper.Content("text/plain", "some text here") |
19 | | - mail.addContent(content) |
20 | | - content = new helper.Content("text/html", "<html><body>some text here</body></html>") |
21 | | - mail.addContent(content) |
22 | | - |
23 | | - test_payload = '{"from":{"email":"[email protected]"},"personalizations":[{"to":[{"email":"[email protected]"}]}],"subject":"Hello World from the SendGrid Node.js Library","content":[{"type":"text/plain","value":"some text here"},{"type":"text/html","value":"<html><body>some text here</body></html>"}]}' |
| 14 | + test_payload = '{"from":{"email":"[email protected]"},"personalizations":[{"to":[{"email":"[email protected]"}]}],"subject":"Sending with SendGrid is Fun","content":[{"type":"text/plain","value":"and easy to do anywhere, even with Node.js"}]}' |
24 | 15 |
|
25 | 16 | it('builds the correct payload', function() { |
26 | 17 | assert.equal(JSON.stringify(mail.toJSON()), test_payload, 'payload is correct') |
|
0 commit comments