get-params-members-obj.js
1.8 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
/* global describe it */
const fs = require('fs');
const should = require('should');
const parseXml = require('../../lib/parse-xml');
const getParamsMembersObj = require('../../lib/generic-xmlrpc/get-params-members-obj');
const topUpRequestPayload = fs.readFileSync('./test-data/top-up-request-1.xml').toString();
const topUpRequestObj = parseXml('4C5B00DA', topUpRequestPayload);
const methodResponsePayload = fs.readFileSync('./test-data/method-response-1.xml').toString();
const methodResponseObj = parseXml('082DEE2D', methodResponsePayload);
describe('#generic-xmlrpc', () => {
describe('#precheck', () => {
it('should pass precheck', () => {
should.exists(topUpRequestPayload, '8134961F');
should.exists(topUpRequestObj, 'E2A43100');
});
});
describe('#get-params-members', () => {
it('should return correct result (from topUpRequest)', () => {
const result = getParamsMembersObj(topUpRequestObj, false);
should.exists(result, '494175C8');
result.MSISDN.should.equal('0818111222', 'A40F6034');
result.REQUESTID.should.equal('123456', '763B7B38');
result.PIN.should.equal('6633', 'EBF2FACB');
result.NOHP.should.equal('0818111333', 'CF204FB7');
result.NOM.should.equal('XR10', '0B8AB5AC');
});
it('should return correct result (from methodResponse)', () => {
const result = getParamsMembersObj(methodResponseObj, false);
should.exists(result, '6D1FC98B');
result.RESPONSECODE.should.equal('00', '476B0894');
result.REQUESTID.should.equal('123456', 'DF50D10B');
result.MESSAGE.should.equal('TOP UP BERHASIL', 'EBCC5B2A');
result.TRANSACTIONID.should.equal('666333', '7825968D');
});
});
});