-
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(name.prefix): add name.prefix method
+ Introduces name.prefix method for en and pt_BR
- Loading branch information
1 parent
86ebc94
commit 965637d
Showing
9 changed files
with
63 additions
and
4 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,4 +1,5 @@ | ||
import firstName from './firstName'; | ||
import lastName from './lastName'; | ||
import prefix from './prefix'; | ||
|
||
export default { firstName, lastName }; | ||
export default { firstName, lastName, prefix }; |
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 prefix from '..'; | ||
|
||
describe('Name | prefix', () => { | ||
it(`should return a random prefix in ${Locale.EN} by default`, () => { | ||
const value = prefix(); | ||
const { en } = locales; | ||
|
||
expect(en).toContain(value); | ||
}); | ||
|
||
it('should return a random prefix from given locale', () => { | ||
const value = prefix(Locale.PT_BR); | ||
const { pt_BR } = locales; | ||
|
||
expect(pt_BR).toContain(value); | ||
}); | ||
|
||
it(`should return a random prefix in ${Locale.EN} when given locale is not found`, () => { | ||
const value = prefix(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 './locales'; | ||
import randomArrayElement from '../../helpers/randomArrayElement'; | ||
|
||
export default function prefix(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 | prefix | 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 @@ | ||
export default ['Mr.', 'Mrs.', 'Ms.', 'Miss', 'Dr.']; |
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 '../../../../lib/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 ['Sr.', 'Sra.', 'Srta.', 'Dr.']; |