diff options
| author | Shinigami <[email protected]> | 2022-02-06 11:14:18 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-02-06 11:14:18 +0100 |
| commit | e618a4b4c1392e7a60a7c1088ec70236c09d1f73 (patch) | |
| tree | 99ed987a432182d48562a6e214b54dd41b28d63a /src | |
| parent | f8e24086b1aa0bc640553bcfc3e8bede9980d089 (diff) | |
| download | faker-e618a4b4c1392e7a60a7c1088ec70236c09d1f73.tar.xz faker-e618a4b4c1392e7a60a7c1088ec70236c09d1f73.zip | |
test: cover source instead of bundled code (#432)
Diffstat (limited to 'src')
| -rw-r--r-- | src/address.ts | 4 | ||||
| -rw-r--r-- | src/finance.ts | 2 | ||||
| -rw-r--r-- | src/helpers.ts | 2 | ||||
| -rw-r--r-- | src/image.ts | 4 | ||||
| -rw-r--r-- | src/image_providers/lorempicsum.ts | 4 | ||||
| -rw-r--r-- | src/image_providers/lorempixel.ts | 4 | ||||
| -rw-r--r-- | src/image_providers/unsplash.ts | 4 | ||||
| -rw-r--r-- | src/internet.ts | 14 | ||||
| -rw-r--r-- | src/name.ts | 4 | ||||
| -rw-r--r-- | src/unique.ts | 2 |
10 files changed, 23 insertions, 21 deletions
diff --git a/src/address.ts b/src/address.ts index c510b46c..66cd0ca2 100644 --- a/src/address.ts +++ b/src/address.ts @@ -454,8 +454,8 @@ export class Address { if (coordinate === undefined) { return [this.faker.address.latitude(), this.faker.address.longitude()]; } - radius ||= 10.0; - isMetric ||= false; + radius = radius || 10.0; + isMetric = isMetric || false; // TODO: implement either a gaussian/uniform distribution of points in circular region. // Possibly include param to function that allows user to choose between distributions. diff --git a/src/finance.ts b/src/finance.ts index 09a47382..7b861758 100644 --- a/src/finance.ts +++ b/src/finance.ts @@ -25,7 +25,7 @@ export class Finance { * @param length */ account(length?: number): string { - length ||= 8; + length = length || 8; let template = ''; for (let i = 0; i < length; i++) { diff --git a/src/helpers.ts b/src/helpers.ts index c67a50a6..e8191bfe 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -342,7 +342,7 @@ export class Helpers { return o || []; } - o ||= ['a', 'b', 'c'] as unknown as T[]; + o = o || (['a', 'b', 'c'] as unknown as T[]); for (let x: T, j: number, i = o.length - 1; i > 0; --i) { j = this.faker.datatype.number(i); x = o[i]; diff --git a/src/image.ts b/src/image.ts index 1a74f26e..761e446e 100644 --- a/src/image.ts +++ b/src/image.ts @@ -81,8 +81,8 @@ export class Image { randomize?: boolean, https?: boolean ): string { - width ||= 640; - height ||= 480; + width = width || 640; + height = height || 480; let protocol = 'http://'; if (typeof https !== 'undefined' && https === true) { protocol = 'https://'; diff --git a/src/image_providers/lorempicsum.ts b/src/image_providers/lorempicsum.ts index 635ab9e6..a3136458 100644 --- a/src/image_providers/lorempicsum.ts +++ b/src/image_providers/lorempicsum.ts @@ -99,8 +99,8 @@ export class LoremPicsum { blur?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10, seed?: string ): string { - width ||= 640; - height ||= 480; + width = width || 640; + height = height || 480; let url = 'https://picsum.photos'; diff --git a/src/image_providers/lorempixel.ts b/src/image_providers/lorempixel.ts index 045da3f2..b6717b46 100644 --- a/src/image_providers/lorempixel.ts +++ b/src/image_providers/lorempixel.ts @@ -58,8 +58,8 @@ export class Lorempixel { category?: string, randomize?: boolean ): string { - width ||= 640; - height ||= 480; + width = width || 640; + height = height || 480; let url = `https://lorempixel.com/${width}/${height}`; if (typeof category !== 'undefined') { diff --git a/src/image_providers/unsplash.ts b/src/image_providers/unsplash.ts index 580a3d96..16bf4f11 100644 --- a/src/image_providers/unsplash.ts +++ b/src/image_providers/unsplash.ts @@ -49,8 +49,8 @@ export class Unsplash { category?: string, keyword?: string ): string { - width ||= 640; - height ||= 480; + width = width || 640; + height = height || 480; let url = 'https://source.unsplash.com'; diff --git a/src/internet.ts b/src/internet.ts index 7b74101f..ff227dbf 100644 --- a/src/internet.ts +++ b/src/internet.ts @@ -199,9 +199,11 @@ export class Internet { * @param provider */ email(firstName?: string, lastName?: string, provider?: string): string { - provider ||= this.faker.random.arrayElement( - this.faker.definitions.internet.free_email - ); + provider = + provider || + this.faker.random.arrayElement( + this.faker.definitions.internet.free_email + ); return ( this.faker.helpers.slugify( this.faker.internet.userName(firstName, lastName) @@ -234,8 +236,8 @@ export class Internet { */ userName(firstName?: string, lastName?: string): string { let result: string; - firstName ||= this.faker.name.firstName(); - lastName ||= this.faker.name.lastName(); + firstName = firstName || this.faker.name.firstName(); + lastName = lastName || this.faker.name.lastName(); switch (this.faker.datatype.number(2)) { case 0: result = `${firstName}${this.faker.datatype.number(99)}`; @@ -481,7 +483,7 @@ export class Internet { pattern?: RegExp, prefix?: string ): string { - len ||= 15; + len = len || 15; if (typeof memorable === 'undefined') { memorable = false; } diff --git a/src/name.ts b/src/name.ts index 4e813989..e62ba45e 100644 --- a/src/name.ts +++ b/src/name.ts @@ -176,8 +176,8 @@ export class Name { gender = this.faker.datatype.number(1); } - firstName ||= this.faker.name.firstName(gender); - lastName ||= this.faker.name.lastName(gender); + firstName = firstName || this.faker.name.firstName(gender); + lastName = lastName || this.faker.name.lastName(gender); switch (r) { case 0: diff --git a/src/unique.ts b/src/unique.ts index eef662b2..7379af1d 100644 --- a/src/unique.ts +++ b/src/unique.ts @@ -37,7 +37,7 @@ export class Unique { compare?: (obj: Record<string, string>, key: string) => 0 | -1; } ): string { - opts ||= {}; + opts = opts || {}; opts.startTime = new Date().getTime(); if (typeof opts.maxTime !== 'number') { opts.maxTime = this.maxTime; |
