test.js 889 Bytes
var assert = require("assert");

describe("#parseSN()", function() {
    var partner = require('./gentong');
    
    var config = {};
    config.h2h_out = {};
    
    config.h2h_out.parse_sn = 'YES';
    config.h2h_out.sn_pattern = " SN : (.+?) Pos Reff";
    config.h2h_out.sn_remove_patterns_separator = '|';
    config.h2h_out.sn_remove_patterns = ' ';
    config.h2h_out.sn_match_index = 1;
    config.h2h_out.sn_min_length = 16;
    
    it ('should return correct sn', function () {
        assert.equal(partner.parseSN("Berhasil 26/16/13 49: s10h ke 081282629266 SN : 31 0009 5856 5718 Pos Reff : 4109000292575968, Saldo Rp. 9.990.500.SA_POIN", config), '0031000958565718');
        assert.equal(partner.parseSN("Berhasil 28/17/13 43: s10h ke 082210008543 SN : 31 0009 5864 1297 Pos Reff : 4109000309576154, Saldo Rp. 9.970.000.SA_POIN", config), '0031000958641297');
    });
});