summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/integration/sendgrid.test.js28
-rw-r--r--test/lib/email.test.js38
-rw-r--r--test/lib/sendgrid.test.js2
3 files changed, 67 insertions, 1 deletions
diff --git a/test/integration/sendgrid.test.js b/test/integration/sendgrid.test.js
index 18b8ad7..53c7a90 100644
--- a/test/integration/sendgrid.test.js
+++ b/test/integration/sendgrid.test.js
@@ -357,6 +357,34 @@ describe('SendGrid #skip', function () {
});
});
+ it('handles the send_at scheduling param', function(done) {
+ payload.subject += "handles the send_at scheduling param";
+
+ var email = new Email(payload);
+ email.setSendAt(Math.floor(new Date() / 1000) + 60);
+ sendgrid.send(email, function(err, json) {
+ expect(err).to.be.null;
+ expect(json.message).to.equal('success');
+ done();
+ });
+ });
+
+ it('handles the send_each_at scheduling param', function(done) {
+ payload.subject += "handles the send_each_at scheduling param";
+ payload.to = [process.env.TO, 'sendgrid-nodejs@mailinator.com']
+ var email = new Email(payload);
+ email.addTo(payload.to[0]);
+ email.addTo(payload.to[1]);
+ email.addSendEachAt(Math.floor(new Date() / 1000) + 60);
+ email.addSendEachAt(Math.floor(new Date() / 1000) + 300);
+
+ sendgrid.send(email, function(err, json) {
+ expect(err).to.be.null;
+ expect(json.message).to.equal('success');
+ done();
+ });
+ });
+
it('handles filters', function(done) {
payload.subject += "handles filters";
diff --git a/test/lib/email.test.js b/test/lib/email.test.js
index e5aab66..20f99ca 100644
--- a/test/lib/email.test.js
+++ b/test/lib/email.test.js
@@ -189,6 +189,44 @@ describe('Email', function () {
expect(email.smtpapi.header.unique_args).to.eql({unique_arg1: 'value', unique_arg2: 'value'});
});
+ it('should be possible to setSendAt', function() {
+ var email = new Email();
+ expect(email.smtpapi.header.send_at).to.be.empty;
+ expect(email.smtpapi.header.send_each_at).to.eql([]);
+ email.setSendAt(1409348513);
+ expect(email.smtpapi.header.send_at).to.eql(1409348513);
+ expect(email.smtpapi.header.send_each_at).to.eql([]);
+ });
+
+ it('should be possible to setSendEachAt', function() {
+ var email = new Email();
+ expect(email.smtpapi.header.send_at).to.be.empty;
+ expect(email.smtpapi.header.send_each_at).to.eql([]);
+ email.setSendEachAt([1409348513, 1409348514]);
+ expect(email.smtpapi.header.send_at).to.be.empty;
+ expect(email.smtpapi.header.send_each_at).to.eql([1409348513, 1409348514]);
+ });
+
+ it('should be possible to addSendEachAt', function() {
+ var email = new Email();
+ expect(email.smtpapi.header.send_at).to.be.empty;
+ expect(email.smtpapi.header.send_each_at).to.eql([]);
+ email.addSendEachAt(1409348513);
+ email.addSendEachAt(1409348514);
+ expect(email.smtpapi.header.send_at).to.be.empty;
+ expect(email.smtpapi.header.send_each_at).to.eql([1409348513, 1409348514]);
+ });
+
+ it('should be possible to setSendEachAt and addSendEachAt', function() {
+ var email = new Email();
+ expect(email.smtpapi.header.send_at).to.be.empty;
+ expect(email.smtpapi.header.send_each_at).to.eql([]);
+ email.setSendEachAt([1409348513]);
+ email.addSendEachAt(1409348514);
+ expect(email.smtpapi.header.send_at).to.be.empty;
+ expect(email.smtpapi.header.send_each_at).to.eql([1409348513, 1409348514]);
+ });
+
it('should be possible to setUniqueArgs', function() {
var email = new Email();
expect(email.smtpapi.header.unique_args).to.eql({});
diff --git a/test/lib/sendgrid.test.js b/test/lib/sendgrid.test.js
index 335c13c..218660f 100644
--- a/test/lib/sendgrid.test.js
+++ b/test/lib/sendgrid.test.js
@@ -15,7 +15,7 @@ describe('SendGrid', function () {
});
it('version should be set', function() {
- expect(sendgrid.version).to.equal("1.3.0");
+ expect(sendgrid.version).to.equal("1.4.0");
});
it('should attach a options object to self', function() {