summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Tomberlin <david.tomberlin@sendgrid.com>2012-01-12 12:14:51 -0800
committerDavid Tomberlin <david.tomberlin@sendgrid.com>2012-01-12 12:14:51 -0800
commite8314bb62bace94e5af2c51c61b7fb8071db80c4 (patch)
tree88c101504c526c4ace890181361067fac7c22b77
parent70fee2c8f8c1233a274743aaa456188a17d4d7e5 (diff)
parentc63d681bba3718ee535b2d2e339b36434a2f49f2 (diff)
downloadsendgrid-nodejs-e8314bb62bace94e5af2c51c61b7fb8071db80c4.zip
sendgrid-nodejs-e8314bb62bace94e5af2c51c61b7fb8071db80c4.tar.gz
sendgrid-nodejs-e8314bb62bace94e5af2c51c61b7fb8071db80c4.tar.bz2
Merge remote-tracking branch 'kyle/x-smtpapi' into x-smtpapi
-rw-r--r--index.js1
-rw-r--r--lib/sendgrid.js3
-rw-r--r--test/index.test.js3
-rw-r--r--test/lib/email.test.js6
-rw-r--r--test/lib/sendgrid.test.js1
-rw-r--r--test/lib/smtpapi_header.test.js35
-rw-r--r--test/mocha.opts2
-rw-r--r--test/test_helper.js3
8 files changed, 44 insertions, 10 deletions
diff --git a/index.js b/index.js
index e6f654b..bda3c75 100644
--- a/index.js
+++ b/index.js
@@ -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');