From 0204ba4880843e467f86e9d587912077cbe429f7 Mon Sep 17 00:00:00 2001 From: Adhidarma Hadiwinoto <me@adhisimon.org> Date: Wed, 21 Oct 2020 14:27:54 +0700 Subject: [PATCH] Protheus tested --- index.js | 2 -- test/protheus.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 test/protheus.js diff --git a/index.js b/index.js index 030ca52..9bf591f 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,4 @@ /* eslint-disable no-console */ -"use strict"; - const regexLooperReplace = require('tektrans-lib/regex-looper/replace'); const rcFromMsg = require('komodo-sdk/rc-from-msg'); const organicRc = require('./rc'); diff --git a/test/protheus.js b/test/protheus.js new file mode 100644 index 0000000..3282457 --- /dev/null +++ b/test/protheus.js @@ -0,0 +1,31 @@ +/* global describe it */ + +require('should'); + +const irs = require('../index'); + +describe('#main', () => { + describe('#getPriceFromMessage', () => { + it('should return correct value', () => { + irs.getPriceFromMessage( + 'RC00 SUKSES Transaksi TSEL15 ke 081382709997 success, SN: 02120300000626854613 Harga Beli : 14820 Sisa Saldo : 5638 RestCode : 00 ResellerTrxID : 9763834', + { + pattern: 'Harga Beli : (\\d+)', + match_idx: 1, + }, + ).should.equal(14820); + }); + }); + + describe('#getBalanceFromMessage', () => { + it('should return correct value', () => { + irs.getBalanceFromMessage( + 'RC00 SUKSES Transaksi TSEL15 ke 081382709997 success, SN: 02120300000626854613 Harga Beli : 14820 Sisa Saldo : 5638 RestCode : 00 ResellerTrxID : 9763834', + { + pattern: 'Sisa Saldo : (\\d+)', + match_idx: 1, + }, + ).should.equal(5638); + }); + }); +}); -- 1.9.0