-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(suffix): add name.suffix method
+ Add name.suffix method in en and pt_BR
- Loading branch information
1 parent
965637d
commit de922b4
Showing
9 changed files
with
75 additions
and
2 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
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import firstName from './firstName'; | ||
import lastName from './lastName'; | ||
import prefix from './prefix'; | ||
import suffix from './suffix'; | ||
|
||
export default { firstName, lastName, prefix }; | ||
export default { firstName, lastName, prefix, suffix }; |
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,26 @@ | ||
import { Locale } from '../../../types/locale'; | ||
import locales from '../locales'; | ||
import suffix from '..'; | ||
|
||
describe('Name | suffix', () => { | ||
it(`should return a random suffix in ${Locale.EN} by default`, () => { | ||
const value = suffix(); | ||
const { en } = locales; | ||
|
||
expect(en).toContain(value); | ||
}); | ||
|
||
it('should return a random suffix from given locale', () => { | ||
const value = suffix(Locale.PT_BR); | ||
const { pt_BR } = locales; | ||
|
||
expect(pt_BR).toContain(value); | ||
}); | ||
|
||
it(`should return a random suffix in ${Locale.EN} when given locale is not found`, () => { | ||
const value = suffix(Locale.RU); | ||
const { en } = locales; | ||
|
||
expect(en).toContain(value); | ||
}); | ||
}); |
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,10 @@ | ||
import { Locale } from '../../types/locale'; | ||
import getLocale from '../../helpers/getLocale'; | ||
import locales from '../suffix/locales'; | ||
import randomArrayElement from '../../helpers/randomArrayElement'; | ||
|
||
export default function suffix(selectedLocale?: Locale): string { | ||
const collection = getLocale(locales, selectedLocale); | ||
|
||
return randomArrayElement(collection); | ||
} |
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,11 @@ | ||
import locales from '..'; | ||
|
||
describe('Name | suffix | Locale', () => { | ||
it('should have en locale', () => { | ||
expect(locales).toHaveProperty('en'); | ||
}); | ||
|
||
it('should have pt_BR locale', () => { | ||
expect(locales).toHaveProperty('pt_BR'); | ||
}); | ||
}); |
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,13 @@ | ||
export default [ | ||
'Jr.', | ||
'Sr.', | ||
'I', | ||
'II', | ||
'III', | ||
'IV', | ||
'V', | ||
'MD', | ||
'DDS', | ||
'PhD', | ||
'DVM', | ||
]; |
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,7 @@ | ||
import { LocaleObject } from '../../../types/locale'; | ||
import en from './en/collection'; | ||
import pt_BR from './pt_BR/collection'; | ||
|
||
const locales: LocaleObject<string[]> = { en, pt_BR }; | ||
|
||
export default locales; |
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 @@ | ||
export default ['Jr.', 'Neto', 'Filho']; |