Skip to content

Commit b29d1c6

Browse files
Merge pull request #395 from sendgrid/test_hello_world
Updating test to reflect Hello World Example
2 parents 9767ae6 + 617e99f commit b29d1c6

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

test/helpers/mail/test.js

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,13 @@ var assert = require('chai').assert
33
// Test the minimum required to send an email
44
describe('helloEmail', function () {
55
var helper = require('../../../lib/helpers/mail/mail.js')
6+
var fromEmail = new helper.Email('[email protected]');
7+
var toEmail = new helper.Email('[email protected]');
8+
var subject = 'Sending with SendGrid is Fun';
9+
var content = new helper.Content('text/plain', 'and easy to do anywhere, even with Node.js');
10+
var mail = new helper.Mail(fromEmail, subject, toEmail, content);
611

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>"}]}'
12+
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"}]}'
2413

2514
it('builds the correct payload', function() {
2615
assert.equal(JSON.stringify(mail.toJSON()), test_payload, 'payload is correct')

0 commit comments

Comments
 (0)