From 19b36ea994616b813d8f27c79f35af87d908c7d9 Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Wed, 21 Jun 2017 11:53:52 -0700 Subject: [PATCH 1/2] Updating test to reflect Hello World Example --- test/helpers/mail/test.js | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/test/helpers/mail/test.js b/test/helpers/mail/test.js index 9ba15cec5..cc3830847 100644 --- a/test/helpers/mail/test.js +++ b/test/helpers/mail/test.js @@ -1,26 +1,17 @@ var assert = require('chai').assert +var helper = require('sendgrid').mail; + // Test the minimum required to send an email describe('helloEmail', function () { var helper = require('../../../lib/helpers/mail/mail.js') + var fromEmail = new helper.Email('test@example.com'); + var toEmail = new helper.Email('test@example.com'); + 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("test@example.com") - mail.setFrom(email) - - personalization = new helper.Personalization() - email = new helper.Email("test@example.com") - 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", "some text here") - mail.addContent(content) - - test_payload = '{"from":{"email":"test@example.com"},"personalizations":[{"to":[{"email":"test@example.com"}]}],"subject":"Hello World from the SendGrid Node.js Library","content":[{"type":"text/plain","value":"some text here"},{"type":"text/html","value":"some text here"}]}' + test_payload = '{"from":{"email":"test@example.com"},"personalizations":[{"to":[{"email":"test@example.com"}]}],"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') From 617e99fd5abe0b1f5f24e34e257b4a4c6252ca97 Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Wed, 21 Jun 2017 11:59:07 -0700 Subject: [PATCH 2/2] Remove duplicate variable declaration --- test/helpers/mail/test.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/helpers/mail/test.js b/test/helpers/mail/test.js index cc3830847..eb8ac633e 100644 --- a/test/helpers/mail/test.js +++ b/test/helpers/mail/test.js @@ -1,7 +1,5 @@ var assert = require('chai').assert -var helper = require('sendgrid').mail; - // Test the minimum required to send an email describe('helloEmail', function () { var helper = require('../../../lib/helpers/mail/mail.js')