Skip to content

Commit

Permalink
feat(person): add short bio (#1696)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Mayer authored Dec 31, 2022
1 parent 351f8f0 commit 2a2e054
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/definitions/person.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export type PersonDefinitions = LocaleEntry<{
*/
name: string[];

bio_patterns?: string[];

title: PersonTitleDefinitions;

western_zodiac_sign: string[];
Expand Down
43 changes: 43 additions & 0 deletions src/locales/en/person/bio_part.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
export default [
'activist',
'artist',
'author',
'blogger',
'business owner',
'coach',
'creator',
'designer',
'developer',
'dreamer',
'educator',
'engineer',
'entrepreneur',
'environmentalist',
'film lover',
'filmmaker',
'foodie',
'founder',
'friend',
'gamer',
'geek',
'grad',
'inventor',
'leader',
'model',
'musician',
'nerd',
'parent',
'patriot',
'person',
'philosopher',
'photographer',
'public speaker',
'scientist',
'singer',
'streamer',
'student',
'teacher',
'traveler',
'veteran',
'writer',
];
10 changes: 10 additions & 0 deletions src/locales/en/person/bio_patterns.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default [
'{{person.bio_part}}',
'{{person.bio_part}}, {{person.bio_part}}',
'{{person.bio_part}}, {{person.bio_part}}, {{person.bio_part}}',
'{{person.bio_part}}, {{person.bio_part}}, {{person.bio_part}} {{internet.emoji}}',
'{{word.noun}} {{person.bio_supporter}}',
'{{word.noun}} {{person.bio_supporter}} {{internet.emoji}}',
'{{word.noun}} {{person.bio_supporter}}, {{person.bio_part}}',
'{{word.noun}} {{person.bio_supporter}}, {{person.bio_part}} {{internet.emoji}}',
];
9 changes: 9 additions & 0 deletions src/locales/en/person/bio_supporter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default [
'advocate',
'devotee',
'enthusiast',
'fan',
'junkie',
'lover',
'supporter',
];
6 changes: 6 additions & 0 deletions src/locales/en/person/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* Run 'pnpm run generate:locales' to update.
*/
import type { PersonDefinitions } from '../../..';
import bio_part from './bio_part';
import bio_patterns from './bio_patterns';
import bio_supporter from './bio_supporter';
import female_first_name from './female_first_name';
import female_middle_name from './female_middle_name';
import first_name from './first_name';
Expand All @@ -19,6 +22,9 @@ import title from './title';
import western_zodiac_sign from './western_zodiac_sign';

const person: PersonDefinitions = {
bio_part,
bio_patterns,
bio_supporter,
female_first_name,
female_middle_name,
first_name,
Expand Down
14 changes: 14 additions & 0 deletions src/modules/person/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,20 @@ export class PersonModule {
return this.faker.helpers.objectValue(Sex);
}

/**
* Returns a random short biography
*
* @example
* faker.person.bio() // 'oatmeal advocate, veteran 🐠'
*
* @since 8.0.0
*/
bio(): string {
const { bio_patterns } = this.faker.definitions.person;

return this.faker.helpers.fake(bio_patterns);
}

/**
* Returns a random person prefix.
*
Expand Down
6 changes: 6 additions & 0 deletions test/__snapshots__/person.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Vitest Snapshot v1

exports[`person > 42 > bio 1`] = `"public speaker, traveler, designer"`;

exports[`person > 42 > firstName > noArgs 1`] = `"Garnet"`;

exports[`person > 42 > firstName > with sex 1`] = `"Glen"`;
Expand Down Expand Up @@ -48,6 +50,8 @@ exports[`person > 42 > suffix > with sex 1`] = `"III"`;

exports[`person > 42 > zodiacSign 1`] = `"Gemini"`;

exports[`person > 1211 > bio 1`] = `"infusion supporter, photographer 🙆‍♀️"`;

exports[`person > 1211 > firstName > noArgs 1`] = `"Tito"`;

exports[`person > 1211 > firstName > with sex 1`] = `"Percy"`;
Expand Down Expand Up @@ -96,6 +100,8 @@ exports[`person > 1211 > suffix > with sex 1`] = `"DVM"`;

exports[`person > 1211 > zodiacSign 1`] = `"Capricorn"`;

exports[`person > 1337 > bio 1`] = `"inventor, creator, developer"`;

exports[`person > 1337 > firstName > noArgs 1`] = `"Devyn"`;

exports[`person > 1337 > firstName > with sex 1`] = `"Ray"`;
Expand Down
3 changes: 2 additions & 1 deletion test/person.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ describe('person', () => {
'jobTitle',
'jobDescriptor',
'jobArea',
'jobType'
'jobType',
'bio'
);

t.describeEach(
Expand Down

0 comments on commit 2a2e054

Please sign in to comment.