Skip to content

Commit f1bf905

Browse files
committed
also secondary_address
1 parent 09bbaa1 commit f1bf905

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

src/definitions/location.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export type LocationDefinitions = LocaleEntry<{
112112
};
113113

114114
/**
115-
* The address "inside" an address/e.g. an apartment or office.
115+
* The address "inside" an address/e.g. an apartment or office. Since these rarely start with 0, any consecutive # characters will be replaced by a number without a leading zero.
116116
*/
117117
secondary_address: string[];
118118

src/modules/location/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,14 @@ export class LocationModule {
284284
* @since 8.0.0
285285
*/
286286
secondaryAddress(): string {
287-
return this.faker.helpers.replaceSymbolWithNumber(
288-
this.faker.helpers.arrayElement(
289-
this.faker.definitions.location.secondary_address
290-
)
291-
);
287+
return this.faker.helpers
288+
.arrayElement(this.faker.definitions.location.secondary_address)
289+
.replace(/#+/g, (m) =>
290+
this.faker.string.numeric({
291+
length: m.length,
292+
allowLeadingZeros: false,
293+
})
294+
);
292295
}
293296

294297
/**

test/__snapshots__/location.spec.ts.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ exports[`location > 42 > ordinalDirection > with abbreviated option 1`] = `"NW"`
126126

127127
exports[`location > 42 > ordinalDirection > with boolean 1`] = `"Northwest"`;
128128

129-
exports[`location > 42 > secondaryAddress 1`] = `"Apt. 791"`;
129+
exports[`location > 42 > secondaryAddress 1`] = `"Apt. 891"`;
130130

131131
exports[`location > 42 > state > noArgs 1`] = `"Maine"`;
132132

@@ -140,7 +140,7 @@ exports[`location > 42 > streetAddress > noArgs 1`] = `"8917 Miller Park"`;
140140

141141
exports[`location > 42 > streetAddress > with boolean 1`] = `"8917 Miller Park"`;
142142

143-
exports[`location > 42 > streetAddress > with useFullAddress options 1`] = `"8917 Miller Park Apt. 410"`;
143+
exports[`location > 42 > streetAddress > with useFullAddress options 1`] = `"8917 Miller Park Apt. 510"`;
144144

145145
exports[`location > 42 > timeZone 1`] = `"America/North_Dakota/New_Salem"`;
146146

@@ -278,7 +278,7 @@ exports[`location > 1211 > ordinalDirection > with abbreviated option 1`] = `"SW
278278

279279
exports[`location > 1211 > ordinalDirection > with boolean 1`] = `"Southwest"`;
280280

281-
exports[`location > 1211 > secondaryAddress 1`] = `"Suite 487"`;
281+
exports[`location > 1211 > secondaryAddress 1`] = `"Suite 587"`;
282282

283283
exports[`location > 1211 > state > noArgs 1`] = `"Washington"`;
284284

@@ -292,7 +292,7 @@ exports[`location > 1211 > streetAddress > noArgs 1`] = `"587 Breana Wells"`;
292292

293293
exports[`location > 1211 > streetAddress > with boolean 1`] = `"587 Breana Wells"`;
294294

295-
exports[`location > 1211 > streetAddress > with useFullAddress options 1`] = `"587 Breana Wells Apt. 616"`;
295+
exports[`location > 1211 > streetAddress > with useFullAddress options 1`] = `"587 Breana Wells Apt. 716"`;
296296

297297
exports[`location > 1211 > timeZone 1`] = `"Pacific/Fiji"`;
298298

@@ -430,7 +430,7 @@ exports[`location > 1337 > ordinalDirection > with abbreviated option 1`] = `"NW
430430

431431
exports[`location > 1337 > ordinalDirection > with boolean 1`] = `"Northwest"`;
432432

433-
exports[`location > 1337 > secondaryAddress 1`] = `"Apt. 512"`;
433+
exports[`location > 1337 > secondaryAddress 1`] = `"Apt. 612"`;
434434

435435
exports[`location > 1337 > state > noArgs 1`] = `"Indiana"`;
436436

0 commit comments

Comments
 (0)