import { isPhoneValid } from './phone.util'; describe('isPhoneValid', () => { it('should return valid phone details for a valid phone number', () => { const phone = '0336931584'; const isoAlpha2Code = 'VN'; const result = isPhoneValid(phone, isoAlpha2Code); expect(result.inputPhone).toBe(phone); expect(result.isoAlpha2Code).toBe(isoAlpha2Code); expect(result.countryCode).toBe(84); expect(result.nationalNumber).toBe('0336 931 584'); expect(result.internationalNumber).toBe('+84 336 931 584'); expect(result.e164).toBe('84336931584'); }); it('should throw an error for an invalid phone number', () => { const phone = '123'; const isoAlpha2Code = 'US'; expect(() => { isPhoneValid(phone, isoAlpha2Code); }).toThrow('Invalid phone'); }); });