test.js
2.27 KB
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
"use strict";
const should = require("should");
const partner = require("./partner-bnisp");
describe("#partner", function() {
describe("#createUrlPath", function() {
it('should return correct url path based on example', function() {
let options = {
noid: 1002003,
token: 'CIPY6t6ruy5UuGG0PCqu',
product: 'PULSA',
product_type: 'THREE5000',
id_pel: '0895385381299',
trace_id: 16
}
partner.createUrlPath(options).should.equal('/get/purchase/json/1002003/CIPY6t6ruy5UuGG0PCqu/PULSA/THREE5000/0895385381299/0/0/16')
})
})
const responseBody = '{"trxId":"064024","response_code":"0000","response_message":"SUKSES","detail":{"jmlTagihan":"1","kodeThree":"012001","nilaiPulsa":"000000005000","noHp":"0895385381299","transactionId":"0612143023138365102 ","voucherSerialNumber":"20170612143620980249"},"reff":"20170612143620980249","loadTime":"0.0107","tipe_request":"purchase","prv":"hpay","userID":"1002003","idpel":"0895385381299","product":"PULSA","produk":"PULSA","product_detail":"THREE5000","produk_tipe":"THREE5000","traceId":16,"tagihan":5050,"total_tagihan":5050,"amount":5050,"saldo":94950,"waktu":"2017-07-17 18:43:32"}';
const responseData = partner.parseResponseBody(responseBody);
describe('#parseResponseBody', function() {
it('should return correct response code', function() {
responseData.response_code.should.equal('0000');
})
it('should return correct voucher serial number', function() {
responseData.detail.voucherSerialNumber.should.equal('20170612143620980249');
})
})
describe('#responseDataProcessor', function() {
const processed = partner.responseDataProcessor(responseData);
it('should return correct rc', function() {
processed.rc.should.equal('00');
})
it('should return correct sn', function() {
processed.sn.should.equal('20170612143620980249');
})
it('should return correct amount', function() {
processed.amount.should.equal(5050);
})
it('should return correct balance', function() {
processed.balance.should.equal(94950);
})
})
})