supplier-htc-postpaid.js 1.84 KB
/* global describe it */

require('should');

const irs = require('../index');

describe('Respon dari HTC postpaid', () => {
    describe('#irs', () => {
        describe('#calculateBaseBillAmount', () => {
            it('should return correct value', () => {
                const msg = 'CEK BPJSKS BERHASIL,SN:IDPEL:0001465757368,NAMA:BAMBANG PARTODEWO,CABANG:1101-SEMARANG,JML:,TOTALBAYAR:28.000';

                const detailPattern = {
                    pattern: 'SN:(.*)($|(, *SALDO))',
                    match_idx: 1,
                };

                const detailReplacements = [
                    {
                        pattern: ' *\\.\\.+ *',
                        replacement: '/',
                        flags: 'g',
                    },
                    {
                        pattern: ' *, *',
                        replacement: '/',
                        flags: 'g',
                    },
                    {
                        pattern: ' *: *',
                        replacement: ':',
                        flags: 'g',
                    },
                ]

                const detail = irs.getDetailFromMessage(
                    msg,
                    detailPattern,
                    detailReplacements
                );

                detail.should.equal('IDPEL:0001465757368/NAMA:BAMBANG PARTODEWO/CABANG:1101-SEMARANG/JML:/TOTALBAYAR:28.000', 'HTC BPJSK POSTPAID getDetailFromMessage');
                const detailSplitted = irs.splitPostpaidDetail(detail);

                irs.calculateBaseBillAmount(
                    detailSplitted,
                    null,
                    {
                        KEYWORD_TOTALTAG: 'TOTALBAYAR',
                        ADMINFEE: '2500',
                    },
                    1,
                ).should.equal(25500);
            })
        });
    })
});