UNPKG

2.1 kBJavaScriptView Raw
1var mocha = require('mocha');
2var assert = require('assert');
3var nconf = require('nconf');
4var testingKeys = nconf.env().file({
5 file: __dirname + '/testing_keys.json'
6});
7var util = require('util');
8var merge = require('merge');
9
10var postmark = require('../lib/postmark/index.js');
11
12describe('client email sending', function() {
13 // allow some of the more intensive tests to take longer.
14 this.timeout(30000);
15 var _client = null;
16
17 beforeEach(function() {
18 _client = new postmark.Client(testingKeys.get('WRITE_TEST_SERVER_TOKEN'));
19 });
20
21 it('can send single email ("send" alias)', function(done) {
22 _client.send({
23 To: testingKeys.get('WRITE_TEST_EMAIL_RECIPIENT_ADDRESS'),
24 From: testingKeys.get('WRITE_TEST_SENDER_EMAIL_ADDRESS'),
25 Subject: "Hello from the node.js client! " + new Date(),
26 TextBody: "Testing 1.2.3..."
27 }, done);
28 });
29
30 it('can send single email', function(done) {
31 _client.sendEmail({
32 To: testingKeys.get('WRITE_TEST_EMAIL_RECIPIENT_ADDRESS'),
33 From: testingKeys.get('WRITE_TEST_SENDER_EMAIL_ADDRESS'),
34 Subject: "Hello from the node.js client! " + new Date(),
35 TextBody: "Testing 1.2.3..."
36 }, done);
37 });
38
39 it('can send a batch of emails ("batch" alias)', function(done) {
40 var emailBatch = [];
41
42 for (var i = 0; i < 3; i++) {
43 emailBatch.push({
44 to: testingKeys.get('WRITE_TEST_EMAIL_RECIPIENT_ADDRESS'),
45 from: testingKeys.get('WRITE_TEST_SENDER_EMAIL_ADDRESS'),
46 subject: "Hello from the node.js client! " + new Date(),
47 textBody: "Testing batch email: " + i
48 });
49 }
50 _client.batch(emailBatch, done);
51 });
52
53 it('can send a batch of emails', function(done) {
54 var emailBatch = [];
55
56 for (var i = 0; i < 3; i++) {
57 emailBatch.push({
58 to: testingKeys.get('WRITE_TEST_EMAIL_RECIPIENT_ADDRESS'),
59 from: testingKeys.get('WRITE_TEST_SENDER_EMAIL_ADDRESS'),
60 subject: "Hello from the node.js client! " + new Date(),
61 textBody: "Testing batch email: " + i
62 });
63 }
64 _client.sendEmailBatch(emailBatch, done);
65 });
66});
\No newline at end of file