Commit e1f73a2c87850ac9c24801219429b61a76517208
1 parent
e4c88f6f43
Exists in
master
Move test to dedicated directory
Showing 2 changed files with 63 additions and 37 deletions Side-by-side Diff
test.js
... | ... | @@ -1,37 +0,0 @@ |
1 | -"use strict"; | |
2 | - | |
3 | -/* global describe it */ | |
4 | - | |
5 | -//process.env.KOMODO_SDK_DEBUG_RC_FROM_MSG = 'YES'; | |
6 | - | |
7 | -const should = require('should'); | |
8 | -const irs = require('./index'); | |
9 | - | |
10 | -describe('#irs', function() { | |
11 | - describe('#getRcFromMessage', function() { | |
12 | - it('should return correct rc', function() { | |
13 | - irs.getRcFromMessage('Request IBP25 ke 085736328877 under proses..').should.equal('68'); | |
14 | - irs.getRcFromMessage('Transaksi HX5 ke 081809903333 GAGAL. Mohon periksa kembali No tujuan sebelum di ulang. Saldo: Rp 26.857.538').should.equal('40'); | |
15 | - 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'); | |
16 | - irs.getRcFromMessage('Maaf Produk sedang gangguan').should.equal('90'); | |
17 | - }); | |
18 | - }); | |
19 | - | |
20 | - describe('#getPriceFromMessage', function() { | |
21 | - describe('#generic', function() { | |
22 | - it('should return correct price', function() { | |
23 | - 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); | |
24 | - }); | |
25 | - | |
26 | - it('should handle missing price', function() { | |
27 | - should.not.exist(irs.getPriceFromMessage('REFF#11538167 Trx IBP25.085736328877 BERHASIL, SN: 503133415264594 @5/3/2018 1:34:13 PM')); | |
28 | - }); | |
29 | - }); | |
30 | - | |
31 | - describe('#eflashtron', function() { | |
32 | - it('should return correct price', function() { | |
33 | - 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); | |
34 | - }); | |
35 | - }) | |
36 | - }); | |
37 | -}); |
test/main.js
... | ... | @@ -0,0 +1,63 @@ |
1 | +"use strict"; | |
2 | + | |
3 | +/* global describe it */ | |
4 | + | |
5 | +//process.env.KOMODO_SDK_DEBUG_RC_FROM_MSG = 'YES'; | |
6 | + | |
7 | +const should = require('should'); | |
8 | +const irs = require('../index'); | |
9 | + | |
10 | +describe('#irs', function() { | |
11 | + describe('#getRcFromMessage', function() { | |
12 | + it('should return correct rc', function() { | |
13 | + irs.getRcFromMessage('Request IBP25 ke 085736328877 under proses..').should.equal('68'); | |
14 | + irs.getRcFromMessage('Transaksi HX5 ke 081809903333 GAGAL. Mohon periksa kembali No tujuan sebelum di ulang. Saldo: Rp 26.857.538').should.equal('40'); | |
15 | + 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'); | |
16 | + irs.getRcFromMessage('Maaf Produk sedang gangguan').should.equal('90'); | |
17 | + }); | |
18 | + }); | |
19 | + | |
20 | + describe('#getPriceFromMessage', function() { | |
21 | + describe('#generic', function() { | |
22 | + it('should return correct price', function() { | |
23 | + 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); | |
24 | + }); | |
25 | + | |
26 | + it('should handle missing price', function() { | |
27 | + should.not.exist(irs.getPriceFromMessage('REFF#11538167 Trx IBP25.085736328877 BERHASIL, SN: 503133415264594 @5/3/2018 1:34:13 PM')); | |
28 | + }); | |
29 | + }); | |
30 | + | |
31 | + describe('#eflashtron', function() { | |
32 | + it('should return correct price', function() { | |
33 | + 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); | |
34 | + }); | |
35 | + }); | |
36 | + | |
37 | + describe('#custom', () => { | |
38 | + it('should return correct price', () => { | |
39 | + 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'; | |
40 | + const rule = { | |
41 | + pattern: 'Saldo Anda (?:[\\d\\.]+) - Rp ([\\d\\.]+)', | |
42 | + match_idx: 1, | |
43 | + } | |
44 | + irs.getPriceFromMessage(msg, rule).should.equal(5525); | |
45 | + should.not.exists(irs.getPriceFromMessage('kosong', rule)); | |
46 | + }); | |
47 | + }) | |
48 | + }); | |
49 | + | |
50 | + describe('#getBalanceFromMessage', () => { | |
51 | + describe('#custom', () => { | |
52 | + it('should return correct price', () => { | |
53 | + 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'; | |
54 | + const rule = { | |
55 | + pattern: 'Saldo Anda (?:[\\d\\.]+) - Rp (?:[\\d\\.]+) = Rp ([\\d\\.]+)', | |
56 | + match_idx: 1, | |
57 | + } | |
58 | + irs.getBalanceFromMessage(msg, rule).should.equal(490105); | |
59 | + should.not.exists(irs.getBalanceFromMessage('kosong', rule)); | |
60 | + }); | |
61 | + }) | |
62 | + }); | |
63 | +}); | |
0 | 64 | \ No newline at end of file |