aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby <[email protected]>2022-11-07 10:58:05 -0500
committerGitHub <[email protected]>2022-11-07 15:58:05 +0000
commit7e00d1741495f763f986b3a5daf40943db4abc7d (patch)
tree84bf218e5cce1977fcd14d883689516f9f5befba
parentd3632585e01ce4590be57d2045f73f0b25a0f16d (diff)
downloadfaker-7e00d1741495f763f986b3a5daf40943db4abc7d.tar.xz
faker-7e00d1741495f763f986b3a5daf40943db4abc7d.zip
feat(person): add `zodiacSign()` (#182)
Co-authored-by: ST-DDT <[email protected]>
-rw-r--r--src/definitions/person.ts2
-rw-r--r--src/locales/en/person/index.ts2
-rw-r--r--src/locales/en/person/western_zodiac_sign.ts14
-rw-r--r--src/modules/person/index.ts14
-rw-r--r--test/__snapshots__/person.spec.ts.snap6
-rw-r--r--test/person.spec.ts12
6 files changed, 50 insertions, 0 deletions
diff --git a/src/definitions/person.ts b/src/definitions/person.ts
index b6db46e1..488ff4fe 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 24dcdf76..68824ff3 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 00000000..095925ea
--- /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 023cded1..af954d54 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 81181d32..a74ca00a 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 42b9e66f..757c6e8c 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);
+ });
+ });
}
});
});