modems.js
1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"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');
})
})
})