get-params-members-obj.js 1.8 KB
/* 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');
        });
    });
});