Skip to content

Commit

Permalink
First version of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielflippance committed Jul 9, 2015
1 parent 8351f66 commit a586a52
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
var paypalPayResponseParser = require('./paypalPayResponseParser.js');

exports.parse_SingleEntry_Succeeds = function(test) {
var result = paypalPayResponseParser.parse(
'paymentInfoList.paymentInfo(0).receiver.amount=12.00'
+ '&paymentInfoList.paymentInfo(0).receiver.paymentType=SERVICE'
+ '&paymentInfoList.paymentInfo(1).receiver.email=paypal%40trymarketspace.com'
);
test.expect(18);

test.notEqual(null, result);
test.notEqual(undefined, result);
test.notEqual(null, result.paymentInfoList);
test.notEqual(undefined, result.paymentInfoList);
test.notEqual(null, result.paymentInfoList.paymentInfo);
test.notEqual(undefined, result.paymentInfoList.paymentInfo);
test.equal(2, result.paymentInfoList.paymentInfo.length);

test.notEqual(null, result.paymentInfoList.paymentInfo[0]);
test.notEqual(undefined, result.paymentInfoList.paymentInfo[0]);
test.notEqual(null, result.paymentInfoList.paymentInfo[0].receiver);
test.notEqual(undefined, result.paymentInfoList.paymentInfo[0].receiver);
test.equal(12.00, result.paymentInfoList.paymentInfo[0].receiver.amount);
test.equal("SERVICE", result.paymentInfoList.paymentInfo[0].receiver.paymentType);

test.notEqual(null, result.paymentInfoList.paymentInfo[1]);
test.notEqual(undefined, result.paymentInfoList.paymentInfo[1]);
test.notEqual(null, result.paymentInfoList.paymentInfo[1].receiver);
test.notEqual(undefined, result.paymentInfoList.paymentInfo[1].receiver);
test.equal("[email protected]", result.paymentInfoList.paymentInfo[1].receiver.email);

test.done();
}

exports.parseItem_SingleEntry_Succeeds = function(test) {
var initialObject = { daniel: "hello" };
var result = paypalPayResponseParser.parseItem('paymentInfoList.paymentInfo(0).receiver.amount=12.00', initialObject );
test.expect(13);

test.notEqual(null, result);
test.notEqual(undefined, result);
test.notEqual(null, result.paymentInfoList);
test.notEqual(undefined, result.paymentInfoList);
test.notEqual(null, result.paymentInfoList.paymentInfo);
test.notEqual(undefined, result.paymentInfoList.paymentInfo);
test.equal(1, result.paymentInfoList.paymentInfo.length);
test.notEqual(null, result.paymentInfoList.paymentInfo[0]);
test.notEqual(undefined, result.paymentInfoList.paymentInfo[0]);
test.notEqual(null, result.paymentInfoList.paymentInfo[0].receiver);
test.notEqual(undefined, result.paymentInfoList.paymentInfo[0].receiver);
test.equal("12.00", result.paymentInfoList.paymentInfo[0].receiver.amount);
test.equal("hello", result.daniel);

test.done();
}

0 comments on commit a586a52

Please sign in to comment.