test.js 4.04 KB
var assert = require("assert");


describe('aaa', function() {
    var aaa = require('./aaa');
    
    describe("#unaliasResponseCode()", function() {
        it('should return 68', function() {
            assert.equal('68', aaa.unaliasResponseCode('01', '01:68'));
        });
        
        it('should return 68', function() {
            assert.equal('68', aaa.unaliasResponseCode('68', '01:68'));
        });
        
        it('should return 00', function() {
            assert.equal('00', aaa.unaliasResponseCode('00', '01:68'));
        });
        
        it('should return 40', function() {
            assert.equal('40', aaa.unaliasResponseCode('40', ''));
        });
        
        it('should return 40', function() {
            assert.equal('40', aaa.unaliasResponseCode('40', ''));
        });
        
        it('should return 40', function() {
            assert.equal('40', aaa.unaliasResponseCode('40'));
        });
    
    });
});

describe('partner', function() {
    var partner = require('./partner-scrappingkisel');
    
    describe("#stockKeyword", function() {
        it('should return 10K', function() {
            assert.equal('10K', partner.stockKeyword('Telkomsel 10K'));
        });
        
        it('should return 20K', function() {
            assert.equal('20K', partner.stockKeyword('Telkomsel 20K'));
        });
        
        it('should return 25K', function() {
            assert.equal('25K', partner.stockKeyword('Telkomsel 25K'));
        });
        
        it('should return 50K', function() {
            assert.equal('50K', partner.stockKeyword('Telkomsel 50K'));
        });
        
        it('should return 100K', function() {
            assert.equal('100K', partner.stockKeyword('Telkomsel 100K'));
        });
    });
    
    describe("#parseStock", function() {
        it('should return 476', function() {
            assert.equal(476, partner.parseStock('10K = 476; 20K = 598; 25K = 600; 50K = 700; 100K = 400; 150K = 0; 200K = 0; 300K = 0; 500K = 0', 'Telkomsel 10K'));
        });
        
        it('should return 598', function() {
            assert.equal(598, partner.parseStock('10K = 476; 20K = 598; 25K = 600; 50K = 700; 100K = 400; 150K = 0; 200K = 0; 300K = 0; 500K = 0', 'Telkomsel 20K'));
        });
        
        it('should return 0', function() {
            assert.equal(0, partner.parseStock('10K = 476; 20K = 598; 25K = 600; 50K = 700; 100K = 400; 150K = 0; 200K = 0; 300K = 0; 500K = 0', 'Telkomsel 200K'));
        });
        
        it('should return 0', function() {
            assert.equal(0, partner.parseStock('10K = 476; 20K = 598; 25K = 600; 50K = 700; 100K = 400; 150K = 0; 200K = 0; 300K = 0; 500K = 0', 'Telkomsel 2000K'));
        });
        
        it('should return 0', function() {
            assert.equal(0, partner.parseStock('10K = 476; 20K = 598; 25K = 600; 50K = 700; 100K = 400; 150K = 0; 200K = 0; 300K = 0; 500K = 0', 'Telkomsel 2000'));
        });
        
        it('should return 0', function() {
            assert.equal(0, partner.parseStock('', 'Telkomsel 2000'));
        });
        
        it('should return 0', function() {
            assert.equal(0, partner.parseStock('10K = 476; 20K = 598; 25K = 600; 50K = 700; 100K = 400; 150K = 0; 200K = 0; 300K = 0; 500K = 0', ''));
        });
        
    });
    
    describe('#productsWithout', function () {
        
        it('should return S10,S20,S50,S100', function() {
            assert.equal('S10,S20,S50,S100', partner.productsWithout('S25', 'S10,S20,S25,S50,S100'));
        });
        
        it('should return S10,S20,S25,S50', function() {
            assert.equal('S10,S20,S25,S50', partner.productsWithout('S100', 'S10,S20,S25,S50,S100'));
        });
        
        it('should return S20,S25,S50,S100', function() {
            assert.equal('S20,S25,S50,S100', partner.productsWithout('S10', 'S10,S20,S25,S50,S100'));
        });
        
        it('should return S10,S20,S25,S50', function() {
            assert.equal('S10,S20,S25,S50', partner.productsWithout('S100', 'S10,S20,S25,S50'));
        });
        
    });
});