From 7e00d1741495f763f986b3a5daf40943db4abc7d Mon Sep 17 00:00:00 2001 From: Bobby <30593201+luciferreeves@users.noreply.github.com> Date: Mon, 7 Nov 2022 10:58:05 -0500 Subject: [PATCH] feat(person): add `zodiacSign()` (#182) Co-authored-by: ST-DDT --- src/definitions/person.ts | 2 ++ src/locales/en/person/index.ts | 2 ++ src/locales/en/person/western_zodiac_sign.ts | 14 ++++++++++++++ src/modules/person/index.ts | 14 ++++++++++++++ test/__snapshots__/person.spec.ts.snap | 6 ++++++ test/person.spec.ts | 12 ++++++++++++ 6 files changed, 50 insertions(+) create mode 100644 src/locales/en/person/western_zodiac_sign.ts diff --git a/src/definitions/person.ts b/src/definitions/person.ts index b6db46e1976..488ff4fe433 100644 --- a/src/definitions/person.ts +++ b/src/definitions/person.ts @@ -31,6 +31,8 @@ export type PersonDefinitions = LocaleEntry<{ name: string[]; title: PersonTitleDefinitions; + + western_zodiac_sign: string[]; }>; /** diff --git a/src/locales/en/person/index.ts b/src/locales/en/person/index.ts index 24dcdf762f8..68824ff3869 100644 --- a/src/locales/en/person/index.ts +++ b/src/locales/en/person/index.ts @@ -16,6 +16,7 @@ import prefix from './prefix'; import sex from './sex'; import suffix from './suffix'; import title from './title'; +import western_zodiac_sign from './western_zodiac_sign'; const person: PersonDefinitions = { female_first_name, @@ -31,6 +32,7 @@ const person: PersonDefinitions = { sex, suffix, title, + western_zodiac_sign, }; export default person; diff --git a/src/locales/en/person/western_zodiac_sign.ts b/src/locales/en/person/western_zodiac_sign.ts new file mode 100644 index 00000000000..095925eac10 --- /dev/null +++ b/src/locales/en/person/western_zodiac_sign.ts @@ -0,0 +1,14 @@ +export default [ + 'Aquarius', + 'Pisces', + 'Aries', + 'Taurus', + 'Gemini', + 'Cancer', + 'Leo', + 'Virgo', + 'Libra', + 'Scorpio', + 'Sagittarius', + 'Capricorn', +]; diff --git a/src/modules/person/index.ts b/src/modules/person/index.ts index 023cded121b..af954d546f9 100644 --- a/src/modules/person/index.ts +++ b/src/modules/person/index.ts @@ -330,4 +330,18 @@ export class PersonModule { this.faker.definitions.person.title.job ); } + + /** + * Returns a random zodiac sign. + * + * @example + * faker.person.zodiacSign() // 'Pisces' + * + * @since 8.0.0 + */ + zodiacSign(): string { + return this.faker.helpers.arrayElement( + this.faker.definitions.person.western_zodiac_sign + ); + } } diff --git a/test/__snapshots__/person.spec.ts.snap b/test/__snapshots__/person.spec.ts.snap index 81181d3236d..a74ca00a33b 100644 --- a/test/__snapshots__/person.spec.ts.snap +++ b/test/__snapshots__/person.spec.ts.snap @@ -46,6 +46,8 @@ exports[`person > 42 > suffix > noArgs 1`] = `"III"`; exports[`person > 42 > suffix > with sex 1`] = `"III"`; +exports[`person > 42 > zodiacSign 1`] = `"Gemini"`; + exports[`person > 1211 > firstName > noArgs 1`] = `"Tito"`; exports[`person > 1211 > firstName > with sex 1`] = `"Percy"`; @@ -92,6 +94,8 @@ exports[`person > 1211 > suffix > noArgs 1`] = `"DVM"`; exports[`person > 1211 > suffix > with sex 1`] = `"DVM"`; +exports[`person > 1211 > zodiacSign 1`] = `"Capricorn"`; + exports[`person > 1337 > firstName > noArgs 1`] = `"Devyn"`; exports[`person > 1337 > firstName > with sex 1`] = `"Ray"`; @@ -137,3 +141,5 @@ exports[`person > 1337 > sexType 1`] = `"female"`; exports[`person > 1337 > suffix > noArgs 1`] = `"I"`; exports[`person > 1337 > suffix > with sex 1`] = `"I"`; + +exports[`person > 1337 > zodiacSign 1`] = `"Taurus"`; diff --git a/test/person.spec.ts b/test/person.spec.ts index 42b9e66f73f..757c6e8c093 100644 --- a/test/person.spec.ts +++ b/test/person.spec.ts @@ -40,6 +40,8 @@ describe('person', () => { sex: 'female', }); }); + + t.it('zodiacSign'); }); describe(`random seeded tests for seed ${faker.seed()}`, () => { @@ -382,6 +384,16 @@ describe('person', () => { expect(faker.definitions.person.title.job).toContain(job); }); }); + + describe('zodiacSign()', () => { + it('returns a random zodiac sign', () => { + const sign = faker.person.zodiacSign(); + + expect(sign).toBeTypeOf('string'); + + expect(faker.definitions.person.western_zodiac_sign).toContain(sign); + }); + }); } }); });