Browse files

added an integration test

  • Loading branch information...
1 parent 4712f9e commit 269c74caac2011d5873a3b09386bdd4c3a4cf1f2 @partkyle partkyle committed May 16, 2012
Showing with 18 additions and 0 deletions.
  1. +12 −0 test/integration/sendgrid.test.js
  2. +6 −0 test/lib/email.test.js
View
12 test/integration/sendgrid.test.js
@@ -117,6 +117,18 @@ describe('SendGrid', function () {
});
});
+ it('should support toname and fromname', function(done) {
+ var mail = new Email(text_params);
+ mail.toname = 'toname test';
+ mail.fromname = 'from me';
+ mail.subject = 'testing to and from names';
+
+ sendgrid.send(mail, function(success, message) {
+ expect(success).to.be.true;
+ done();
+ });
+ });
+
it('should report errors to the user', function(done) {
var mail = new Email({});
sendgrid.send(mail, function(success, message) {
View
6 test/lib/email.test.js
@@ -52,32 +52,38 @@ describe('Email', function () {
var smtpFormat = email.toSmtpFormat();
expect(smtpFormat.to).to.be.empty;
});
+
it("should not set a fromname if one isn't provided", function() {
var email = new Email({from: 'test@test.com', subject: 'testing', text: 'testing'});
var webFormat = email.toWebFormat();
expect(webFormat.fromname).to.be.empty;
});
+
it("should set a fromname if one is provided", function() {
var email = new Email({from: 'test@test.com', fromname:'Tester T. Testerson', subject: 'testing', text: 'testing'});
var webFormat = email.toWebFormat();
expect(webFormat.fromname).to.equal('Tester T. Testerson');
});
+
it("should not set a toname if one isn't provided", function() {
var email = new Email({from: 'test@test.com', subject: 'testing', text: 'testing'});
var webFormat = email.toWebFormat();
expect(webFormat.toname).to.be.empty;
});
+
it("should set a toname if one is provided", function() {
var email = new Email({from: 'test@test.com', to:'test@test.com', toname:'Tester T. Testerson', subject: 'testing', text: 'testing'});
var webFormat = email.toWebFormat();
expect(webFormat.toname).to.equal('Tester T. Testerson');
});
+
it("should set multiple tonames if several are provided", function() {
var email = new Email({from: 'test@test.com', to: ['test@test.com', 'test2@test.com'], toname:['Tester T. Testerson', 'Test2 M. Testerson'], subject: 'testing', text: 'testing'});
var webFormat = email.toWebFormat();
expect(webFormat.toname[0]).to.equal('Tester T. Testerson');
expect(webFormat.toname[1]).to.equal('Test2 M. Testerson');
});
+
describe('files', function() {
it('should support adding attachments via path', function() {
var email = new Email();

0 comments on commit 269c74c

Please sign in to comment.