diff options
-rw-r--r-- | index.js | 1 | ||||
-rw-r--r-- | lib/sendgrid.js | 3 | ||||
-rw-r--r-- | test/index.test.js | 3 | ||||
-rw-r--r-- | test/lib/email.test.js | 6 | ||||
-rw-r--r-- | test/lib/sendgrid.test.js | 1 | ||||
-rw-r--r-- | test/lib/smtpapi_header.test.js | 35 | ||||
-rw-r--r-- | test/mocha.opts | 2 | ||||
-rw-r--r-- | test/test_helper.js | 3 |
8 files changed, 44 insertions, 10 deletions
@@ -1,2 +1,3 @@ module.exports.SendGrid = require('./lib/sendgrid'); module.exports.Email = require('./lib/email'); +module.exports.SmtpapiHeaders = require('./lib/smtpapi_headers'); diff --git a/lib/sendgrid.js b/lib/sendgrid.js index e430049..eab1834 100644 --- a/lib/sendgrid.js +++ b/lib/sendgrid.js @@ -61,8 +61,7 @@ SendGrid.prototype.smtp = function(email, callback) { html: email.html, headers: { "x-smtpapi": JSON.stringify(email['x-smtpapi']) - }, - debug:true + } }, function(error, success) { callback.call(self, success, error); }); diff --git a/test/index.test.js b/test/index.test.js index a7eca1d..0168f20 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -10,4 +10,7 @@ describe("index.js", function () { it('should export the Email object', function() { index.Email.should.not.be.undefined; }); + it('should export the SmtpapiHeaders object', function() { + index.SmtpapiHeaders.should.not.be.undefined; + }); }); diff --git a/test/lib/email.test.js b/test/lib/email.test.js index 233a149..1db7065 100644 --- a/test/lib/email.test.js +++ b/test/lib/email.test.js @@ -16,12 +16,6 @@ describe('Email', function () { } }); - it('should allow to field to be set via addTo', function() { - var mail = new Email(text_params); - mail.addTo('siyegen@gmail.com'); - mail. - }); - describe('validation', function() { it('should invalidate when there are no parameters', function() { var mail = new Email(); diff --git a/test/lib/sendgrid.test.js b/test/lib/sendgrid.test.js index 18df2b6..638e159 100644 --- a/test/lib/sendgrid.test.js +++ b/test/lib/sendgrid.test.js @@ -1,6 +1,5 @@ var SendGrid = require('../../lib/sendgrid'); var Email = require('../../lib/email'); -var should = require('should'); var credentials = { api_user: 'kylep', diff --git a/test/lib/smtpapi_header.test.js b/test/lib/smtpapi_header.test.js index 82b823c..699ad4d 100644 --- a/test/lib/smtpapi_header.test.js +++ b/test/lib/smtpapi_header.test.js @@ -98,5 +98,40 @@ describe('SmtpapiHeader', function() { header.addFilterSetting('footer', 'text/html', '<b>boo</b>'); JSON.parse(header.toJson()).should.eql(header); }); + + it('should not include the "to" parameter when there are none', function() { + header.setCategory('nothing'); + var json = header.toJson(); + + assert(!_.isEmpty(JSON.parse(json).to), 'should be empty'); + }); + + it('should not include the "sub" parameter when there are none', function() { + header.setCategory('nothing'); + var json = header.toJson(); + + assert(!_.isEmpty(JSON.parse(json).sub), 'should be empty'); + }); + + it('should not include the "unique_args" parameter when there are none', function() { + header.setCategory('nothing'); + var json = header.toJson(); + + assert(!_.isEmpty(JSON.parse(json).unique_args), 'should be empty'); + }); + + it('should not include the "category" parameter when there are none', function() { + header.addUniqueArgs({food: 'bar'}); + var json = header.toJson(); + + assert(!_.isEmpty(JSON.parse(json).category), 'should be empty'); + }); + + it('should not include the "filters" parameter when there are none', function() { + header.addUniqueArgs({food: 'bar'}); + var json = header.toJson(); + + assert(!_.isEmpty(JSON.parse(json).filters), 'should be empty'); + }); }); }); diff --git a/test/mocha.opts b/test/mocha.opts index e305201..ac09c5c 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -1 +1 @@ ---require should +--require test/test_helper.js diff --git a/test/test_helper.js b/test/test_helper.js new file mode 100644 index 0000000..befa4c7 --- /dev/null +++ b/test/test_helper.js @@ -0,0 +1,3 @@ +global._ = require('underscore'); +global.should = require('should'); +global.assert = require('assert'); |