From 60289367aeb13034bbac106340f38dfebbdf3ce0 Mon Sep 17 00:00:00 2001 From: Adhidarma Hadiwinoto <me@adhisimon.org> Date: Thu, 19 Jul 2018 21:19:05 +0700 Subject: [PATCH] Perbaikan extractSnFromMessage agar bisa parsing hasil topUpInquiry --- lib/st24.js | 2 +- test.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/st24.js b/lib/st24.js index e7eae7b..15c313d 100644 --- a/lib/st24.js +++ b/lib/st24.js @@ -31,7 +31,7 @@ function extractFromMessage(msg, default_pattern, default_match_idx, custom_rule } function extractSnFromMessage(msg, custom_rule) { - const default_pattern = "^SN=(.*?);"; + const default_pattern = "SN=(.*?);"; const default_match_idx = 1; return extractFromMessage(msg, default_pattern, default_match_idx, custom_rule); diff --git a/test.js b/test.js index a27bffe..e32b5a7 100644 --- a/test.js +++ b/test.js @@ -9,9 +9,13 @@ describe('#st24', function() { describe('#extractSnFromMessage', function() { describe('#using default st24 rule', function() { - it('should return correct sn', function() { + it('should return correct sn from topUpRequest response', function() { st24.extractSnFromMessage('SN=0419165234155980102;19/04/18 16:52 ISI TR5 KE 0895621829255, SUKSES.SAL=1.323.934,HRG=5.250,ID=46398092,SN=0419165234155980102; ..trx lancar').should.equal('0419165234155980102'); }) + + it('should return correct sn from topUpInquiry response', function() { + st24.extractSnFromMessage('19/07/18 20:53 ISI SPT20 KE 081264858057, SUKSES.SAL=828.425,HRG=19.700,ID=48761021,SN=0041002635369521;').should.equal('0041002635369521'); + }) }) describe('#using custom rule', function() { -- 1.9.0