mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-14 18:03:53 +08:00
24 lines
780 B
JavaScript
24 lines
780 B
JavaScript
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.')
|
|
})
|
|
})
|