Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Pr/84 #85

Merged
merged 8 commits into from
Commits on Aug 31, 2013
  1. @jcblw

    fixing context and magically invocating functions, also adding also a…

    jcblw authored
    …llowing send to map to either smtp or http
  2. @jcblw

    Merge remote-tracking branch 'me/master'

    jcblw authored
    * me/master:
      Add badge from fury.io
      Fix ;
  3. @jcblw

    fixing shrinkwrap

    jcblw authored
  4. @jcblw

    adding bottom object context

    jcblw authored
Commits on Sep 2, 2013
  1. @motdotla
  2. @motdotla
  3. @motdotla
Commits on Sep 3, 2013
  1. @motdotla

    Update shrinkwrap

    motdotla authored
This page is out of date. Refresh to see the latest.
View
31 README.md
@@ -31,7 +31,7 @@ Add the following to your `package.json` file:
...
"dependencies": {
...
- "sendgrid": "0.3.0-rc.1.6"
+ "sendgrid": "0.3.0-rc.1.7"
}
}
```
@@ -78,22 +78,10 @@ sendgrid.send(payload, function(err, json) {
});
```
-**Alternatively you can send it explicitly via Web or SMTP.**
+**Alternatively you can opt to send via SMTP rather than via the WEB API. Just initialize with the `api: 'smtp'` option.**
```javascript
-sendgrid.web(payload, function(err, json) {
- if (err) { console.error(err); }
- console.log(json);
-});
-```
-
-Or
-
-```javascript
-sendgrid.smtp(payload, function(err, json) {
- if (err) { console.error(err); }
- console.log(json);
-});
+var sendgrid = require('sendgrid')(api_user, api_key, {api: 'smtp'});
```
## Power Usage
@@ -107,7 +95,7 @@ There are two additioanl objects built into this library that will help you use
Email helps you more powerfully prepare your message to be sent.
-NOTE: anything that is available in the Email constructor is available for use in the `sendgrid.send`, `sendgrid.web`, and `sendgrid.smtp` functions.
+NOTE: anything that is available in the Email constructor is available for use in the `sendgrid.send` function.
To get started create an Email object:
@@ -271,22 +259,21 @@ email.addHtml('<div>Our logo:<img src="cid:the_logo"></div>');
## SMTP options
-You can change the port to 465 if you prefer. After initializing simply code `sendgrid.port = 465`
+You can change the port to 465 if you prefer. When initializing with the smtp api, also initialize with the port.
```javascript
-var sendgrid = require('sendgrid')('username', 'password');
-sendgrid.port = 465;
+var sendgrid = require('sendgrid')('username', 'password', {api: 'smtp', port: 465});
var payload = {...};
-sendgrid.smtp(payload, function(err, json) {
+sendgrid.send(payload, function(err, json) {
if (err) { console.error(err); }
console.log(json);
});
```
-You can also pass some additional fields through the smtp to the underlying nodemailer. The list of these fields are [here](https://github.com/andris9/Nodemailer#e-mail-message-fields).
+You can also pass some additional fields through the smtp to the underlying nodemailer. The list of these fields are [here](https://github.com/andris9/Nodemailer#e-mail-message-fields). To do this, you have to use the underlying `.smtp` method. This is really for power users.
```javascript
-var sendgrid = require('sendgrid')('username', 'password');
+var sendgrid = require('sendgrid')('username', 'password', {api: 'smtp'});
var payload = {...};
var nodeMailerOptions = {
messageId: "some-message-id"
View
54 lib/sendgrid.js
@@ -6,12 +6,23 @@ var _ = require('underscore');
var request = require('request');
var Email = require('./email');
var SmtpapiHeaders = require('./smtpapi_headers');
+var Sendgrid = function(api_user, api_key, options) {
-module.exports = function(api_user, api_key) {
- var self;
+ if( !(this instanceof Sendgrid) ) {
+ return new Sendgrid(api_user, api_key, options);
+ }
+
+ var _this = this;
+ this.options = options || {};
+ this.options.port = this.options.port || 587;
+
+ var send = function() {
+ if ( _this.options.api === 'smtp') {
+ smtp.apply(this, arguments);
+ return true;
+ }
- var send = function(email, callback) {
- web(email, callback);
+ web.apply( this, arguments );
}
/*
@@ -24,9 +35,7 @@ module.exports = function(api_user, api_key) {
* This parameter is optional.
*/
var web = function(email, callback) {
- self = this;
var callback = callback || function() { };
-
if (email.constructor !== Email) {
email = new Email(email);
}
@@ -46,7 +55,6 @@ module.exports = function(api_user, api_key) {
* This parameter is optional.
*/
var smtp = function(email, nodeMailerOptions, callback) {
- self = this;
// Support a callback without nodeMailerOptions
if (! callback && typeof nodeMailerOptions === "function") {
@@ -113,7 +121,7 @@ module.exports = function(api_user, api_key) {
// SMTP settings
var smtp_settings = {
host: "smtp.sendgrid.net",
- port: parseInt(self.port),
+ port: parseInt(_this.port),
requiresAuth: true,
auth: {
user: api_user,
@@ -124,7 +132,7 @@ module.exports = function(api_user, api_key) {
smtp_settings['secureConnection'] = true;
}
- var smtpTransport = nodemailer.createTransport(self.SMTP, smtp_settings);
+ var smtpTransport = nodemailer.createTransport(_this.SMTP, smtp_settings);
var smtpParams = email.toSmtpFormat();
@@ -144,16 +152,18 @@ module.exports = function(api_user, api_key) {
/*
* Expose public API calls
*/
- return {
- version : package_json.version,
- port : 587,
- SMTP : "SMTP",
- Email : Email,
- SmtpapiHeaders : SmtpapiHeaders,
- api_user : api_user,
- api_key : api_key,
- web : web,
- smtp : smtp,
- send : send
- };
-}
+ this.version = package_json.version;
+ this.SMTP = "SMTP";
+ this.Email = Email;
+ this.SmtpapiHeaders = SmtpapiHeaders;
+ this.api_user = api_user;
+ this.api_key = api_key;
+ this.web = web;
+ this.smtp = smtp;
+ this.send = send;
+ this.options = this.options;
+ this.port = this.options.port;
+ return this;
+};
+
+module.exports = Sendgrid;
View
89 npm-shrinkwrap.json
@@ -1,39 +1,42 @@
{
"name": "sendgrid",
- "version": "0.3.0-rc.1.6",
+ "version": "0.3.0-rc.1.7",
"dependencies": {
"underscore": {
"version": "1.4.4",
- "from": "underscore@1.4.4",
+ "from": "https://registry.npmjs.org/underscore/-/underscore-1.4.4.tgz",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.4.4.tgz"
},
"nodemailer": {
"version": "0.4.4",
- "from": "nodemailer@0.4.4",
+ "from": "https://registry.npmjs.org/nodemailer/-/nodemailer-0.4.4.tgz",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-0.4.4.tgz",
"dependencies": {
"mailcomposer": {
"version": "0.1.34",
- "from": "mailcomposer@~0.1",
+ "from": "mailcomposer@0.1.34",
+ "resolved": "https://registry.npmjs.org/mailcomposer/-/mailcomposer-0.1.34.tgz",
"dependencies": {
"mimelib": {
"version": "0.2.12",
- "from": "mimelib@~0.2",
+ "from": "mimelib@0.2.12",
"dependencies": {
"encoding": {
"version": "0.1.6",
- "from": "encoding@~0.1",
+ "from": "encoding@0.1.6",
+ "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.6.tgz",
"dependencies": {
"iconv-lite": {
"version": "0.2.7",
- "from": "iconv-lite@0.2.7",
+ "from": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.2.7.tgz",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.2.7.tgz"
}
}
},
"addressparser": {
"version": "0.1.3",
- "from": "addressparser@~0.1"
+ "from": "addressparser@0.1.3",
+ "resolved": "https://registry.npmjs.org/addressparser/-/addressparser-0.1.3.tgz"
}
}
}
@@ -41,16 +44,18 @@
},
"simplesmtp": {
"version": "0.3.4",
- "from": "simplesmtp@~0.2 || ~0.3",
+ "from": "https://registry.npmjs.org/simplesmtp/-/simplesmtp-0.3.4.tgz",
"resolved": "https://registry.npmjs.org/simplesmtp/-/simplesmtp-0.3.4.tgz",
"dependencies": {
"rai": {
"version": "0.1.7",
- "from": "rai@~0.1"
+ "from": "rai@0.1.7",
+ "resolved": "https://registry.npmjs.org/rai/-/rai-0.1.7.tgz"
},
"xoauth2": {
"version": "0.1.8",
- "from": "xoauth2@~0.1"
+ "from": "xoauth2@0.1.8",
+ "resolved": "https://registry.npmjs.org/xoauth2/-/xoauth2-0.1.8.tgz"
}
}
}
@@ -58,82 +63,92 @@
},
"mime": {
"version": "1.2.9",
- "from": "mime@1.2.9",
+ "from": "https://registry.npmjs.org/mime/-/mime-1.2.9.tgz",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.2.9.tgz"
},
"request": {
"version": "2.22.0",
- "from": "request@2.22.0",
+ "from": "https://registry.npmjs.org/request/-/request-2.22.0.tgz",
"resolved": "https://registry.npmjs.org/request/-/request-2.22.0.tgz",
"dependencies": {
"qs": {
"version": "0.6.5",
- "from": "qs@~0.6.0",
+ "from": "https://registry.npmjs.org/qs/-/qs-0.6.5.tgz",
"resolved": "https://registry.npmjs.org/qs/-/qs-0.6.5.tgz"
},
"json-stringify-safe": {
"version": "4.0.0",
- "from": "json-stringify-safe@~4.0.0"
+ "from": "json-stringify-safe@4.0.0",
+ "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-4.0.0.tgz"
},
"forever-agent": {
"version": "0.5.0",
- "from": "forever-agent@~0.5.0"
+ "from": "forever-agent@0.5.0",
+ "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.5.0.tgz"
},
"tunnel-agent": {
"version": "0.3.0",
- "from": "tunnel-agent@~0.3.0"
+ "from": "tunnel-agent@0.3.0",
+ "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.3.0.tgz"
},
"http-signature": {
"version": "0.10.0",
- "from": "http-signature@~0.10.0",
+ "from": "http-signature@0.10.0",
+ "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-0.10.0.tgz",
"dependencies": {
"assert-plus": {
"version": "0.1.2",
- "from": "assert-plus@0.1.2",
+ "from": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.1.2.tgz",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.1.2.tgz"
},
"asn1": {
"version": "0.1.11",
- "from": "asn1@0.1.11",
+ "from": "https://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz"
},
"ctype": {
"version": "0.5.2",
- "from": "ctype@0.5.2",
+ "from": "https://registry.npmjs.org/ctype/-/ctype-0.5.2.tgz",
"resolved": "https://registry.npmjs.org/ctype/-/ctype-0.5.2.tgz"
}
}
},
"hawk": {
"version": "0.13.1",
- "from": "hawk@~0.13.0",
+ "from": "hawk@0.13.1",
+ "resolved": "https://registry.npmjs.org/hawk/-/hawk-0.13.1.tgz",
"dependencies": {
"hoek": {
"version": "0.8.5",
- "from": "hoek@0.8.x",
+ "from": "https://registry.npmjs.org/hoek/-/hoek-0.8.5.tgz",
"resolved": "https://registry.npmjs.org/hoek/-/hoek-0.8.5.tgz"
},
"boom": {
"version": "0.4.2",
- "from": "boom@0.4.x",
+ "from": "boom@0.4.2",
+ "resolved": "https://registry.npmjs.org/boom/-/boom-0.4.2.tgz",
"dependencies": {
"hoek": {
"version": "0.9.1",
- "from": "hoek@0.9.x"
+ "from": "hoek@0.9.1",
+ "resolved": "https://registry.npmjs.org/hoek/-/hoek-0.9.1.tgz"
}
}
},
"cryptiles": {
"version": "0.2.2",
- "from": "cryptiles@0.2.x"
+ "from": "cryptiles@0.2.2",
+ "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-0.2.2.tgz"
},
"sntp": {
"version": "0.2.4",
- "from": "sntp@0.2.x",
+ "from": "sntp@0.2.4",
+ "resolved": "https://registry.npmjs.org/sntp/-/sntp-0.2.4.tgz",
"dependencies": {
"hoek": {
"version": "0.9.1",
- "from": "hoek@0.9.x"
+ "from": "hoek@0.9.1",
+ "resolved": "https://registry.npmjs.org/hoek/-/hoek-0.9.1.tgz"
}
}
}
@@ -141,30 +156,33 @@
},
"aws-sign": {
"version": "0.3.0",
- "from": "aws-sign@~0.3.0",
+ "from": "https://registry.npmjs.org/aws-sign/-/aws-sign-0.3.0.tgz",
"resolved": "https://registry.npmjs.org/aws-sign/-/aws-sign-0.3.0.tgz"
},
"oauth-sign": {
"version": "0.3.0",
- "from": "oauth-sign@~0.3.0",
+ "from": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.3.0.tgz",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.3.0.tgz"
},
"cookie-jar": {
"version": "0.3.0",
- "from": "cookie-jar@~0.3.0"
+ "from": "cookie-jar@0.3.0",
+ "resolved": "https://registry.npmjs.org/cookie-jar/-/cookie-jar-0.3.0.tgz"
},
"node-uuid": {
"version": "1.4.0",
- "from": "node-uuid@~1.4.0"
+ "from": "node-uuid@1.4.0",
+ "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.0.tgz"
},
"form-data": {
"version": "0.0.8",
- "from": "form-data@0.0.8",
+ "from": "https://registry.npmjs.org/form-data/-/form-data-0.0.8.tgz",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-0.0.8.tgz",
"dependencies": {
"combined-stream": {
"version": "0.0.4",
- "from": "combined-stream@~0.0.4",
+ "from": "combined-stream@0.0.4",
+ "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.4.tgz",
"dependencies": {
"delayed-stream": {
"version": "0.0.5",
@@ -174,7 +192,8 @@
},
"async": {
"version": "0.2.9",
- "from": "async@~0.2.7"
+ "from": "async@0.2.9",
+ "resolved": "https://registry.npmjs.org/async/-/async-0.2.9.tgz"
}
}
}
View
2  package.json
@@ -9,7 +9,7 @@
],
"name": "sendgrid",
"description": "A NodeJS implementation of the SendGrid Api.",
- "version": "0.3.0-rc.1.6",
+ "version": "0.3.0-rc.1.7",
"homepage": "http://sendgrid.com",
"repository": {
"type": "git",
View
58 test/integration/sendgrid.test.js
@@ -18,15 +18,12 @@ var SendGrid = require('../../lib/sendgrid')
describe('SendGrid #skip', function () {
var sendgrid;
- beforeEach(function() {
- sendgrid = new SendGrid(API_USER, API_KEY);
- });
-
describe('#send', function() {
var payload;
beforeEach(function() {
- payload = Object.create(default_payload);
+ sendgrid = new SendGrid(API_USER, API_KEY);
+ payload = Object.create(default_payload);
payload.subject += "web ";
});
@@ -384,6 +381,7 @@ describe('SendGrid #skip', function () {
var payload;
beforeEach(function() {
+ sendgrid = new SendGrid(API_USER, API_KEY, {api: 'smtp'});
sendgrid.SMTP = "SMTP";
payload = Object.create(default_payload);
@@ -391,7 +389,7 @@ describe('SendGrid #skip', function () {
});
it('has a blank send payload', function(done) {
- sendgrid.smtp({}, function(err, json) {
+ sendgrid.send({}, function(err, json) {
expect(err.message).to.equal("501 Syntax error");
done();
@@ -402,7 +400,7 @@ describe('SendGrid #skip', function () {
payload.subject += "has an optional callback";
expect(function() {
- sendgrid.smtp(payload);
+ sendgrid.send(payload);
}).to.not.throw(Error);
done();
@@ -411,7 +409,7 @@ describe('SendGrid #skip', function () {
it('sends successfully', function(done) {
payload.subject += "sends successfully";
- sendgrid.smtp(payload, function(err, json) {
+ sendgrid.send(payload, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -423,7 +421,7 @@ describe('SendGrid #skip', function () {
payload.subject += "sends successfully over port 465";
sendgrid.port = 465;
- sendgrid.smtp(payload, function(err, json) {
+ sendgrid.send(payload, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -435,7 +433,7 @@ describe('SendGrid #skip', function () {
payload.subject += "has array of TOs";
payload.to = [process.env.TO]
- sendgrid.smtp(payload, function(err, json) {
+ sendgrid.send(payload, function(err, json) {
expect(err).to.be.null;
done();
@@ -446,7 +444,7 @@ describe('SendGrid #skip', function () {
payload.subject += "has multiple array of TOs";
payload.to = [process.env.TO, 'sendgrid-nodejs@mailinator.com']
- sendgrid.smtp(payload, function(err, json) {
+ sendgrid.send(payload, function(err, json) {
expect(err).to.be.null;
done();
@@ -456,7 +454,7 @@ describe('SendGrid #skip', function () {
it('encodes unicode like ✔', function(done) {
payload.subject += "encodes unicode like ✔";
- sendgrid.smtp(payload, function(err, json) {
+ sendgrid.send(payload, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -469,7 +467,7 @@ describe('SendGrid #skip', function () {
payload.toname = "to name";
payload.fromname = "from name";
- sendgrid.smtp(payload, function(err, json) {
+ sendgrid.send(payload, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -483,7 +481,7 @@ describe('SendGrid #skip', function () {
{filename: 'secret.txt', content: new Buffer("File Content")}
];
- sendgrid.smtp(payload, function(err, json) {
+ sendgrid.send(payload, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -496,7 +494,7 @@ describe('SendGrid #skip', function () {
var email = new Email(payload);
email.addFile({filename: 'secret.txt', content: new Buffer("File Content")});
- sendgrid.smtp(email, function(err, json) {
+ sendgrid.send(email, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -510,7 +508,7 @@ describe('SendGrid #skip', function () {
{filename: 'icon.jpg', url: "http://i.imgur.com/2fDh8.jpg"}
];
- sendgrid.smtp(payload, function(err, json) {
+ sendgrid.send(payload, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -523,7 +521,7 @@ describe('SendGrid #skip', function () {
var email = new Email(payload);
email.addFile({filename: 'icon.jpg', url: "http://i.imgur.com/2fDh8.jpg"});
- sendgrid.smtp(email, function(err, json) {
+ sendgrid.send(email, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -537,7 +535,7 @@ describe('SendGrid #skip', function () {
{path: __dirname + '/../assets/logo.png'}
];
- sendgrid.smtp(payload, function(err, json) {
+ sendgrid.send(payload, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -550,7 +548,7 @@ describe('SendGrid #skip', function () {
var email = new Email(payload);
email.addFile({path: __dirname + '/../assets/logo.png'});
- sendgrid.smtp(email, function(err, json) {
+ sendgrid.send(email, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -564,7 +562,7 @@ describe('SendGrid #skip', function () {
{filename: 'empty-test'}
]
- sendgrid.smtp(payload, function(err, json) {
+ sendgrid.send(payload, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -577,7 +575,7 @@ describe('SendGrid #skip', function () {
var email = new Email(payload);
email.addFile({filename: 'empty-test'});
- sendgrid.smtp(email, function(err, json) {
+ sendgrid.send(email, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -596,7 +594,7 @@ describe('SendGrid #skip', function () {
]
payload.html = "<img src='cid:photo1'/>";
- sendgrid.smtp(payload, function(err, json) {
+ sendgrid.send(payload, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -614,7 +612,7 @@ describe('SendGrid #skip', function () {
});
email.html = "<img src='cid:photo1'/>";
- sendgrid.smtp(email, function(err, json) {
+ sendgrid.send(email, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -632,7 +630,7 @@ describe('SendGrid #skip', function () {
}
]
- sendgrid.smtp(payload, function(err, json) {
+ sendgrid.send(payload, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -649,7 +647,7 @@ describe('SendGrid #skip', function () {
contentType: ''
});
- sendgrid.smtp(email, function(err, json) {
+ sendgrid.send(email, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -662,7 +660,7 @@ describe('SendGrid #skip', function () {
var email = new Email(payload);
email.replyto = 'noreply@sendgrid.com';
- sendgrid.smtp(email, function(err, json) {
+ sendgrid.send(email, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -676,7 +674,7 @@ describe('SendGrid #skip', function () {
var email = new Email(payload);
email.addFilterSetting('footer', 'enable', 1);
email.addFilterSetting('footer', 'text/plain', 'This is mah footer!');
- sendgrid.smtp(email, function(err, json) {
+ sendgrid.send(email, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -690,7 +688,7 @@ describe('SendGrid #skip', function () {
var email = new Email(payload);
email.addFilterSetting('footer', 'enable', 1);
email.addFilterSetting('footer', 'text/plain', 'This is mah footer with a ✔ in it!');
- sendgrid.smtp(email, function(err, json) {
+ sendgrid.send(email, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -704,7 +702,7 @@ describe('SendGrid #skip', function () {
var email = new Email(payload);
email.addSubVal('-name-',['Panda', 'Cow']);
email.html = 'You are a <strong>-name-</strong>';
- sendgrid.smtp(email, function(err, json) {
+ sendgrid.send(email, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
@@ -722,7 +720,7 @@ describe('SendGrid #skip', function () {
email.addSection({'-kyleSection-': 'I heard you liked batman so I killed your parents'});
email.addSection({'-davidSection-': 'Metal gear?!!?!!!!eleven'});
email.html = "Yo -name-!<br /> Here's a meme for you:<br /> -meme-";
- sendgrid.smtp(email, function(err, json) {
+ sendgrid.send(email, function(err, json) {
expect(err).to.be.null;
expect(json.message).to.equal('success');
View
14 test/lib/sendgrid.test.js
@@ -19,15 +19,25 @@ describe('SendGrid', function () {
});
it('version should be set', function() {
- expect(sendgrid.version).to.equal("0.3.0-rc.1.6");
+ expect(sendgrid.version).to.equal("0.3.0-rc.1.7");
});
- it('SMTP_PORT should be set and settable', function() {
+ it('should attach a options object to self', function() {
+ expect( typeof sendgrid.options).to.equal('object');
+ });
+
+ it('port should be set and settable', function() {
expect(sendgrid.port).to.equal(587);
sendgrid.port = 465;
expect(sendgrid.port).to.equal(465);
});
+ it('options.port should be set and settable', function() {
+ expect(sendgrid.options.port).to.equal(587);
+ var sendgrid2 = require('../../lib/sendgrid')('username', 'password', {api: 'smtp', port: 465});
+ expect(sendgrid2.options.port).to.equal(465);
+ });
+
describe('#send', function() {
var payload, mock, webApi, postParams, postParamsString;
Something went wrong with that request. Please try again.