-
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): introduces lastName module
+ Add lastName module + Move firstName tests to its own module folder + Add JA locale support
- Loading branch information
1 parent
34765b8
commit 61dfba8
Showing
13 changed files
with
619 additions
and
6 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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import name from '..'; | ||
|
||
describe('Name', () => { | ||
it('has firstName module', () => { | ||
it('should have firstName module', () => { | ||
expect(name).toHaveProperty('firstName'); | ||
}); | ||
|
||
it('should have lastName module', () => { | ||
expect(name).toHaveProperty('lastName'); | ||
}); | ||
}); |
6 changes: 3 additions & 3 deletions
6
src/name/__tests__/firstName.test.ts → ...ame/firstName/__tests__/firstName.test.ts
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,7 +1,8 @@ | ||
import { LocaleObject } from '../../../types/locale'; | ||
import en from './en/collection'; | ||
import ja from './ja/collection'; | ||
import pt_BR from './pt_BR/collection'; | ||
|
||
const locales: LocaleObject<string[]> = { en, pt_BR }; | ||
const locales: LocaleObject<string[]> = { en, ja, 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,23 @@ | ||
export default [ | ||
'大和', | ||
'大翔', | ||
'太一', | ||
'心愛', | ||
'愛菜', | ||
'杏', | ||
'樹', | ||
'海翔', | ||
'結愛', | ||
'結菜', | ||
'結衣', | ||
'美咲', | ||
'美羽', | ||
'翼', | ||
'莉子', | ||
'蒼空', | ||
'蓮', | ||
'陸斗', | ||
'陽翔', | ||
'陽菜', | ||
'颯太', | ||
]; |
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,3 +1,4 @@ | ||
import firstName from './firstName'; | ||
import lastName from './lastName'; | ||
|
||
export default { firstName }; | ||
export default { firstName, lastName }; |
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 lastName from '..'; | ||
import locales from '../locales'; | ||
|
||
describe('Name | lastName', () => { | ||
it('should return a random last name from given locale', () => { | ||
const name = lastName(Locale.PT_BR); | ||
const { pt_BR } = locales; | ||
|
||
expect(pt_BR).toContain(name); | ||
}); | ||
|
||
it(`should return a random last name in ${Locale.EN} by default`, () => { | ||
const name = lastName(); | ||
const { en } = locales; | ||
|
||
expect(en).toContain(name); | ||
}); | ||
|
||
it(`should return a random last name in ${Locale.EN} when given locale is not found`, () => { | ||
const name = lastName(Locale.RU); | ||
const { en } = locales; | ||
|
||
expect(en).toContain(name); | ||
}); | ||
}); |
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 lastName(selectedLocale?: Locale) { | ||
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,15 @@ | ||
import locales from '..'; | ||
|
||
describe('Name | lastName | Locales', () => { | ||
it('should have en locale', () => { | ||
expect(locales).toHaveProperty('en'); | ||
}); | ||
|
||
it('should have pt_BR locale', () => { | ||
expect(locales).toHaveProperty('pt_BR'); | ||
}); | ||
|
||
it('should have ja locale', () => { | ||
expect(locales).toHaveProperty('ja'); | ||
}); | ||
}); |
Oops, something went wrong.