Commit a42ac8d00ecf2e64163cb39f7c47607bfaa8aba0
1 parent
09e99f6add
Exists in
master
Perbaikan getBillCount. TESTED
Showing 2 changed files with 38 additions and 8 deletions Side-by-side Diff
index.js
... | ... | @@ -245,10 +245,12 @@ function getBillCount(detailSplitted, customKeyword) { |
245 | 245 | if (!detailSplitted) return 0; |
246 | 246 | |
247 | 247 | return Number( |
248 | - (customKeyword && detailSplitted[customKeyword]) | |
249 | - || detailSplitted['JMLBLN'] | |
250 | - || '0' | |
251 | - ); | |
248 | + ( | |
249 | + (customKeyword && detailSplitted[customKeyword]) | |
250 | + || detailSplitted['JMLBLN'] | |
251 | + || '' | |
252 | + ).replace(/\D+$/g, '') | |
253 | + ) || 0; | |
252 | 254 | } |
253 | 255 | |
254 | 256 | exports.getRcFromMessage = getRcFromMessage; |
test/main.js
... | ... | @@ -300,10 +300,38 @@ describe('#irs', function() { |
300 | 300 | |
301 | 301 | describe('#getBillCount', () => { |
302 | 302 | it('should return correct value', () => { |
303 | - 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); | |
304 | - 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')); | |
305 | - should.not.exists(irs.getBillCount('')); | |
306 | - should.not.exists(irs.getBillCount()); | |
303 | + // 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); | |
304 | + irs.getBillCount({ | |
305 | + NAMA: 'SUYATMAN', | |
306 | + DAYA: '900', | |
307 | + TARIF: 'R1M', | |
308 | + JMLBLN: 'BLN', | |
309 | + PERIODE: '201911,201912', | |
310 | + }).should.equal(0); | |
311 | + | |
312 | + irs.getBillCount({ | |
313 | + NAMA: 'SUYATMAN', | |
314 | + DAYA: '900', | |
315 | + TARIF: 'R1M', | |
316 | + JMLBLN: '2', | |
317 | + PERIODE: '201911,201912', | |
318 | + }).should.equal(2); | |
319 | + | |
320 | + irs.getBillCount({ | |
321 | + NAMA: 'SUYATMAN', | |
322 | + DAYA: '900', | |
323 | + TARIF: 'R1M', | |
324 | + JMLBLN: '2BLN', | |
325 | + PERIODE: '201911,201912', | |
326 | + }, null).should.equal(2); | |
327 | + | |
328 | + irs.getBillCount({ | |
329 | + NAMA: 'SUYATMAN', | |
330 | + DAYA: '900', | |
331 | + TARIF: 'R1M', | |
332 | + JML: '2BLN', | |
333 | + PERIODE: '201911,201912', | |
334 | + }, 'JML').should.equal(2); | |
307 | 335 | }); |
308 | 336 | }); |
309 | 337 | }); |
310 | 338 | \ No newline at end of file |