Commit 99f38aa7c6be5b06470b6bad79de6b92af9befb0

Authored by Adhidarma Hadiwinoto
1 parent 68534cf30e
Exists in master

Some test

Showing 1 changed file with 46 additions and 28 deletions Inline Diff

1 /* eslint-disable no-console */ 1 /* eslint-disable no-console */
2 /* global describe it */ 2 /* global describe it */
3 3
4 //process.env.KOMODO_SDK_DEBUG_RC_FROM_MSG = 'YES'; 4 //process.env.KOMODO_SDK_DEBUG_RC_FROM_MSG = 'YES';
5 5
6 const should = require('should'); 6 const should = require('should');
7 const irs = require('../index'); 7 const irs = require('../index');
8 8
9 describe('#irs', function() { 9 describe('#irs', function() {
10 describe('#getRcFromMessage', function() { 10 describe('#getRcFromMessage', function() {
11 it('should return correct rc', function() { 11 it('should return correct rc', function() {
12 irs.getRcFromMessage('Request IBP25 ke 085736328877 under proses..').should.equal('68'); 12 irs.getRcFromMessage('Request IBP25 ke 085736328877 under proses..').should.equal('68');
13 irs.getRcFromMessage('Transaksi HX5 ke 081809903333 GAGAL. Mohon periksa kembali No tujuan sebelum di ulang. Saldo: Rp 26.857.538').should.equal('40'); 13 irs.getRcFromMessage('Transaksi HX5 ke 081809903333 GAGAL. Mohon periksa kembali No tujuan sebelum di ulang. Saldo: Rp 26.857.538').should.equal('40');
14 irs.getRcFromMessage('REFF#11538167 Trx IBP25.085736328877 BERHASIL,Harga: 24.475 SN: 503133415264594 Sisa Saldo: 1.169.227 - 24.475 = 1.144.752 @5/3/2018 1:34:13 PM').should.equal('00'); 14 irs.getRcFromMessage('REFF#11538167 Trx IBP25.085736328877 BERHASIL,Harga: 24.475 SN: 503133415264594 Sisa Saldo: 1.169.227 - 24.475 = 1.144.752 @5/3/2018 1:34:13 PM').should.equal('00');
15 15
16 irs.getRcFromMessage('REFF#1238 CEK TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail: NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041 Sisa Saldo: 180.318 - 0 = 180.318 @29/12/2017 9:48:16').should.equal('00', 'postpaid inquiry success'); 16 irs.getRcFromMessage('REFF#1238 CEK TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail: NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041 Sisa Saldo: 180.318 - 0 = 180.318 @29/12/2017 9:48:16').should.equal('00', 'postpaid inquiry success');
17 irs.getRcFromMessage('REFF#1239 BAYAR TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail:S/N:0BNS25G5043265250358/NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLNPERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALBAYAR:19041 Sisa Saldo: 180.318 - 17.741 = 162.577 @29/12/2017 9:48:41').should.equal('00', 'postpaid payment success'); 17 irs.getRcFromMessage('REFF#1239 BAYAR TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail:S/N:0BNS25G5043265250358/NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLNPERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALBAYAR:19041 Sisa Saldo: 180.318 - 17.741 = 162.577 @29/12/2017 9:48:41').should.equal('00', 'postpaid payment success');
18 18
19 irs.getRcFromMessage('Maaf Produk sedang gangguan').should.equal('90'); 19 irs.getRcFromMessage('Maaf Produk sedang gangguan').should.equal('90');
20 }); 20 });
21 }); 21 });
22 22
23 describe('#getPriceFromMessage', function() { 23 describe('#getPriceFromMessage', function() {
24 describe('#generic', function() { 24 describe('#generic', function() {
25 it('should return correct price', function() { 25 it('should return correct price', function() {
26 irs.getPriceFromMessage('REFF#11538167 Trx IBP25.085736328877 BERHASIL,Harga: 24.475 SN: 503133415264594 Sisa Saldo: 1.169.227 - 24.475 = 1.144.752 @5/3/2018 1:34:13 PM').should.equal(24475); 26 irs.getPriceFromMessage('REFF#11538167 Trx IBP25.085736328877 BERHASIL,Harga: 24.475 SN: 503133415264594 Sisa Saldo: 1.169.227 - 24.475 = 1.144.752 @5/3/2018 1:34:13 PM').should.equal(24475);
27 }); 27 });
28 28
29 it('should handle postpaid response', () => { 29 it('should handle postpaid response', () => {
30 irs.getPriceFromMessage('REFF#1238 CEK TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail: NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041 Sisa Saldo: 180.318 - 0 = 180.318 @29/12/2017 9:48:16').should.equal(0, 'postpaid inquiry succces'); 30 irs.getPriceFromMessage('REFF#1238 CEK TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail: NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041 Sisa Saldo: 180.318 - 0 = 180.318 @29/12/2017 9:48:16').should.equal(0, 'postpaid inquiry succces');
31 irs.getPriceFromMessage('REFF#1239 BAYAR TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail:S/N:0BNS25G5043265250358/NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLNPERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALBAYAR:19041 Sisa Saldo: 180.318 - 17.741 = 162.577 @29/12/2017 9:48:41').should.equal(17741, 'postpaid payment success'); 31 irs.getPriceFromMessage('REFF#1239 BAYAR TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail:S/N:0BNS25G5043265250358/NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLNPERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALBAYAR:19041 Sisa Saldo: 180.318 - 17.741 = 162.577 @29/12/2017 9:48:41').should.equal(17741, 'postpaid payment success');
32 irs.getPriceFromMessage('REFF#562126 BAYAR TAGIHAN PLN25 SUKSES IDPEL:172000147469 Detail:S/N: 0BNS25G5008509025529/NAMA:MASJID-NURUL-IMAN/DAYA:900/TARIF:S2/JMLBLN:1BLN/PERIODE:201912/METERKINI:19627/METERLALU:19428/TAGIHAN:79340/ADM:2500/DENDA:0/TOTALBAYAR:81840 Sisa Saldo: 1.000.000 - 79.540 = 920.460 @2019/12/20 19:49:21').should.equal(79540); 32 irs.getPriceFromMessage('REFF#562126 BAYAR TAGIHAN PLN25 SUKSES IDPEL:172000147469 Detail:S/N: 0BNS25G5008509025529/NAMA:MASJID-NURUL-IMAN/DAYA:900/TARIF:S2/JMLBLN:1BLN/PERIODE:201912/METERKINI:19627/METERLALU:19428/TAGIHAN:79340/ADM:2500/DENDA:0/TOTALBAYAR:81840 Sisa Saldo: 1.000.000 - 79.540 = 920.460 @2019/12/20 19:49:21').should.equal(79540);
33 }) 33 })
34 34
35 it('should handle missing price', function() { 35 it('should handle missing price', function() {
36 should.not.exist(irs.getPriceFromMessage('REFF#11538167 Trx IBP25.085736328877 BERHASIL, SN: 503133415264594 @5/3/2018 1:34:13 PM')); 36 should.not.exist(irs.getPriceFromMessage('REFF#11538167 Trx IBP25.085736328877 BERHASIL, SN: 503133415264594 @5/3/2018 1:34:13 PM'));
37 }); 37 });
38 }); 38 });
39 39
40 describe('#eflashtron', function() { 40 describe('#eflashtron', function() {
41 it('should return correct price', function() { 41 it('should return correct price', function() {
42 irs.getPriceFromMessage('Trx HT5.08989355280 BERHASIL. SN: 0608211002164754102. Sisa Saldo: 536.581 - 5.265 = 531.316 @08/06/2019 21:10:03 Komplen max. H+7').should.equal(5265); 42 irs.getPriceFromMessage('Trx HT5.08989355280 BERHASIL. SN: 0608211002164754102. Sisa Saldo: 536.581 - 5.265 = 531.316 @08/06/2019 21:10:03 Komplen max. H+7').should.equal(5265);
43 }); 43 });
44 }); 44 });
45 45
46 describe('#some suppliers', () => { 46 describe('#some suppliers', () => {
47 it('should return correct price', () => { 47 it('should return correct price', () => {
48 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') 48 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')
49 .should.equal(5285, 'tajir price'); 49 .should.equal(5285, 'tajir price');
50 }); 50 });
51 }); 51 });
52 52
53 describe('#custom', () => { 53 describe('#custom', () => {
54 it('should return correct price', () => { 54 it('should return correct price', () => {
55 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'; 55 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 const rule = { 56 const rule = {
57 pattern: 'Saldo Anda (?:[\\d\\.]+) - Rp ([\\d\\.]+)', 57 pattern: 'Saldo Anda (?:[\\d\\.]+) - Rp ([\\d\\.]+)',
58 match_idx: 1, 58 match_idx: 1,
59 } 59 }
60 irs.getPriceFromMessage(msg, rule).should.equal(5525); 60 irs.getPriceFromMessage(msg, rule).should.equal(5525);
61 should.not.exists(irs.getPriceFromMessage('kosong', rule)); 61 should.not.exists(irs.getPriceFromMessage('kosong', rule));
62 }); 62 });
63 }) 63 })
64 }); 64 });
65 65
66 describe('#getBalanceFromMessage', () => { 66 describe('#getBalanceFromMessage', () => {
67 67
68 describe('#some suppliers', () => { 68 describe('#some suppliers', () => {
69 it('should return correct price', () => { 69 it('should return correct price', () => {
70 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') 70 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')
71 .should.equal(2278726, 'tajir balance'); 71 .should.equal(2278726, 'tajir balance');
72 }); 72 });
73 }); 73 });
74 74
75 75
76 describe('#custom', () => { 76 describe('#custom', () => {
77 it('should return correct price', () => { 77 it('should return correct price', () => {
78 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'; 78 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';
79 const rule = { 79 const rule = {
80 pattern: 'Saldo Anda (?:[\\d\\.]+) - Rp (?:[\\d\\.]+) = Rp ([\\d\\.]+)', 80 pattern: 'Saldo Anda (?:[\\d\\.]+) - Rp (?:[\\d\\.]+) = Rp ([\\d\\.]+)',
81 match_idx: 1, 81 match_idx: 1,
82 } 82 }
83 irs.getBalanceFromMessage(msg, rule).should.equal(490105); 83 irs.getBalanceFromMessage(msg, rule).should.equal(490105);
84 should.not.exists(irs.getBalanceFromMessage('kosong', rule)); 84 should.not.exists(irs.getBalanceFromMessage('kosong', rule));
85 }); 85 });
86 }) 86 })
87 }); 87 });
88 88
89 describe('#getSnFromMessage', () => { 89 describe('#getSnFromMessage', () => {
90 it('should return correct result', () => { 90 it('should return correct result', () => {
91 irs.getSnFromMessage('HX5 No.087781522208 Berhasil SN: 99971113094584 Tgl 2019-13-11 12:31:47.Saldo Anda 495.630 - Rp 5.525 = Rp 490.105').should.equal('99971113094584', 'SN: 99971113094584'); 91 irs.getSnFromMessage('HX5 No.087781522208 Berhasil SN: 99971113094584 Tgl 2019-13-11 12:31:47.Saldo Anda 495.630 - Rp 5.525 = Rp 490.105').should.equal('99971113094584', 'SN: 99971113094584');
92 irs.getSnFromMessage('HX5 No.087781522208 Berhasil SN:99971113094584 Tgl 2019-13-11 12:31:47.Saldo Anda 495.630 - Rp 5.525 = Rp 490.105').should.equal('99971113094584', 'SN:99971113094584'); 92 irs.getSnFromMessage('HX5 No.087781522208 Berhasil SN:99971113094584 Tgl 2019-13-11 12:31:47.Saldo Anda 495.630 - Rp 5.525 = Rp 490.105').should.equal('99971113094584', 'SN:99971113094584');
93 irs.getSnFromMessage('REFF#22955367 BAYAR TAGIHAN PLN25 SUKSES IDPEL:173300992349 Detail:S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560 Sisa Saldo: 40.653.798 - 140.960 = 40.512.838 @2019/11/28 11:44:36') 93 irs.getSnFromMessage('REFF#22955367 BAYAR TAGIHAN PLN25 SUKSES IDPEL:173300992349 Detail:S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560 Sisa Saldo: 40.653.798 - 140.960 = 40.512.838 @2019/11/28 11:44:36')
94 .should.equal('0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560', 'kiosbayar postpaid payment'); 94 .should.equal('0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560', 'kiosbayar postpaid payment');
95 }); 95 });
96 }); 96 });
97 97
98 describe('#getDetailFromMessage', () => { 98 describe('#getDetailFromMessage', () => {
99 it('should return correct result', () => { 99 it('should return correct result', () => {
100 irs.getDetailFromMessage('REFF#1238 CEK TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail: NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041 Sisa Saldo: 180.318 - 0 = 180.318 @29/12/2017 9:48:16') 100 irs.getDetailFromMessage('REFF#1238 CEK TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail: NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041 Sisa Saldo: 180.318 - 0 = 180.318 @29/12/2017 9:48:16')
101 .should.equal('NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041', 'postpaid inquiry success'); 101 .should.equal('NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041', 'postpaid inquiry success');
102 102
103 irs.getDetailFromMessage('REFF#22955367 BAYAR TAGIHAN PLN25 SUKSES IDPEL:173300992349 Detail:S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560 Sisa Saldo: 40.653.798 - 140.960 = 40.512.838 @2019/11/28 11:44:36') 103 irs.getDetailFromMessage('REFF#22955367 BAYAR TAGIHAN PLN25 SUKSES IDPEL:173300992349 Detail:S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560 Sisa Saldo: 40.653.798 - 140.960 = 40.512.838 @2019/11/28 11:44:36')
104 .should.equal('S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560', 'kiosbayar postpaid payment'); 104 .should.equal('S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560', 'kiosbayar postpaid payment');
105 105
106 irs.getDetailFromMessage('REFF#561744 CEK TAGIHAN PLN25 SUKSES IDPEL:172000147469 Detail: NAMA:MASJID-NURUL-IMAN/DAYA:900/TARIF:S2/JMLBLN:1BLN/PERIODE:201912/METERKINI:19627/METERLALU:19428/TAGIHAN:79340/ADM:2500/DENDA:0/TOTALTAGIHAN:81840 Sisa Saldo: 1.000.000 - 0 = 1.000.000 @2019/12/20 19:41:21') 106 irs.getDetailFromMessage('REFF#561744 CEK TAGIHAN PLN25 SUKSES IDPEL:172000147469 Detail: NAMA:MASJID-NURUL-IMAN/DAYA:900/TARIF:S2/JMLBLN:1BLN/PERIODE:201912/METERKINI:19627/METERLALU:19428/TAGIHAN:79340/ADM:2500/DENDA:0/TOTALTAGIHAN:81840 Sisa Saldo: 1.000.000 - 0 = 1.000.000 @2019/12/20 19:41:21')
107 .should.equal('NAMA:MASJID-NURUL-IMAN/DAYA:900/TARIF:S2/JMLBLN:1BLN/PERIODE:201912/METERKINI:19627/METERLALU:19428/TAGIHAN:79340/ADM:2500/DENDA:0/TOTALTAGIHAN:81840'); 107 .should.equal('NAMA:MASJID-NURUL-IMAN/DAYA:900/TARIF:S2/JMLBLN:1BLN/PERIODE:201912/METERKINI:19627/METERLALU:19428/TAGIHAN:79340/ADM:2500/DENDA:0/TOTALTAGIHAN:81840');
108 }); 108 });
109 109
110 it('should return correct result with custom pattern', () => { 110 it('should return correct result with tajira response', () => {
111 irs.getDetailFromMessage( 111 const detailPattern = {
112 'Cek Tagihan PLN SUKSES ke 520550410074, REFID: 520550410074/MASJID.. KATEGORI:S2/900 , PERIODE:092020, JUMLAH:1, TOTAL TAGIHAN : 72.010', 112 pattern: '(REFID: .*?)($|(, *SALDO))',
113 match_idx: 1,
114 };
115
116 const detailReplacements = [
113 { 117 {
114 pattern: '(REFID: .*)$', 118 pattern: ' *\\.\\.+ *',
115 match_idx: 1, 119 replacement: '/',
120 flags: 'g',
116 }, 121 },
117 [ 122 {
118 { 123 pattern: ' *, *',
119 pattern: ' *\\.\\.+ *', 124 replacement: '/',
120 replacement: '/', 125 flags: 'g',
121 flags: 'g', 126 },
122 }, 127 {
123 { 128 pattern: ' *: *',
124 pattern: ' *, *', 129 replacement: ':',
125 replacement: '/', 130 flags: 'g',
126 flags: 'g', 131 },
127 }, 132 {
128 { 133 pattern: 'TOTAL TAGIHAN*',
129 pattern: ' *: *', 134 replacement: 'TOTALTAGIHAN',
130 replacement: ':', 135 },
131 flags: 'g', 136 ]
132 }, 137
133 { 138 irs.getDetailFromMessage(
134 pattern: 'TOTAL TAGIHAN*', 139 'Cek Tagihan PLN SUKSES ke 520550410074, REFID: 520550410074/MASJID.. KATEGORI:S2/900 , PERIODE:092020, JUMLAH:1, TOTAL TAGIHAN : 72.010',
135 replacement: 'TOTALTAGIHAN', 140 detailPattern,
136 }, 141 detailReplacements
137 ] 142 ).should.equal('REFID:520550410074/MASJID/KATEGORI:S2/900/PERIODE:092020/JUMLAH:1/TOTALTAGIHAN:72.010', 'TAJIRA PLN POSTPAID');
138 ) 143
139 .should.equal('REFID:520550410074/MASJID/KATEGORI:S2/900/PERIODE:092020/JUMLAH:1/TOTALTAGIHAN:72.010', 'TAJIRA PLN POSTPAID'); 144 // const detailPattern2 = {
145 // pattern: '(REFID: .*), SALDO',
146 // match_idx: 1,
147 // };
148
149 irs.getDetailFromMessage(
150 'CEK TAGIHAN PLNFULL SUKSES KE 520550388323, REFID: 52055038832320700700.. NAMA:MUSHOLA AL AMIN, KATEGORIDAYA:S2/450, PERIODE:092020, TAGIHANASLI:16620, DENDA:3000, ADMIN:2750, TOTALBAYAR:19.370, SALDO:500.000',
151 detailPattern,
152 detailReplacements
153 ).should.equal(
154 'REFID:52055038832320700700/NAMA:MUSHOLA AL AMIN/KATEGORIDAYA:S2/450/PERIODE:092020/TAGIHANASLI:16620/DENDA:3000/ADMIN:2750/TOTALBAYAR:19.370',
155 'TAJIRA PLN POSTPAID 2',
156 );
157
140 }); 158 });
141 }); 159 });
142 160
143 describe('#splitPostpaidDetail', () => { 161 describe('#splitPostpaidDetail', () => {
144 it('should return correct result - inquiry', () => { 162 it('should return correct result - inquiry', () => {
145 const detail = 'NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041'; 163 const detail = 'NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041';
146 const splitted = irs.splitPostpaidDetail(detail); 164 const splitted = irs.splitPostpaidDetail(detail);
147 165
148 splitted.should.ok(); 166 splitted.should.ok();
149 splitted.find((item) => item.keyword === 'NAMA').value.should.equal('MUSHOLLA-NURUL-KHOIR'); 167 splitted.find((item) => item.keyword === 'NAMA').value.should.equal('MUSHOLLA-NURUL-KHOIR');
150 splitted.find((item) => item.keyword === 'TAGIHAN').value.should.equal('14441'); 168 splitted.find((item) => item.keyword === 'TAGIHAN').value.should.equal('14441');
151 splitted.find((item) => item.keyword === 'DENDA').value.should.equal('3000'); 169 splitted.find((item) => item.keyword === 'DENDA').value.should.equal('3000');
152 }); 170 });
153 171
154 it('should return correct result - pay', () => { 172 it('should return correct result - pay', () => {
155 const detail = 'S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560'; 173 const detail = 'S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560';
156 const splitted = irs.splitPostpaidDetail(detail); 174 const splitted = irs.splitPostpaidDetail(detail);
157 175
158 splitted.should.ok(); 176 splitted.should.ok();
159 splitted.find((item) => item.keyword === 'SN').value.should.equal('0BNS25G5082152526173'); 177 splitted.find((item) => item.keyword === 'SN').value.should.equal('0BNS25G5082152526173');
160 splitted.find((item) => item.keyword === 'NAMA').value.should.equal('DONAR-HARHAP'); 178 splitted.find((item) => item.keyword === 'NAMA').value.should.equal('DONAR-HARHAP');
161 splitted.find((item) => item.keyword === 'TAGIHAN').value.should.equal('131560'); 179 splitted.find((item) => item.keyword === 'TAGIHAN').value.should.equal('131560');
162 splitted.find((item) => item.keyword === 'DENDA').value.should.equal('9000'); 180 splitted.find((item) => item.keyword === 'DENDA').value.should.equal('9000');
163 }); 181 });
164 }); 182 });
165 183
166 describe('#calculateBaseBillAmount', () => { 184 describe('#calculateBaseBillAmount', () => {
167 it('should return correct value - inquiry', () => { 185 it('should return correct value - inquiry', () => {
168 const detail = 'NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041'; 186 const detail = 'NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041';
169 const splitted = irs.splitPostpaidDetail(detail); 187 const splitted = irs.splitPostpaidDetail(detail);
170 188
171 irs.calculateBaseBillAmount(splitted).should.equal(17441); 189 irs.calculateBaseBillAmount(splitted).should.equal(17441);
172 190
173 }) 191 })
174 192
175 it('should return correct value - payment', () => { 193 it('should return correct value - payment', () => {
176 const detail = 'S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560'; 194 const detail = 'S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560';
177 const splitted = irs.splitPostpaidDetail(detail); 195 const splitted = irs.splitPostpaidDetail(detail);
178 196
179 // console.log('--- DEBUG'); 197 // console.log('--- DEBUG');
180 // console.log(splitted); 198 // console.log(splitted);
181 // console.log('---'); 199 // console.log('---');
182 200
183 irs.calculateBaseBillAmount(splitted).should.equal(140560, '#2CBDCEB8'); 201 irs.calculateBaseBillAmount(splitted).should.equal(140560, '#2CBDCEB8');
184 202
185 }) 203 })
186 }); 204 });
187 205
188 describe('#getBillCount', () => { 206 describe('#getBillCount', () => {
189 it('should return correct value', () => { 207 it('should return correct value', () => {
190 irs.getBillCount('0BNS25G5087744307740/NAMA:SUYATMAN/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201911,201912/METERKINI:3606/METERLALU:3564/TAGIHAN:117260/ADM:5000/DENDA:9000/TOTALBAYAR:131260').should.equal(2); 208 irs.getBillCount('0BNS25G5087744307740/NAMA:SUYATMAN/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201911,201912/METERKINI:3606/METERLALU:3564/TAGIHAN:117260/ADM:5000/DENDA:9000/TOTALBAYAR:131260').should.equal(2);
191 should.not.exists(irs.getBillCount('0BNS25G5087744307740/NAMA:SUYATMAN/DAYA:900/TARIF:R1M/JMLBLN:BLN/PERIODE:201911,201912/METERKINI:3606/METERLALU:3564/TAGIHAN:117260/ADM:5000/DENDA:9000/TOTALBAYAR:131260')); 209 should.not.exists(irs.getBillCount('0BNS25G5087744307740/NAMA:SUYATMAN/DAYA:900/TARIF:R1M/JMLBLN:BLN/PERIODE:201911,201912/METERKINI:3606/METERLALU:3564/TAGIHAN:117260/ADM:5000/DENDA:9000/TOTALBAYAR:131260'));
192 should.not.exists(irs.getBillCount('')); 210 should.not.exists(irs.getBillCount(''));
193 should.not.exists(irs.getBillCount()); 211 should.not.exists(irs.getBillCount());
194 }); 212 });
195 }); 213 });
196 }); 214 });