modems.js.old 1.63 KB
"use strict";

/* global describe it */

const should = require('should');

const modemSelect = require('../lib/modemSelect');

describe('#modemSelect', function() {
    
    describe('#getModemUrl', function() {

        const modemsConfig = {
            SMS0: {
                url: "http://localhost:8888/"
            }
        }
    
        it('should return correct url', function() {
            modemSelect.getModemUrl('SMS0', modemsConfig).should.equal('http://localhost:8888/');
        })

        it ('should handle missing modems', function() {
            should.not.exists(modemSelect.getModemUrl('SMS0', null));
            should.not.exists(modemSelect.getModemUrl('SMS0', {}));
            should.not.exists(modemSelect.getModemUrl('SMS1', modemsConfig));
        })
    })

    describe('#removeSuffixFromNumber', function() {
        const config = {
            number_suffix: '@phonenumber'
        }

        it('should return correct number', function() {
            modemSelect.removeSuffixFromNumber('08181234@phonenumber', config).should.equal('08181234');
        })

        it ('should return correct number without suffix in the number', function() {
            modemSelect.removeSuffixFromNumber('08181234', config).should.equal('08181234');
        })

        it ('should return correct number without suffix in config', function() {
            modemSelect.removeSuffixFromNumber('08181234', null).should.equal('08181234');
            modemSelect.removeSuffixFromNumber('08181234', {}).should.equal('08181234');
            modemSelect.removeSuffixFromNumber('08181234@phonenumber', {}).should.equal('08181234');
        })
    })

})