-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
executable file
·108 lines (100 loc) · 3 KB
/
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env node
/*
* Tart Mailer - Node.js API Client - Regression Tests
*
* Copyright (c) 2013, Tart İnternet Teknolojileri Ticaret AŞ
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
* granted, provided that the above copyright notice and this permission notice appear in all copies.
*
* The software is provided "as is" and the author disclaims all warranties with regard to the software including all
* implied warranties of merchantability and fitness. In no event shall the author be liable for any special, direct,
* indirect, or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether
* in an action of contract, negligence or other tortious action, arising out of or in connection with the use or
* performance of this software.
*/
var tartMailer = require('./');
var client = new tartMailer({
url: 'http://localhost:8080/',
auth: {
user: '[email protected]',
pass: 'secret'
}
});
var tests = [
['getSender'],
['setSender', {'fromName': 'Osman'}],
['addEmail', {
'bulk': true,
'redirectURL': 'http://tr.wikipedia.org',
'variations': [
{
'subject': 'Wiki',
'plainbody': 'Check out Wikipedia.'
},
{
'subject': 'Wikipedia',
'plainbody': 'Try Wikipedia.'
}
]
}],
['listEmails'],
['filterEmails', {
'bulk': true
}],
['addEmailVariation', 1, {
'subject': 'Extra Variation',
'plainBody': 'This is the one.'
}],
['getEmail', 1],
['getEmailVariation', 1, 1],
['upsertEmailVariation', 1, 2, {
'subject': 'Extra Variation',
'plainBody': 'This is the second.'
}],
['listMessagesSend', 1],
['filterMessagesSend', 1, {
'sent': false
}],
['listSubscribers'],
['subscribe', '[email protected]', {
'locale': 'tr_TR',
'properties': {
'firstname': 'Osman',
'lastname': 'Kabalak'
}
}],
['filterSubscribers', {
'locale': 'tr_TR',
'properties': {
'firstname': 'Osman'
}
}],
['sendToSubscriber', '[email protected]', {
'redirectURL': 'http://click.xxx/?from=mailer',
'subject': 'Click this link!',
'plainBody': 'Click: {redirecturl}',
'hTMLBody': '<h1>XXX</h1><p><a href=\'{redirecturl}\'>click</a></p>'
}],
['listMessagesSendToSubscriber', '[email protected]'],
['filterMessagesSendToSubscriber', '[email protected]', {
'sent': false
}]
];
run();
function run() {
var args = tests.shift();
var method = args.shift();
args.push(callback);
console.log('Testing ' + method + '...');
client[method].apply(client, args);
}
function callback(err, result) {
if(err)
console.log(err);
if(result)
console.log(result);
console.log();
if(tests.length > 0)
run();
}