Commit 9eb443895c80548064a6f82406b32302c30c0871
1 parent
e1f0e514aa
Exists in
master
getBalanceFromMessage lebih tahan banting
Showing 2 changed files with 13 additions and 1 deletions Side-by-side Diff
test.js
... | ... | @@ -41,6 +41,16 @@ describe('partner', function() { |
41 | 41 | var message = 'SN=10125649183280;23/08/15 14:25 ISI XRH10 KE 087878342801, BERHASIL.SAL=8.753.973,HRG=10.400,ID=15832056,SN=10125649183280; YM CS kembali ke services477pulsa, tks.'; |
42 | 42 | assert.equal(8753973, partner.getBalanceFromMessage(message, 'SAL=(.+?),HRG')); |
43 | 43 | }); |
44 | + | |
45 | + it ('should return undefined', function() { | |
46 | + var message = 'SN=10125649183280;23/08/15 14:25 ISI XRH10 KE 087878342801, BERHASIL.SAL=8.753.973,HRG=10.400,ID=15832056,SN=10125649183280; YM CS kembali ke services477pulsa, tks.'; | |
47 | + assert.equal(undefined, partner.getBalanceFromMessage(message, 'ASAL=(.+?),HRG')); | |
48 | + }); | |
49 | + | |
50 | + it ('should return undefined', function() { | |
51 | + var message = 'SN=10125649183280;23/08/15 14:25 ISI XRH10 KE 087878342801, BERHASIL.SAL=8.753.973,HRG=10.400,ID=15832056,SN=10125649183280; YM CS kembali ke services477pulsa, tks.'; | |
52 | + assert.equal(undefined, partner.getBalanceFromMessage(message, '')); | |
53 | + }); | |
44 | 54 | |
45 | 55 | }); |
46 | 56 | }); |
xmlout.js
... | ... | @@ -151,7 +151,9 @@ function createServer() { |
151 | 151 | |
152 | 152 | function getBalanceFromMessage(message, balance_regex) { |
153 | 153 | if (!balance_regex) { |
154 | - balance_regex = config.globals.balance_regex; | |
154 | + if (config && config.globals && config.globals.balance_regex) { | |
155 | + balance_regex = config.globals.balance_regex; | |
156 | + } | |
155 | 157 | } |
156 | 158 | |
157 | 159 | if (!balance_regex) { |