From 2a2e054a16a45bc5cd56bdd923b7f5140eb12699 Mon Sep 17 00:00:00 2001 From: Matt Mayer Date: Sun, 1 Jan 2023 00:49:19 +0700 Subject: [PATCH] feat(person): add short bio (#1696) --- src/definitions/person.ts | 2 ++ src/locales/en/person/bio_part.ts | 43 ++++++++++++++++++++++++++ src/locales/en/person/bio_patterns.ts | 10 ++++++ src/locales/en/person/bio_supporter.ts | 9 ++++++ src/locales/en/person/index.ts | 6 ++++ src/modules/person/index.ts | 14 +++++++++ test/__snapshots__/person.spec.ts.snap | 6 ++++ test/person.spec.ts | 3 +- 8 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 src/locales/en/person/bio_part.ts create mode 100644 src/locales/en/person/bio_patterns.ts create mode 100644 src/locales/en/person/bio_supporter.ts diff --git a/src/definitions/person.ts b/src/definitions/person.ts index 488ff4fe433..773d4fb849c 100644 --- a/src/definitions/person.ts +++ b/src/definitions/person.ts @@ -30,6 +30,8 @@ export type PersonDefinitions = LocaleEntry<{ */ name: string[]; + bio_patterns?: string[]; + title: PersonTitleDefinitions; western_zodiac_sign: string[]; diff --git a/src/locales/en/person/bio_part.ts b/src/locales/en/person/bio_part.ts new file mode 100644 index 00000000000..0e6830f8029 --- /dev/null +++ b/src/locales/en/person/bio_part.ts @@ -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', +]; diff --git a/src/locales/en/person/bio_patterns.ts b/src/locales/en/person/bio_patterns.ts new file mode 100644 index 00000000000..80caf4edc3c --- /dev/null +++ b/src/locales/en/person/bio_patterns.ts @@ -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}}', +]; diff --git a/src/locales/en/person/bio_supporter.ts b/src/locales/en/person/bio_supporter.ts new file mode 100644 index 00000000000..26de8b024d6 --- /dev/null +++ b/src/locales/en/person/bio_supporter.ts @@ -0,0 +1,9 @@ +export default [ + 'advocate', + 'devotee', + 'enthusiast', + 'fan', + 'junkie', + 'lover', + 'supporter', +]; diff --git a/src/locales/en/person/index.ts b/src/locales/en/person/index.ts index 68824ff3869..0f1b5889890 100644 --- a/src/locales/en/person/index.ts +++ b/src/locales/en/person/index.ts @@ -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'; @@ -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, diff --git a/src/modules/person/index.ts b/src/modules/person/index.ts index 2e443c3e199..59202fb0058 100644 --- a/src/modules/person/index.ts +++ b/src/modules/person/index.ts @@ -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. * diff --git a/test/__snapshots__/person.spec.ts.snap b/test/__snapshots__/person.spec.ts.snap index a74ca00a33b..593d9978f6e 100644 --- a/test/__snapshots__/person.spec.ts.snap +++ b/test/__snapshots__/person.spec.ts.snap @@ -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"`; @@ -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"`; @@ -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"`; diff --git a/test/person.spec.ts b/test/person.spec.ts index 757c6e8c093..c232977ff0a 100644 --- a/test/person.spec.ts +++ b/test/person.spec.ts @@ -17,7 +17,8 @@ describe('person', () => { 'jobTitle', 'jobDescriptor', 'jobArea', - 'jobType' + 'jobType', + 'bio' ); t.describeEach(