diff options
| author | Shinigami <[email protected]> | 2024-03-18 09:49:27 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-03-18 08:49:27 +0000 |
| commit | 6dee178558b87b73bba1395c11d2ffe3d156dad1 (patch) | |
| tree | fa36e0dfe38c0c84fe9aec832293e69c82ec4f89 /test | |
| parent | e624d0edddfbbb6a67f3a3abfec48ac37e70b976 (diff) | |
| download | faker-6dee178558b87b73bba1395c11d2ffe3d156dad1.tar.xz faker-6dee178558b87b73bba1395c11d2ffe3d156dad1.zip | |
refactor(location)!: remove v8 deprecated location methods (#2753)
Diffstat (limited to 'test')
| -rw-r--r-- | test/all-functional.spec.ts | 2 | ||||
| -rw-r--r-- | test/modules/__snapshots__/helpers.spec.ts.snap | 2 | ||||
| -rw-r--r-- | test/modules/__snapshots__/location.spec.ts.snap | 72 | ||||
| -rw-r--r-- | test/modules/helpers.spec.ts | 12 | ||||
| -rw-r--r-- | test/modules/location.spec.ts | 42 |
5 files changed, 10 insertions, 120 deletions
diff --git a/test/all-functional.spec.ts b/test/all-functional.spec.ts index 577e6498..12b69ba1 100644 --- a/test/all-functional.spec.ts +++ b/test/all-functional.spec.ts @@ -51,9 +51,7 @@ const BROKEN_LOCALE_METHODS = { }, location: { state: ['az', 'nb_NO', 'ro_MD', 'sk'], - stateAbbr: ['cs_CZ', 'ro_MD', 'sk'], zipCode: ['en_HK'], - zipCodeByState: ['en_HK'], }, string: { fromCharacters: '*', diff --git a/test/modules/__snapshots__/helpers.spec.ts.snap b/test/modules/__snapshots__/helpers.spec.ts.snap index d8a78602..92801e06 100644 --- a/test/modules/__snapshots__/helpers.spec.ts.snap +++ b/test/modules/__snapshots__/helpers.spec.ts.snap @@ -263,7 +263,7 @@ exports[`helpers > 1211 > fake > with a static template 1`] = `"my test string"` exports[`helpers > 1211 > fake > with empty string 1`] = `""`; -exports[`helpers > 1211 > fake > with multiple dynamic templates 1`] = `"The Villages"`; +exports[`helpers > 1211 > fake > with multiple dynamic templates 1`] = `"396 St George's Road"`; exports[`helpers > 1211 > fake > with multiple static templates 1`] = `"C"`; diff --git a/test/modules/__snapshots__/location.spec.ts.snap b/test/modules/__snapshots__/location.spec.ts.snap index a29416ed..5d4b1d31 100644 --- a/test/modules/__snapshots__/location.spec.ts.snap +++ b/test/modules/__snapshots__/location.spec.ts.snap @@ -6,12 +6,8 @@ exports[`location > 42 > cardinalDirection > noArgs 1`] = `"East"`; exports[`location > 42 > cardinalDirection > with abbreviated option 1`] = `"E"`; -exports[`location > 42 > cardinalDirection > with boolean 1`] = `"East"`; - exports[`location > 42 > city 1`] = `"Fort Moses"`; -exports[`location > 42 > cityName 1`] = `"Hamilton"`; - exports[`location > 42 > country 1`] = `"Guinea"`; exports[`location > 42 > countryCode > noArgs 1`] = `"GY"`; @@ -34,42 +30,28 @@ exports[`location > 42 > direction > noArgs 1`] = `"South"`; exports[`location > 42 > direction > with abbreviated option 1`] = `"S"`; -exports[`location > 42 > direction > with boolean 1`] = `"South"`; - exports[`location > 42 > latitude > noArgs 1`] = `-22.5828`; -exports[`location > 42 > latitude > with max 1`] = `-52.546`; - exports[`location > 42 > latitude > with max and min option 1`] = `-2.5092`; exports[`location > 42 > latitude > with max option 1`] = `-52.546`; exports[`location > 42 > latitude > with max, min and precision option 1`] = `-2.5091976231`; -exports[`location > 42 > latitude > with min 1`] = `27.454`; - exports[`location > 42 > latitude > with min option 1`] = `27.454`; -exports[`location > 42 > latitude > with precision 1`] = `-22.5827786075`; - exports[`location > 42 > latitude > with precision option 1`] = `-22.5827786075`; exports[`location > 42 > longitude > noArgs 1`] = `-45.1656`; -exports[`location > 42 > longitude > with max 1`] = `-108.8374`; - exports[`location > 42 > longitude > with max and min option 1`] = `-2.5092`; exports[`location > 42 > longitude > with max option 1`] = `-108.8374`; exports[`location > 42 > longitude > with max, min and precision option 1`] = `-2.5091976231`; -exports[`location > 42 > longitude > with min 1`] = `61.1626`; - exports[`location > 42 > longitude > with min option 1`] = `61.1626`; -exports[`location > 42 > longitude > with precision 1`] = `-45.165557215`; - exports[`location > 42 > longitude > with precision option 1`] = `-45.165557215`; exports[`location > 42 > nearbyGPSCoordinate > near origin 1`] = ` @@ -132,16 +114,12 @@ exports[`location > 42 > ordinalDirection > noArgs 1`] = `"Northwest"`; exports[`location > 42 > ordinalDirection > with abbreviated option 1`] = `"NW"`; -exports[`location > 42 > ordinalDirection > with boolean 1`] = `"Northwest"`; - exports[`location > 42 > secondaryAddress 1`] = `"Apt. 975"`; exports[`location > 42 > state > noArgs 1`] = `"Maine"`; exports[`location > 42 > state > with options 1`] = `"ME"`; -exports[`location > 42 > stateAbbr 1`] = `"ME"`; - exports[`location > 42 > street 1`] = `"Wiegand Ridges"`; exports[`location > 42 > streetAddress > noArgs 1`] = `"9751 Anderson Throughway"`; @@ -158,20 +136,14 @@ exports[`location > 42 > zipCode > with format option 1`] = `"397-511"`; exports[`location > 42 > zipCode > with string 1`] = `"397"`; -exports[`location > 42 > zipCodeByState > noArgs 1`] = `"97511"`; - exports[`location > 1211 > buildingNumber 1`] = `"929"`; exports[`location > 1211 > cardinalDirection > noArgs 1`] = `"West"`; exports[`location > 1211 > cardinalDirection > with abbreviated option 1`] = `"W"`; -exports[`location > 1211 > cardinalDirection > with boolean 1`] = `"West"`; - exports[`location > 1211 > city 1`] = `"The Villages"`; -exports[`location > 1211 > cityName 1`] = `"Utica"`; - exports[`location > 1211 > country 1`] = `"Uganda"`; exports[`location > 1211 > countryCode > noArgs 1`] = `"UM"`; @@ -194,42 +166,28 @@ exports[`location > 1211 > direction > noArgs 1`] = `"Southwest"`; exports[`location > 1211 > direction > with abbreviated option 1`] = `"SW"`; -exports[`location > 1211 > direction > with boolean 1`] = `"Southwest"`; - exports[`location > 1211 > latitude > noArgs 1`] = `77.1337`; -exports[`location > 1211 > latitude > with max 1`] = `2.8521`; - exports[`location > 1211 > latitude > with max and min option 1`] = `8.5704`; exports[`location > 1211 > latitude > with max option 1`] = `2.8521`; exports[`location > 1211 > latitude > with max, min and precision option 1`] = `8.5704030781`; -exports[`location > 1211 > latitude > with min 1`] = `82.8521`; - exports[`location > 1211 > latitude > with min option 1`] = `82.8521`; -exports[`location > 1211 > latitude > with precision 1`] = `77.1336277025`; - exports[`location > 1211 > latitude > with precision option 1`] = `77.1336277025`; exports[`location > 1211 > longitude > noArgs 1`] = `154.2673`; -exports[`location > 1211 > longitude > with max 1`] = `-3.5811`; - exports[`location > 1211 > longitude > with max and min option 1`] = `8.5704`; exports[`location > 1211 > longitude > with max option 1`] = `-3.5811`; exports[`location > 1211 > longitude > with max, min and precision option 1`] = `8.5704030781`; -exports[`location > 1211 > longitude > with min 1`] = `166.4189`; - exports[`location > 1211 > longitude > with min option 1`] = `166.4189`; -exports[`location > 1211 > longitude > with precision 1`] = `154.267255405`; - exports[`location > 1211 > longitude > with precision option 1`] = `154.267255405`; exports[`location > 1211 > nearbyGPSCoordinate > near origin 1`] = ` @@ -292,16 +250,12 @@ exports[`location > 1211 > ordinalDirection > noArgs 1`] = `"Southwest"`; exports[`location > 1211 > ordinalDirection > with abbreviated option 1`] = `"SW"`; -exports[`location > 1211 > ordinalDirection > with boolean 1`] = `"Southwest"`; - exports[`location > 1211 > secondaryAddress 1`] = `"Suite 929"`; exports[`location > 1211 > state > noArgs 1`] = `"Washington"`; exports[`location > 1211 > state > with options 1`] = `"WA"`; -exports[`location > 1211 > stateAbbr 1`] = `"WA"`; - exports[`location > 1211 > street 1`] = `"W Chestnut Street"`; exports[`location > 1211 > streetAddress > noArgs 1`] = `"929 S Broad Street"`; @@ -318,20 +272,14 @@ exports[`location > 1211 > zipCode > with format option 1`] = `"982-966"`; exports[`location > 1211 > zipCode > with string 1`] = `"982"`; -exports[`location > 1211 > zipCodeByState > noArgs 1`] = `"82966-7368"`; - exports[`location > 1337 > buildingNumber 1`] = `"22435"`; exports[`location > 1337 > cardinalDirection > noArgs 1`] = `"East"`; exports[`location > 1337 > cardinalDirection > with abbreviated option 1`] = `"E"`; -exports[`location > 1337 > cardinalDirection > with boolean 1`] = `"East"`; - exports[`location > 1337 > city 1`] = `"East Duane"`; -exports[`location > 1337 > cityName 1`] = `"East Hartford"`; - exports[`location > 1337 > country 1`] = `"Egypt"`; exports[`location > 1337 > countryCode > noArgs 1`] = `"EH"`; @@ -354,42 +302,28 @@ exports[`location > 1337 > direction > noArgs 1`] = `"South"`; exports[`location > 1337 > direction > with abbreviated option 1`] = `"S"`; -exports[`location > 1337 > direction > with boolean 1`] = `"South"`; - exports[`location > 1337 > latitude > noArgs 1`] = `-42.8356`; -exports[`location > 1337 > latitude > with max 1`] = `-63.7976`; - exports[`location > 1337 > latitude > with max and min option 1`] = `-4.7595`; exports[`location > 1337 > latitude > with max option 1`] = `-63.7976`; exports[`location > 1337 > latitude > with max, min and precision option 1`] = `-4.7595064997`; -exports[`location > 1337 > latitude > with min 1`] = `16.2024`; - exports[`location > 1337 > latitude > with min option 1`] = `16.2024`; -exports[`location > 1337 > latitude > with precision 1`] = `-42.8355584972`; - exports[`location > 1337 > latitude > with precision option 1`] = `-42.8355584972`; exports[`location > 1337 > longitude > noArgs 1`] = `-85.6711`; -exports[`location > 1337 > longitude > with max 1`] = `-130.2153`; - exports[`location > 1337 > longitude > with max and min option 1`] = `-4.7595`; exports[`location > 1337 > longitude > with max option 1`] = `-130.2153`; exports[`location > 1337 > longitude > with max, min and precision option 1`] = `-4.7595064997`; -exports[`location > 1337 > longitude > with min 1`] = `39.7847`; - exports[`location > 1337 > longitude > with min option 1`] = `39.7847`; -exports[`location > 1337 > longitude > with precision 1`] = `-85.6711169944`; - exports[`location > 1337 > longitude > with precision option 1`] = `-85.6711169944`; exports[`location > 1337 > nearbyGPSCoordinate > near origin 1`] = ` @@ -452,16 +386,12 @@ exports[`location > 1337 > ordinalDirection > noArgs 1`] = `"Northwest"`; exports[`location > 1337 > ordinalDirection > with abbreviated option 1`] = `"NW"`; -exports[`location > 1337 > ordinalDirection > with boolean 1`] = `"Northwest"`; - exports[`location > 1337 > secondaryAddress 1`] = `"Apt. 224"`; exports[`location > 1337 > state > noArgs 1`] = `"Indiana"`; exports[`location > 1337 > state > with options 1`] = `"IN"`; -exports[`location > 1337 > stateAbbr 1`] = `"IN"`; - exports[`location > 1337 > street 1`] = `"Carmella Forge"`; exports[`location > 1337 > streetAddress > noArgs 1`] = `"22435 Westley Ridges"`; @@ -477,5 +407,3 @@ exports[`location > 1337 > zipCode > noArgs 1`] = `"12435"`; exports[`location > 1337 > zipCode > with format option 1`] = `"212-435"`; exports[`location > 1337 > zipCode > with string 1`] = `"212"`; - -exports[`location > 1337 > zipCodeByState > noArgs 1`] = `"12435"`; diff --git a/test/modules/helpers.spec.ts b/test/modules/helpers.spec.ts index e60859ef..98c3488a 100644 --- a/test/modules/helpers.spec.ts +++ b/test/modules/helpers.spec.ts @@ -152,7 +152,7 @@ describe('helpers', () => { .it('with multiple dynamic templates', [ '{{string.sample}}', '{{location.city_name}}', - '{{location.cityName}}', + '{{location.streetAddress}}', ]); }); @@ -989,10 +989,10 @@ describe('helpers', () => { }); it('should be able to pass multiple dynamic templates', () => { - expect(faker.definitions.location.city_name).toContain( + expect(faker.definitions.company.buzz_noun).toContain( faker.helpers.fake([ - '{{location.city_name}}', - '{{location.cityName}}', + '{{company.buzz_noun}}', + '{{company.buzzNoun}}', ]) ); }); @@ -1038,8 +1038,8 @@ describe('helpers', () => { }); it('should support deprecated module aliases', () => { - expect(faker.definitions.location.city_name).toContain( - faker.helpers.fake('{{address.cityName}}') + expect(faker.definitions.location.state).toContain( + faker.helpers.fake('{{address.state}}') ); expect(faker.definitions.person.first_name).toContain( faker.helpers.fake('{{name.firstName}}') diff --git a/test/modules/location.spec.ts b/test/modules/location.spec.ts index 682e3441..86897ad5 100644 --- a/test/modules/location.spec.ts +++ b/test/modules/location.spec.ts @@ -55,9 +55,6 @@ describe('location', () => { seededTests(faker, 'location', (t) => { t.it('street'); - // TODO @xDivisionByZerox 2023-04-16: add street name locale data to `en` - t.skip('streetName'); - t.it('buildingNumber'); t.it('secondaryAddress'); @@ -68,7 +65,7 @@ describe('location', () => { .it('with useFullAddress options', { useFullAddress: true }); }); - t.itEach('city', 'cityName'); + t.itEach('city'); t.it('county'); @@ -89,9 +86,6 @@ describe('location', () => { 'longitude' )((t) => { t.it('noArgs') - .it('with max', 10) - .it('with min', undefined, -10) - .it('with precision', undefined, undefined, 10) .it('with max option', { max: 10 }) .it('with min option', { min: -10 }) .it('with precision option', { precision: 10 }) @@ -122,8 +116,6 @@ describe('location', () => { t.it('noArgs').it('with options', { abbreviated: true }); }); - t.it('stateAbbr'); - t.it('timeZone'); t.describeEach( @@ -131,27 +123,17 @@ describe('location', () => { 'cardinalDirection', 'ordinalDirection' )((t) => { - t.it('noArgs') - .it('with boolean', false) - .it('with abbreviated option', { abbreviated: true }); + t.it('noArgs').it('with abbreviated option', { abbreviated: true }); }); t.describe('zipCode', (t) => { t.it('noArgs') .it('with string', '###') .it('with format option', { format: '###-###' }); - // These are currently commented out because non-default locales are currently not supported + // TODO @Shinigami92 2024-03-15: These are currently commented out because non-default locales are currently not supported // .it('with state option', { state: 'CA' }) // .it('with options', { state: 'CA', format: '###-###' }); }); - - t.describe('zipCodeByState', (t) => { - t.it('noArgs'); - // These are currently commented out because non-default locales are currently not supported - // .it('with string 1', 'CA') - // .it('with string 2', 'WA') - // .it('with state options', { state: 'WA' }); - }); }); describe.each(times(NON_SEEDED_BASED_RUN).map(() => faker.seed()))( @@ -231,24 +213,6 @@ describe('location', () => { }); }); - describe('zipCodeByState()', () => { - it('returns zipCode valid for specified State', () => { - const states = ['IL', 'GA', 'WA']; - - const zipCode1 = +fakerEN_US.location.zipCodeByState(states[0]); - expect(zipCode1).toBeGreaterThanOrEqual(60001); - expect(zipCode1).toBeLessThanOrEqual(62999); - - const zipCode2 = +fakerEN_US.location.zipCodeByState(states[1]); - expect(zipCode2).toBeGreaterThanOrEqual(30001); - expect(zipCode2).toBeLessThanOrEqual(31999); - - const zipCode3 = +fakerEN_US.location.zipCodeByState(states[2]); - expect(zipCode3).toBeGreaterThanOrEqual(98001); - expect(zipCode3).toBeLessThanOrEqual(99403); - }); - }); - describe('buildingNumber()', () => { it('never starts with a zero', () => { const buildingNumber = faker.location.buildingNumber(); |
