-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
55 lines (47 loc) · 2.49 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
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();
}