Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(person): add zodiacSign() #182

Merged
merged 3 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/definitions/person.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export type PersonDefinitions = LocaleEntry<{
name: string[];

title: PersonTitleDefinitions;

western_zodiac_sign: string[];
}>;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en/person/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -31,6 +32,7 @@ const person: PersonDefinitions = {
sex,
suffix,
title,
western_zodiac_sign,
};

export default person;
14 changes: 14 additions & 0 deletions src/locales/en/person/western_zodiac_sign.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default [
'Aquarius',
'Pisces',
'Aries',
'Taurus',
'Gemini',
'Cancer',
'Leo',
'Virgo',
'Libra',
'Scorpio',
'Sagittarius',
'Capricorn',
];
14 changes: 14 additions & 0 deletions src/modules/person/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
6 changes: 6 additions & 0 deletions test/__snapshots__/person.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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"`;
Expand Down Expand Up @@ -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"`;
Expand Down Expand Up @@ -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"`;
12 changes: 12 additions & 0 deletions test/person.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ describe('person', () => {
sex: 'female',
});
});

t.it('zodiacSign');
});

describe(`random seeded tests for seed ${faker.seed()}`, () => {
Expand Down Expand Up @@ -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);
});
});
}
});
});