diff --git a/index.js b/index.js index 29af8cd..b36710b 100644 --- a/index.js +++ b/index.js @@ -100,7 +100,7 @@ function getSnFromMessage(msg, rule) { function getBalanceFromMessage(msg, rule) { if (!rule) { rule = { - pattern: "Sisa Saldo: .+? = ([\\d\\.]+) ", + pattern: "Saldo: .+? = ([\\d\\.]+) ", match_idx: 1 } } diff --git a/test/main.js b/test/main.js index b53f5cb..da43dff 100644 --- a/test/main.js +++ b/test/main.js @@ -42,6 +42,13 @@ describe('#irs', function() { }); }); + describe('#some suppliers', () => { + it('should return correct price', () => { + irs.getPriceFromMessage('Trx S10 085212341234 BERHASIL, Harga: 5.285 SN: 41002553325946 Saldo: 2.284.011 - 5.285 = 2.278.726 @24/06/2018 18:38:06') + .should.equal(5285, 'tajir price'); + }); + }); + describe('#custom', () => { it('should return correct price', () => { const msg = 'HX5 No.087781522208 Berhasil SN:99971113094584 Tgl 2019-13-11 12:31:47.Saldo Anda 495.630 - Rp 5.525 = Rp 490.105'; @@ -56,6 +63,15 @@ describe('#irs', function() { }); describe('#getBalanceFromMessage', () => { + + describe('#some suppliers', () => { + it('should return correct price', () => { + irs.getBalanceFromMessage('Trx S10 085212341234 BERHASIL, Harga: 5.285 SN: 41002553325946 Saldo: 2.284.011 - 5.285 = 2.278.726 @24/06/2018 18:38:06') + .should.equal(2278726, 'tajir balance'); + }); + }); + + describe('#custom', () => { it('should return correct price', () => { const msg = 'HX5 No.087781522208 Berhasil SN:99971113094584 Tgl 2019-13-11 12:31:47.Saldo Anda 495.630 - Rp 5.525 = Rp 490.105';