supplier-htc-postpaid.js
1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* 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);
})
});
})
});