protheus.js 1.05 KB
/* global describe it */

require('should');

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

describe('#main', () => {
    describe('#getPriceFromMessage', () => {
        it('should return correct value', () => {
            irs.getPriceFromMessage(
                'RC00 SUKSES Transaksi TSEL15 ke 081382709997 success, SN: 02120300000626854613 Harga Beli : 14820 Sisa Saldo : 5638 RestCode : 00 ResellerTrxID : 9763834',
                {
                    pattern: 'Harga Beli : (\\d+)',
                    match_idx: 1,
                },
            ).should.equal(14820);
        });
    });

    describe('#getBalanceFromMessage', () => {
        it('should return correct value', () => {
            irs.getBalanceFromMessage(
                'RC00 SUKSES Transaksi TSEL15 ke 081382709997 success, SN: 02120300000626854613 Harga Beli : 14820 Sisa Saldo : 5638 RestCode : 00 ResellerTrxID : 9763834',
                {
                    pattern: 'Sisa Saldo : (\\d+)',
                    match_idx: 1,
                },
            ).should.equal(5638);
        });
    });
});