Add Phone Number Formatting Function

This commit is contained in:
aladin002dz
2020-10-07 11:37:42 +01:00
parent e92b5d2a49
commit ba3af82e84
2 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,23 @@
import { formatPhoneNumber } from './FormatPhoneNumber'
describe('PhoneNumberFormatting', () => {
it('expects to return the formatted phone number', () => {
expect(formatPhoneNumber('1234567890')).toEqual('(123) 456-7890')
})
it('expects to return the formatted phone number', () => {
expect(formatPhoneNumber(1234567890)).toEqual('(123) 456-7890')
})
it('expects to throw a type error', () => {
expect(() => { formatPhoneNumber('1234567') }).toThrow('Invalid phone number.')
})
it('expects to throw a type error', () => {
expect(() => { formatPhoneNumber('123456text') }).toThrow('Invalid phone number.')
})
it('expects to throw a type error', () => {
expect(() => { formatPhoneNumber(12345) }).toThrow('Invalid phone number.')
})
})