From ff6dda94ddd312ebcff816cbb63e74df9857d091 Mon Sep 17 00:00:00 2001 From: Umair Jibran Date: Sat, 14 Dec 2024 16:00:59 +0500 Subject: feat(location): add list of spoken languages (#3333) * add list of spoken languages * remove dupes * add language definition * add language module * add test case for `language()` * autogenerated supporting code * add languages for urdu * add test to make sure the values are truthy * update seed to match new format * update language list slim them down to a few languages as the long list was not easy to build up * update documentation * update returns * language: convert alpha2 to lowercase * update seed flies * covert alpha3 to lowercase * update seeders * update example * update version * use interface for language * Update index.ts * Revert "Update index.ts" This reverts commit 72a18e99cfee1f4c09d151b27bda1f2c8d1137d8. * Update src/modules/location/index.ts Co-authored-by: ST-DDT * Update src/modules/location/index.ts Co-authored-by: ST-DDT * Update src/definitions/location.ts Co-authored-by: ST-DDT * language semantic Co-authored-by: ST-DDT * add additional test cases * add examples for each property * add languages for the supported locales * update seeds * use example of german instead of english * Update src/definitions/location.ts Co-authored-by: ST-DDT --------- Co-authored-by: ST-DDT --- test/modules/__snapshots__/location.spec.ts.snap | 24 ++++++++++++++++++++++++ test/modules/location.spec.ts | 15 +++++++++++++++ 2 files changed, 39 insertions(+) (limited to 'test/modules') diff --git a/test/modules/__snapshots__/location.spec.ts.snap b/test/modules/__snapshots__/location.spec.ts.snap index a8d24e9a..6116943f 100644 --- a/test/modules/__snapshots__/location.spec.ts.snap +++ b/test/modules/__snapshots__/location.spec.ts.snap @@ -32,6 +32,14 @@ exports[`location > 42 > direction > noArgs 1`] = `"South"`; exports[`location > 42 > direction > with abbreviated option 1`] = `"S"`; +exports[`location > 42 > language 1`] = ` +{ + "alpha2": "gu", + "alpha3": "guj", + "name": "Gujarati", +} +`; + exports[`location > 42 > latitude > noArgs 1`] = `-22.5828`; exports[`location > 42 > latitude > with max and min option 1`] = `-2.5092`; @@ -170,6 +178,14 @@ exports[`location > 1211 > direction > noArgs 1`] = `"Southwest"`; exports[`location > 1211 > direction > with abbreviated option 1`] = `"SW"`; +exports[`location > 1211 > language 1`] = ` +{ + "alpha2": "tl", + "alpha3": "tgl", + "name": "Tagalog", +} +`; + exports[`location > 1211 > latitude > noArgs 1`] = `77.1337`; exports[`location > 1211 > latitude > with max and min option 1`] = `8.5704`; @@ -308,6 +324,14 @@ exports[`location > 1337 > direction > noArgs 1`] = `"South"`; exports[`location > 1337 > direction > with abbreviated option 1`] = `"S"`; +exports[`location > 1337 > language 1`] = ` +{ + "alpha2": "ru", + "alpha3": "rus", + "name": "Russian", +} +`; + exports[`location > 1337 > latitude > noArgs 1`] = `-42.8356`; exports[`location > 1337 > latitude > with max and min option 1`] = `-4.7595`; diff --git a/test/modules/location.spec.ts b/test/modules/location.spec.ts index 2be7c489..78b68812 100644 --- a/test/modules/location.spec.ts +++ b/test/modules/location.spec.ts @@ -126,6 +126,8 @@ describe('location', () => { t.it('timeZone'); + t.it('language'); + t.describeEach( 'direction', 'cardinalDirection', @@ -415,6 +417,19 @@ describe('location', () => { expect(faker.definitions.location.time_zone).toContain(actual); }); }); + + describe('language()', () => { + it('should return a random language', () => { + const actual = faker.location.language(); + expect(actual.name).toBeTruthy(); + expect(actual.alpha2).toBeTruthy(); + expect(actual.alpha2).toHaveLength(2); + expect(actual.alpha3).toBeTruthy(); + expect(actual.alpha3).toHaveLength(3); + + expect(faker.definitions.location.language).toContain(actual); + }); + }); } ); }); -- cgit v1.2.3