-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
58 lines (52 loc) · 1.59 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
'use strict';
const t = require('chai').assert;
const assert = require('assert');
describe('smtp', function() {
assert(process.env.SMTP_HOST, 'process.env.SMTP_HOST environment variable is missing');
assert(process.env.SMTP_PORT, 'process.env.SMTP_PORT environment variable is missing');
assert(process.env.SMTP_USER, 'process.env.SMTP_USER environment variable is missing');
assert(process.env.SMTP_PASS, 'process.env.SMTP_PASS environment variable is missing');
it('should throw an error if from is bad defined', function() {
t.throws(function(){
provider = require('./')({
host: process.env.SMTP_HOST,
port: process.env.SMTP_PORT,
secure: true,
debug: true,
auth:{
user: process.env.SMTP_USER,
pass: process.env.SMTP_PASS,
}
});
});
});
it('should send an email', function(f) {
const provider = require('./')({
host: process.env.SMTP_HOST,
port: process.env.SMTP_PORT,
secure: true,
debug: true,
auth:{
user: process.env.SMTP_USER,
pass: process.env.SMTP_PASS,
}
}, {
from: 'Sender Name <[email protected]>'
});
provider.send({
html: '<strong>hello :)</strong>',
text: 'hello :)',
data: {
email: '[email protected]',
name: 'Transacemail Sendgrid'
}
}, function(err, result) {
t.strictEqual(err, null);
t.deepEqual(result, [{
email: '[email protected]',
status: 'sent'
}]);
f();
});
});
});