-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update IsPhoneNumber decorator to use max dataset
- Loading branch information
1 parent
d325cc7
commit 32c8231
Showing
2 changed files
with
33 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { isPhoneNumber } from './IsPhoneNumber'; | ||
|
||
describe('@IsPhoneNumber decorator implementation', () => { | ||
describe('isPhoneNumber validator', () => { | ||
it('should accept valid values', () => { | ||
expect(isPhoneNumber('+36 20 111 1111', 'HU')).toBe(true); | ||
}); | ||
|
||
describe('should not accept invalid values', () => { | ||
it('when country code invalid', () => { | ||
expect(isPhoneNumber('+1 20 111 1111', 'HU')).toBe(false); | ||
}); | ||
|
||
it('when country code does not match locale', () => { | ||
expect(isPhoneNumber('+36 00 111 1111', 'HU')).toBe(false); | ||
}); | ||
|
||
it('when phone number length is incorrect', () => { | ||
expect(isPhoneNumber('+36 20 111 111', 'HU')).toBe(false); | ||
}); | ||
}); | ||
|
||
it('should not accept values with extra whitespace', () => { | ||
expect(isPhoneNumber(' +36 20 111 1111', 'HU')).toBe(false); | ||
expect(isPhoneNumber('+36 20 111 1111 ', 'HU')).toBe(false); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters