Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions test/helpers/mail/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,13 @@ var assert = require('chai').assert
// Test the minimum required to send an email
describe('helloEmail', function () {
var helper = require('../../../lib/helpers/mail/mail.js')
var fromEmail = new helper.Email('[email protected]');
var toEmail = new helper.Email('[email protected]');
var subject = 'Sending with SendGrid is Fun';
var content = new helper.Content('text/plain', 'and easy to do anywhere, even with Node.js');
var mail = new helper.Mail(fromEmail, subject, toEmail, content);

mail = new helper.Mail()
email = new helper.Email("[email protected]")
mail.setFrom(email)

personalization = new helper.Personalization()
email = new helper.Email("[email protected]")
personalization.addTo(email)
mail.addPersonalization(personalization)

mail.setSubject("Hello World from the SendGrid Node.js Library")

content = new helper.Content("text/plain", "some text here")
mail.addContent(content)
content = new helper.Content("text/html", "<html><body>some text here</body></html>")
mail.addContent(content)

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

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