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/es6/ drwxr-xr-x | |
| Viewing file: Select action/file-type: import metadata from '../metadata.min.json';
import PhoneNumber from './PhoneNumber';
describe('PhoneNumber', function () {
it('should validate constructor arguments', function () {
expect(function () {
return new PhoneNumber();
}).to["throw"]('`countryCallingCode` not passed');
expect(function () {
return new PhoneNumber('7');
}).to["throw"]('`nationalNumber` not passed');
expect(function () {
return new PhoneNumber('7', '8005553535');
}).to["throw"]('`metadata` not passed');
});
it('should accept country code argument', function () {
var phoneNumber = new PhoneNumber('RU', '8005553535', metadata);
phoneNumber.countryCallingCode.should.equal('7');
phoneNumber.country.should.equal('RU');
phoneNumber.number.should.equal('+78005553535');
});
it('should format number with options', function () {
var phoneNumber = new PhoneNumber('7', '8005553535', metadata);
phoneNumber.ext = '123';
phoneNumber.format('NATIONAL', {
formatExtension: function formatExtension(number, extension) {
return "".concat(number, " \u0434\u043E\u0431. ").concat(extension);
}
}).should.equal('8 (800) 555-35-35 доб. 123');
});
it('should compare phone numbers', function () {
new PhoneNumber('RU', '8005553535', metadata).isEqual(new PhoneNumber('RU', '8005553535', metadata)).should.equal(true);
new PhoneNumber('RU', '8005553535', metadata).isEqual(new PhoneNumber('7', '8005553535', metadata)).should.equal(true);
new PhoneNumber('RU', '8005553535', metadata).isEqual(new PhoneNumber('RU', '8005553536', metadata)).should.equal(false);
});
it('should tell if a number is non-geographic', function () {
new PhoneNumber('7', '8005553535', metadata).isNonGeographic().should.equal(false);
new PhoneNumber('870', '773111632', metadata).isNonGeographic().should.equal(true);
});
it('should allow setting extension', function () {
var phoneNumber = new PhoneNumber('1', '2133734253', metadata);
phoneNumber.setExt('1234');
phoneNumber.ext.should.equal('1234');
phoneNumber.formatNational().should.equal('(213) 373-4253 ext. 1234');
});
});
//# sourceMappingURL=PhoneNumber.test.js.map |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0119 ]-- |