mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 19:12:50 +00:00
test files
This commit is contained in:
34
libs/ui/src/lib/input/phone.spec.ts
Normal file
34
libs/ui/src/lib/input/phone.spec.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { optionalPhoneNumber, phoneNumber } from './phone';
|
||||
|
||||
describe('phoneNumber', () => {
|
||||
it('normalizes a legacy Ethiopian national number to E.164', () => {
|
||||
expect(phoneNumber.parse('0911223344')).toBe('+251911223344');
|
||||
});
|
||||
|
||||
it('passes an Ethiopian E.164 number through unchanged', () => {
|
||||
expect(phoneNumber.parse('+251911223344')).toBe('+251911223344');
|
||||
});
|
||||
|
||||
it('accepts a valid international number', () => {
|
||||
expect(phoneNumber.parse('+14155552671')).toBe('+14155552671');
|
||||
});
|
||||
|
||||
it('rejects a too-short number', () => {
|
||||
expect(() => phoneNumber.parse('+251911')).toThrow();
|
||||
});
|
||||
|
||||
it('rejects non-numeric input', () => {
|
||||
expect(() => phoneNumber.parse('abc')).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('optionalPhoneNumber', () => {
|
||||
it('allows a blank value', () => {
|
||||
expect(optionalPhoneNumber.parse('')).toBe('');
|
||||
});
|
||||
|
||||
it('still validates a non-blank value', () => {
|
||||
expect(() => optionalPhoneNumber.parse('abc')).toThrow();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user