From 4056ab09c64be40d41562284ec64e7531fbaff41 Mon Sep 17 00:00:00 2001 From: Joscha Feth Date: Sat, 12 Oct 2024 14:39:42 +0100 Subject: [PATCH 1/3] feat(location): add `continent` method (#3162) --- src/definitions/location.ts | 5 +++++ src/locales/en/location/continent.ts | 9 +++++++++ src/locales/en/location/index.ts | 2 ++ src/modules/location/index.ts | 14 ++++++++++++++ test/modules/__snapshots__/location.spec.ts.snap | 6 ++++++ test/modules/location.spec.ts | 12 ++++++++++++ 6 files changed, 48 insertions(+) create mode 100644 src/locales/en/location/continent.ts diff --git a/src/definitions/location.ts b/src/definitions/location.ts index 5aee4e79e3f..9fbda95f59b 100644 --- a/src/definitions/location.ts +++ b/src/definitions/location.ts @@ -36,6 +36,11 @@ export type LocationDefinition = LocaleEntry<{ */ city_suffix: string[]; + /** + * The names of all continents. + */ + continent: string[]; + /** * The names of all countries. */ diff --git a/src/locales/en/location/continent.ts b/src/locales/en/location/continent.ts new file mode 100644 index 00000000000..379b460155e --- /dev/null +++ b/src/locales/en/location/continent.ts @@ -0,0 +1,9 @@ +export default [ + 'Africa', + 'Antarctica', + 'Asia', + 'Australia', + 'Europe', + 'North America', + 'South America', +]; diff --git a/src/locales/en/location/index.ts b/src/locales/en/location/index.ts index 7938321dcb7..64ca3268f7d 100644 --- a/src/locales/en/location/index.ts +++ b/src/locales/en/location/index.ts @@ -8,6 +8,7 @@ import city_name from './city_name'; import city_pattern from './city_pattern'; import city_prefix from './city_prefix'; import city_suffix from './city_suffix'; +import continent from './continent'; import country from './country'; import county from './county'; import direction from './direction'; @@ -26,6 +27,7 @@ const location: LocationDefinition = { city_pattern, city_prefix, city_suffix, + continent, country, county, direction, diff --git a/src/modules/location/index.ts b/src/modules/location/index.ts index 4aabdd8db4a..4a49e029501 100644 --- a/src/modules/location/index.ts +++ b/src/modules/location/index.ts @@ -216,6 +216,20 @@ export class LocationModule extends ModuleBase { ); } + /** + * Returns a random continent name. + * + * @example + * faker.location.continent() // 'Asia' + * + * @since 9.1.0 + */ + continent(): string { + return this.faker.helpers.arrayElement( + this.faker.definitions.location.continent + ); + } + /** * Returns a random [ISO_3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) country code. * diff --git a/test/modules/__snapshots__/location.spec.ts.snap b/test/modules/__snapshots__/location.spec.ts.snap index b53acbda355..a8d24e9a6ef 100644 --- a/test/modules/__snapshots__/location.spec.ts.snap +++ b/test/modules/__snapshots__/location.spec.ts.snap @@ -8,6 +8,8 @@ exports[`location > 42 > cardinalDirection > with abbreviated option 1`] = `"E"` exports[`location > 42 > city 1`] = `"Fort Moses"`; +exports[`location > 42 > continent 1`] = `"Asia"`; + exports[`location > 42 > country 1`] = `"Guinea"`; exports[`location > 42 > countryCode > noArgs 1`] = `"GY"`; @@ -144,6 +146,8 @@ exports[`location > 1211 > cardinalDirection > with abbreviated option 1`] = `"W exports[`location > 1211 > city 1`] = `"The Villages"`; +exports[`location > 1211 > continent 1`] = `"South America"`; + exports[`location > 1211 > country 1`] = `"Uganda"`; exports[`location > 1211 > countryCode > noArgs 1`] = `"UM"`; @@ -280,6 +284,8 @@ exports[`location > 1337 > cardinalDirection > with abbreviated option 1`] = `"E exports[`location > 1337 > city 1`] = `"East Duane"`; +exports[`location > 1337 > continent 1`] = `"Antarctica"`; + exports[`location > 1337 > country 1`] = `"Egypt"`; exports[`location > 1337 > countryCode > noArgs 1`] = `"EH"`; diff --git a/test/modules/location.spec.ts b/test/modules/location.spec.ts index 1291efd31fd..2be7c4896a3 100644 --- a/test/modules/location.spec.ts +++ b/test/modules/location.spec.ts @@ -77,6 +77,8 @@ describe('location', () => { t.it('country'); + t.it('continent'); + t.describe('countryCode', (t) => { t.it('noArgs') .it('with string alpha-2', 'alpha-2') @@ -145,6 +147,16 @@ describe('location', () => { describe.each(times(NON_SEEDED_BASED_RUN).map(() => faker.seed()))( 'random seeded tests for seed %i', () => { + describe('continent()', () => { + it('returns random continent', () => { + const actual = faker.location.continent(); + + expect(actual).toBeTruthy(); + expect(actual).toBeTypeOf('string'); + expect(faker.definitions.location.continent).toContain(actual); + }); + }); + describe('countryCode()', () => { it('returns random alpha-2 countryCode', () => { const countryCode = faker.location.countryCode('alpha-2'); From e271d4a545dd48e57285019e4f412358c49cad0d Mon Sep 17 00:00:00 2001 From: Matt Mayer <152770+matthewmayer@users.noreply.github.com> Date: Sun, 13 Oct 2024 05:44:40 +0700 Subject: [PATCH 2/3] fix(location): update valid ZIP ranges for FL and VA (#3167) --- src/locales/en_US/location/postcode_by_state.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/locales/en_US/location/postcode_by_state.ts b/src/locales/en_US/location/postcode_by_state.ts index 70b61700453..4f8ab247d15 100644 --- a/src/locales/en_US/location/postcode_by_state.ts +++ b/src/locales/en_US/location/postcode_by_state.ts @@ -8,7 +8,7 @@ export default { CT: '0{{number.int({"min": 6001,"max": 6389})}}', DC: '{{number.int({"min": 20001,"max": 20039})}}', DE: '{{number.int({"min": 19701,"max": 19980})}}', - FL: '{{number.int({"min": 32004,"max": 34997})}}', + FL: '{{helpers.arrayElement(["320","321","322","323","324","325","326","327","328","329","330","331","332","333","334","335","336","337","338","339","341","342","344","346","347","349"])}}{{string.numeric({"length": 2})}}', GA: '{{number.int({"min": 30001,"max": 31999})}}', HI: '{{number.int({"min": 96701,"max": 96898})}}', IA: '{{number.int({"min": 50001,"max": 52809})}}', @@ -45,7 +45,7 @@ export default { TN: '{{number.int({"min": 37010,"max": 38589})}}', TX: '{{number.int({"min": 75503,"max": 79999})}}', UT: '{{number.int({"min": 84001,"max": 84784})}}', - VA: '{{number.int({"min": 20040,"max": 20041})}}', + VA: '{{number.int({"min": 22201,"max": 24599})}}', VT: '0{{number.int({"min": 5001,"max": 5495})}}', WA: '{{number.int({"min": 98001,"max": 99403})}}', WI: '{{number.int({"min": 53001,"max": 54990})}}', From 34cf3643bee275f23bc7a39376c1b3d542a8c45f Mon Sep 17 00:00:00 2001 From: Suyash Gulati Date: Sun, 13 Oct 2024 04:23:36 +0530 Subject: [PATCH 3/3] refactor(internet): rename userName method to username (#3130) --- README.md | 2 +- docs/api/ApiIndex.vue | 7 +- docs/guide/frameworks.md | 4 +- src/modules/git/index.ts | 2 +- src/modules/internet/index.ts | 59 ++++++++++- .../__snapshots__/internet.spec.ts.snap | 48 +++++++++ test/modules/internet.spec.ts | 100 ++++++++++++++++-- .../scripts/apidocs/verify-jsdoc-tags.spec.ts | 5 + 8 files changed, 212 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 4ae41314474..9ff5153c784 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ const { faker } = require('@faker-js/faker'); export function createRandomUser() { return { userId: faker.string.uuid(), - username: faker.internet.userName(), + username: faker.internet.username(), // before version 9.1.0, use userName() email: faker.internet.email(), avatar: faker.image.avatar(), password: faker.internet.password(), diff --git a/docs/api/ApiIndex.vue b/docs/api/ApiIndex.vue index 7b1be7bf174..94085371ad1 100644 --- a/docs/api/ApiIndex.vue +++ b/docs/api/ApiIndex.vue @@ -69,8 +69,13 @@ const filtered = computed(() => {