summaryrefslogtreecommitdiffstats
path: root/test/lib/email.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/lib/email.test.js')
-rw-r--r--test/lib/email.test.js53
1 files changed, 40 insertions, 13 deletions
diff --git a/test/lib/email.test.js b/test/lib/email.test.js
index 120a3da..60f29f3 100644
--- a/test/lib/email.test.js
+++ b/test/lib/email.test.js
@@ -45,18 +45,6 @@ describe('Email', function () {
expect(format.to).to.equal(payload.to);
});
- it('should not have multiple TOs if as an array but also set on smtpapi via addTo', function() {
- var payload = Object.create(default_payload);
- payload.to = ['david.tomberlin@sendgrid.com', 'otherguy@sendgrid.com'];
- var email = new Email(payload);
- email.addTo(payload.to[0]);
- email.addTo(payload.to[1]);
-
- var format = email.toWebFormat();
-
- expect(format.to).to.equal(payload.from);
- });
-
it('should have multiple BCCs if as an array', function() {
var payload = Object.create(default_payload);
payload.bcc = ['david.tomberlin@sendgrid.com', 'otherguy@sendgrid.com'];
@@ -119,11 +107,50 @@ describe('Email', function () {
var payload = Object.create(default_payload);
payload.to = "";
var email = new Email(payload);
- email.addTo("test@test.com");
+ email.addSmtpapiTo("test@test.com");
var format = email.toWebFormat();
+ expect(format.to).to.not.be.empty;
expect(JSON.parse(format['x-smtpapi']).to).to.not.be.empty;
+ });
+
+ it('should have to addresses if there is no tos set but there are smtpapi tos set', function() {
+ var payload = Object.create(default_payload);
+ payload.to = "";
+ var email = new Email(payload);
+ email.setSmtpapiTos(["test@test.com", "test2@test.com"]);
+ var format = email.toWebFormat();
+
+ expect(format.to).to.not.be.empty;
+ expect(JSON.parse(format['x-smtpapi']).to).to.not.be.empty;
+ expect(JSON.parse(format['x-smtpapi']).to).to.be.an.array;
+ });
+
+ it('should have a to address using addTo if there is no smtpapi to', function(){
+ var payload = Object.create(default_payload);
+ payload.to = "";
+ var email = new Email(payload);
+ email.addTo('test@test.com');
+ email.addTo('test1@test.com');
+ var format = email.toWebFormat();
+
+ expect(format.to).to.not.be.empty;
+ expect(format.to[0]).to.equal('test@test.com');
+ expect(format.to[1]).to.equal('test1@test.com');
+ });
+
+ it('should have a to addresses using setTos if there is no smtpapi to', function(){
+ var payload = Object.create(default_payload);
+ payload.to = "";
+ var email = new Email(payload);
+ email.setTos(['test@test.com', 'test1@test.com']);
+
+ var format = email.toWebFormat();
+
expect(format.to).to.not.be.empty;
+ expect(format.to).to.be.an.array;
+ expect(format.to[0]).to.equal('test@test.com');
+ expect(format.to[1]).to.equal('test1@test.com');
});
it("should set a fromname if one is provided", function() {