Skip to content

Commit 1a438e1

Browse files
committed
output errors on rejection
1 parent 8a12605 commit 1a438e1

File tree

2 files changed

+30
-31
lines changed

2 files changed

+30
-31
lines changed

config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
2-
"API_LOGIN_ID": "2msN9nrBG8K",
3-
"TRANSACTION_KEY": "43jNykM6kC8v87Nb"
2+
"API_LOGIN_ID": "2msN9nrBG8K",
3+
"TRANSACTION_KEY": "43jNykM6kC8v87Nb"
44
};

test.js

+28-29
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ describe('AuthorizeNet service', function () {
2323
assert.equal(transaction.transactionResponse.responseCode, '1');
2424
done();
2525
}, function(rejection){
26-
done(rejection);
27-
})
26+
done(JSON.stringify(rejection));
27+
});
2828
});
2929

3030
it('should submit authorizationCapture request with some extra params', function (done) {
@@ -97,18 +97,18 @@ describe('AuthorizeNet service', function () {
9797
service.authOnlyTransaction(randomAmount(), 4007000000027, 2016, 2).then(function (transaction) {
9898
assert.equal(transaction.transactionResponse.responseCode, '1');
9999
done();
100-
}).catch(function(err){
101-
done(err);
100+
}).catch(function(rejection){
101+
done(JSON.stringify(rejection));
102102
})
103103
});
104104

105105
it('should submit authorization only request with extra params', function (done) {
106106
service.authOnlyTransaction(randomAmount(), 4007000000027, 2017, 11, {transactionRequest: {payment: {creditCard: {cardCode: 666}}}}).then(function (transaction) {
107107
assert.equal(transaction.transactionResponse.responseCode, '1');
108108
done();
109-
}).catch(function(err){
110-
done(err);
111-
})
109+
}).catch(function(rejection){
110+
done(JSON.stringify(rejection));
111+
});
112112
});
113113

114114
it('should reject the promise when web service send an error code', function (done) {
@@ -147,9 +147,8 @@ describe('AuthorizeNet service', function () {
147147
assert.equal(trans.transactionResponse.responseCode, '1');
148148
done();
149149
})
150-
.catch(function (err) {
151-
console.log(err);
152-
done(err);
150+
.catch(function (rejection) {
151+
done(JSON.stringify(rejection));
153152
});
154153
});
155154

@@ -215,9 +214,9 @@ describe('AuthorizeNet service', function () {
215214
assert.equal(trans.transactionResponse.responseCode, '1');
216215
done();
217216
})
218-
.catch(function(err){
219-
done(err);
220-
})
217+
.catch(function(rejection){
218+
done(JSON.stringify(rejection));
219+
});
221220
});
222221

223222
it('should reject the promise when web service send an error code', function (done) {
@@ -258,9 +257,9 @@ describe('AuthorizeNet service', function () {
258257
assert.equal(trans.transaction.transId, transId);
259258
done();
260259
})
261-
.catch(function(err){
262-
done(err);
263-
})
260+
.catch(function(rejection){
261+
done(JSON.stringify(rejection));
262+
});
264263
});
265264

266265
it('should reject the promise when web service return error code', function (done) {
@@ -292,9 +291,9 @@ describe('AuthorizeNet service', function () {
292291
service.getUnsettledTransactionList().then(function (response) {
293292
assert(response.transactions, 'transactions field should be defined');
294293
done();
295-
}).catch(function(err){
296-
done(err);
297-
})
294+
}).catch(function(rejection){
295+
done(JSON.stringify(rejection));
296+
});
298297
});
299298

300299
});
@@ -305,9 +304,9 @@ describe('AuthorizeNet service', function () {
305304
service.getSettledBatchList(true, new Date(Date.now() - 7 * 24 * 3600 * 1000), new Date()).then(function (response) {
306305
assert(response.batchList, 'batchList should be defined');
307306
done();
308-
}).catch(function(err){
309-
done(err);
310-
})
307+
}).catch(function(rejection){
308+
done(JSON.stringify(rejection));
309+
});
311310
});
312311

313312
});
@@ -322,9 +321,9 @@ describe('AuthorizeNet service', function () {
322321
.then(function (response) {
323322
assert(response.batch, 'batch should be defined');
324323
done();
325-
}).catch(function(err){
326-
done(err);
327-
})
324+
}).catch(function(rejection){
325+
done(JSON.stringify(rejection));
326+
});
328327
});
329328

330329
it('should reject the promise if any error happens', function (done) {
@@ -349,10 +348,10 @@ describe('AuthorizeNet service', function () {
349348
.then(function (response) {
350349
assert(response.transactions.transaction, 'it should have a list of transactions');
351350
done();
352-
}).catch(function(err){
353-
done(err);
354-
})
351+
}).catch(function(rejection){
352+
done(JSON.stringify(rejection));
353+
});
355354
});
356-
});
355+
});
357356

358357
});

0 commit comments

Comments
 (0)