mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-19 16:08:34 +01:00
Rename files
This commit is contained in:
30
ts/test-node/util/libphonenumberUtil_test.std.ts
Normal file
30
ts/test-node/util/libphonenumberUtil_test.std.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright 2015 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { assert, AssertionError } from 'chai';
|
||||
import { parseNumber } from '../../util/libphonenumberUtil.std.js';
|
||||
|
||||
describe('libphonenumber util', () => {
|
||||
describe('parseNumber', () => {
|
||||
it('numbers with + are valid without providing regionCode', () => {
|
||||
const result = parseNumber('+14155555555');
|
||||
if (!result.isValidNumber) {
|
||||
throw new AssertionError('Phone number is not valid');
|
||||
}
|
||||
assert.strictEqual(result.e164, '+14155555555');
|
||||
assert.strictEqual(result.regionCode, 'US');
|
||||
assert.strictEqual(result.countryCode, '1');
|
||||
});
|
||||
it('variant numbers with the right regionCode are valid', () => {
|
||||
['4155555555', '14155555555', '+14155555555'].forEach(number => {
|
||||
const result = parseNumber(number, 'US');
|
||||
if (!result.isValidNumber) {
|
||||
throw new AssertionError('Phone number is not valid');
|
||||
}
|
||||
assert.strictEqual(result.e164, '+14155555555');
|
||||
assert.strictEqual(result.regionCode, 'US');
|
||||
assert.strictEqual(result.countryCode, '1');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user