bigbuffet-rw/app/soapbox/utils/__tests__/phone-test.js

30 lines
788 B
JavaScript
Raw Normal View History

2022-03-21 11:09:01 -07:00
import { formatPhoneNumber } from '../phone';
describe('Phone unit tests', () => {
it('Properly formats', () => {
let number = '';
expect(formatPhoneNumber(number)).toEqual('');
number = '5';
expect(formatPhoneNumber(number)).toEqual('+1 (5');
number = '55';
expect(formatPhoneNumber(number)).toEqual('+1 (55');
number = '555';
expect(formatPhoneNumber(number)).toEqual('+1 (555');
number = '55513';
expect(formatPhoneNumber(number)).toEqual('+1 (555) 13');
number = '555135';
expect(formatPhoneNumber(number)).toEqual('+1 (555) 135');
number = '5551350';
expect(formatPhoneNumber(number)).toEqual('+1 (555) 135-0');
number = '5551350123';
expect(formatPhoneNumber(number)).toEqual('+1 (555) 135-0123');
});
});