Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /usr/local/lib/node_modules/homebridge-config-ui-x/node_modules/libphonenumber-js/source/helpers/ drwxr-xr-x | |
| Viewing file: Select action/file-type: import metadata from '../../metadata.max.json'
import Metadata from '../metadata'
import { checkNumberLengthForType } from './checkNumberLength'
describe('checkNumberLength', () => {
it('should check phone number length', () => {
// Too short.
checkNumberLength('800555353', 'FIXED_LINE', 'RU').should.equal('TOO_SHORT')
// Normal.
checkNumberLength('8005553535', 'FIXED_LINE', 'RU').should.equal('IS_POSSIBLE')
// Too long.
checkNumberLength('80055535355', 'FIXED_LINE', 'RU').should.equal('TOO_LONG')
// No such type.
checkNumberLength('169454850', 'VOIP', 'AC').should.equal('INVALID_LENGTH')
// No such possible length.
checkNumberLength('1694548', undefined, 'AD').should.equal('INVALID_LENGTH')
// FIXED_LINE_OR_MOBILE
checkNumberLength('1694548', 'FIXED_LINE_OR_MOBILE', 'AD').should.equal('INVALID_LENGTH')
// No mobile phones.
checkNumberLength('8123', 'FIXED_LINE_OR_MOBILE', 'TA').should.equal('IS_POSSIBLE')
// No "possible lengths" for "mobile".
checkNumberLength('81234567', 'FIXED_LINE_OR_MOBILE', 'SZ').should.equal('IS_POSSIBLE')
})
})
function checkNumberLength(number, type, country) {
const _metadata = new Metadata(metadata)
_metadata.country(country)
return checkNumberLengthForType(number, type, _metadata)
} |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0063 ]-- |