aboutsummaryrefslogtreecommitdiff
path: root/test/modules
diff options
context:
space:
mode:
authorUmair Jibran <[email protected]>2024-12-14 16:00:59 +0500
committerGitHub <[email protected]>2024-12-14 11:00:59 +0000
commitff6dda94ddd312ebcff816cbb63e74df9857d091 (patch)
tree6c4e9541d330dabdf739d4c1e6d3757a2dc42f78 /test/modules
parent3c7abb55e68fcbcf41560539a15845e7c8882765 (diff)
downloadfaker-ff6dda94ddd312ebcff816cbb63e74df9857d091.tar.xz
faker-ff6dda94ddd312ebcff816cbb63e74df9857d091.zip
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 <[email protected]> * Update src/modules/location/index.ts Co-authored-by: ST-DDT <[email protected]> * Update src/definitions/location.ts Co-authored-by: ST-DDT <[email protected]> * language semantic Co-authored-by: ST-DDT <[email protected]> * 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 <[email protected]> --------- Co-authored-by: ST-DDT <[email protected]>
Diffstat (limited to 'test/modules')
-rw-r--r--test/modules/__snapshots__/location.spec.ts.snap24
-rw-r--r--test/modules/location.spec.ts15
2 files changed, 39 insertions, 0 deletions
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);
+ });
+ });
}
);
});