Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(internet): username method to return value that always includes… #2506

Merged
merged 11 commits into from
Nov 19, 2023
11 changes: 8 additions & 3 deletions src/modules/internet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export class InternetModule {

const {
firstName = this.faker.person.firstName(),
lastName = legacyLastName ?? this.faker.person.lastName(),
lastName = legacyLastName,
amillwood marked this conversation as resolved.
Show resolved Hide resolved
provider = legacyProvider ??
this.faker.helpers.arrayElement(
this.faker.definitions.internet.free_email
Expand Down Expand Up @@ -460,7 +460,7 @@ export class InternetModule {

const {
firstName = this.faker.person.firstName(),
lastName = legacyLastName ?? this.faker.person.lastName(),
lastName = legacyLastName,
amillwood marked this conversation as resolved.
Show resolved Hide resolved
allowSpecialCharacters = legacyOptions?.allowSpecialCharacters ?? false,
} = options;

Expand Down Expand Up @@ -616,7 +616,12 @@ export class InternetModule {
} = options;

let result: string;
switch (this.faker.number.int(2)) {
switch (
this.faker.number.int({
min: options.lastName || legacyLastName ? 1 : 0,
max: 2,
})
amillwood marked this conversation as resolved.
Show resolved Hide resolved
) {
case 0:
result = `${firstName}${this.faker.number.int(99)}`;
break;
Expand Down
30 changes: 15 additions & 15 deletions test/modules/__snapshots__/git.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@ exports[`git > 42 > commitDate > with only string refDate 1`] = `"Tue Dec 31 15:

exports[`git > 42 > commitEntry > with only Date refDate 1`] = `
"commit be4abdd39321ad7d3fe01ffce404f4d6db0906bd
Author: Gregg Beahan III <Gregg.Beahan@hotmail.com>
Date: Tue Dec 31 14:49:14 2019 +0100
Author: Gregg Beahan III <Gregg.Beahan38@hotmail.com>
Date: Tue Dec 31 11:39:29 2019 +1200

    parse multi-byte sensor
    quantify online protocol
"
`;

exports[`git > 42 > commitEntry > with only number refDate 1`] = `
"commit be4abdd39321ad7d3fe01ffce404f4d6db0906bd
Author: Gregg Beahan III <Gregg.Beahan@hotmail.com>
Date: Tue Dec 31 14:49:14 2019 +0100
Author: Gregg Beahan III <Gregg.Beahan38@hotmail.com>
Date: Tue Dec 31 11:39:29 2019 +1200

    parse multi-byte sensor
    quantify online protocol
"
`;

exports[`git > 42 > commitEntry > with only string refDate 1`] = `
"commit be4abdd39321ad7d3fe01ffce404f4d6db0906bd
Author: Gregg Beahan III <Gregg.Beahan@hotmail.com>
Date: Tue Dec 31 14:49:14 2019 +0100
Author: Gregg Beahan III <Gregg.Beahan38@hotmail.com>
Date: Tue Dec 31 11:39:29 2019 +1200

    parse multi-byte sensor
    quantify online protocol
"
`;

Expand All @@ -53,7 +53,7 @@ exports[`git > 1211 > commitDate > with only string refDate 1`] = `"Tue Dec 31 0

exports[`git > 1211 > commitEntry > with only Date refDate 1`] = `
"commit adb42f0e3f4a973fab0aeefce96dfcf49cd438df
Author: Imani Anderson <Imani22@hotmail.com>
Author: Imani Anderson <Imani.Anderson@hotmail.com>
Date: Tue Dec 31 10:07:32 2019 -0400

    override wireless interface
Expand All @@ -62,7 +62,7 @@ Date: Tue Dec 31 10:07:32 2019 -0400

exports[`git > 1211 > commitEntry > with only number refDate 1`] = `
"commit adb42f0e3f4a973fab0aeefce96dfcf49cd438df
Author: Imani Anderson <Imani22@hotmail.com>
Author: Imani Anderson <Imani.Anderson@hotmail.com>
Date: Tue Dec 31 10:07:32 2019 -0400

    override wireless interface
Expand All @@ -71,7 +71,7 @@ Date: Tue Dec 31 10:07:32 2019 -0400

exports[`git > 1211 > commitEntry > with only string refDate 1`] = `
"commit adb42f0e3f4a973fab0aeefce96dfcf49cd438df
Author: Imani Anderson <Imani22@hotmail.com>
Author: Imani Anderson <Imani.Anderson@hotmail.com>
Date: Tue Dec 31 10:07:32 2019 -0400

    override wireless interface
Expand All @@ -96,7 +96,7 @@ exports[`git > 1337 > commitDate > with only string refDate 1`] = `"Tue Dec 31 1

exports[`git > 1337 > commitEntry > with only Date refDate 1`] = `
"commit c346ba075bd57f5a62b82d72af39cbbb07a98cba
Author: Miss Friedrich Krajcik <Friedrich41@gmail.com>
Author: Miss Friedrich Krajcik <Friedrich.Krajcik@gmail.com>
Date: Tue Dec 31 04:18:56 2019 -0700

    reboot haptic capacitor
Expand All @@ -105,7 +105,7 @@ Date: Tue Dec 31 04:18:56 2019 -0700

exports[`git > 1337 > commitEntry > with only number refDate 1`] = `
"commit c346ba075bd57f5a62b82d72af39cbbb07a98cba
Author: Miss Friedrich Krajcik <Friedrich41@gmail.com>
Author: Miss Friedrich Krajcik <Friedrich.Krajcik@gmail.com>
Date: Tue Dec 31 04:18:56 2019 -0700

    reboot haptic capacitor
Expand All @@ -114,7 +114,7 @@ Date: Tue Dec 31 04:18:56 2019 -0700

exports[`git > 1337 > commitEntry > with only string refDate 1`] = `
"commit c346ba075bd57f5a62b82d72af39cbbb07a98cba
Author: Miss Friedrich Krajcik <Friedrich41@gmail.com>
Author: Miss Friedrich Krajcik <Friedrich.Krajcik@gmail.com>
Date: Tue Dec 31 04:18:56 2019 -0700

    reboot haptic capacitor
Expand Down
62 changes: 31 additions & 31 deletions test/modules/__snapshots__/internet.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ exports[`internet > 42 > domainSuffix 1`] = `"info"`;

exports[`internet > 42 > domainWord 1`] = `"hasty-sherbet"`;

exports[`internet > 42 > email > noArgs 1`] = `"Garnet_Wiegand59@gmail.com"`;
exports[`internet > 42 > email > noArgs 1`] = `"Garnet_Deckow-Reynolds59@hotmail.com"`;

exports[`internet > 42 > email > with all options 1`] = `"Jane_Doe@fakerjs.dev"`;

exports[`internet > 42 > email > with allowSpecialCharacters option 1`] = `"Garnet$Wiegand59@gmail.com"`;
exports[`internet > 42 > email > with allowSpecialCharacters option 1`] = `"Garnet_Deckow-Reynolds59@hotmail.com"`;

exports[`internet > 42 > email > with firstName option 1`] = `"Jane73@hotmail.com"`;
exports[`internet > 42 > email > with firstName option 1`] = `"Jane73@yahoo.com"`;

exports[`internet > 42 > email > with lastName option 1`] = `"Garnet.Doe73@hotmail.com"`;

Expand All @@ -60,13 +60,13 @@ exports[`internet > 42 > emoji > noArgs 1`] = `"🕸️"`;

exports[`internet > 42 > emoji > with options 1`] = `"🦔"`;

exports[`internet > 42 > exampleEmail > noArgs 1`] = `"Garnet_Wiegand59@example.org"`;
exports[`internet > 42 > exampleEmail > noArgs 1`] = `"Garnet_Deckow-Reynolds59@example.net"`;

exports[`internet > 42 > exampleEmail > with all options 1`] = `"Jane_Doe18@example.com"`;

exports[`internet > 42 > exampleEmail > with allowSpecialCharacters option 1`] = `"Garnet$Wiegand59@example.org"`;
exports[`internet > 42 > exampleEmail > with allowSpecialCharacters option 1`] = `"Garnet_Deckow-Reynolds59@example.net"`;

exports[`internet > 42 > exampleEmail > with firstName option 1`] = `"Jane73@example.net"`;
exports[`internet > 42 > exampleEmail > with firstName option 1`] = `"Jane73@example.com"`;

exports[`internet > 42 > exampleEmail > with lastName option 1`] = `"Garnet.Doe73@example.net"`;

Expand Down Expand Up @@ -180,13 +180,13 @@ exports[`internet > 1211 > domainSuffix 1`] = `"org"`;

exports[`internet > 1211 > domainWord 1`] = `"vicious-infrastructure"`;

exports[`internet > 1211 > email > noArgs 1`] = `"Tito12@hotmail.com"`;
exports[`internet > 1211 > email > noArgs 1`] = `"Tito12@yahoo.com"`;

exports[`internet > 1211 > email > with all options 1`] = `"Jane.Doe89@fakerjs.dev"`;

exports[`internet > 1211 > email > with allowSpecialCharacters option 1`] = `"Tito12@hotmail.com"`;
exports[`internet > 1211 > email > with allowSpecialCharacters option 1`] = `"Tito12@yahoo.com"`;

exports[`internet > 1211 > email > with firstName option 1`] = `"Jane.Koelpin12@hotmail.com"`;
exports[`internet > 1211 > email > with firstName option 1`] = `"Jane.Trantow12@hotmail.com"`;

exports[`internet > 1211 > email > with lastName option 1`] = `"Tito_Doe22@yahoo.com"`;

Expand All @@ -202,13 +202,13 @@ exports[`internet > 1211 > emoji > noArgs 1`] = `"🇮🇸"`;

exports[`internet > 1211 > emoji > with options 1`] = `"🌲"`;

exports[`internet > 1211 > exampleEmail > noArgs 1`] = `"Tito12@example.net"`;
exports[`internet > 1211 > exampleEmail > noArgs 1`] = `"Tito12@example.com"`;

exports[`internet > 1211 > exampleEmail > with all options 1`] = `"Jane_Doe@example.net"`;

exports[`internet > 1211 > exampleEmail > with allowSpecialCharacters option 1`] = `"Tito12@example.net"`;
exports[`internet > 1211 > exampleEmail > with allowSpecialCharacters option 1`] = `"Tito12@example.com"`;

exports[`internet > 1211 > exampleEmail > with firstName option 1`] = `"Jane.Koelpin12@example.net"`;
exports[`internet > 1211 > exampleEmail > with firstName option 1`] = `"Jane.Trantow12@example.net"`;

exports[`internet > 1211 > exampleEmail > with lastName option 1`] = `"Tito_Doe22@example.com"`;

Expand Down Expand Up @@ -322,19 +322,19 @@ exports[`internet > 1337 > domainSuffix 1`] = `"biz"`;

exports[`internet > 1337 > domainWord 1`] = `"fair-mile"`;

exports[`internet > 1337 > email > noArgs 1`] = `"Devyn54@gmail.com"`;
exports[`internet > 1337 > email > noArgs 1`] = `"Devyn54@yahoo.com"`;

exports[`internet > 1337 > email > with all options 1`] = `"Jane56@fakerjs.dev"`;
exports[`internet > 1337 > email > with all options 1`] = `"Jane_Doe@fakerjs.dev"`;

exports[`internet > 1337 > email > with allowSpecialCharacters option 1`] = `"Devyn54@gmail.com"`;
exports[`internet > 1337 > email > with allowSpecialCharacters option 1`] = `"Devyn54@yahoo.com"`;

exports[`internet > 1337 > email > with firstName option 1`] = `"Jane27@gmail.com"`;

exports[`internet > 1337 > email > with lastName option 1`] = `"Devyn21@yahoo.com"`;
exports[`internet > 1337 > email > with lastName option 1`] = `"Devyn.Doe@yahoo.com"`;

exports[`internet > 1337 > email > with legacy names 1`] = `"Jane.Doe@gmail.com"`;
exports[`internet > 1337 > email > with legacy names 1`] = `"Jane.Doe21@gmail.com"`;

exports[`internet > 1337 > email > with legacy names and provider 1`] = `"Jane56@fakerjs.dev"`;
exports[`internet > 1337 > email > with legacy names and provider 1`] = `"Jane_Doe@fakerjs.dev"`;

exports[`internet > 1337 > email > with legacy provider 1`] = `"Devyn27@fakerjs.dev"`;

Expand All @@ -344,19 +344,19 @@ exports[`internet > 1337 > emoji > noArgs 1`] = `"💇🏼‍♀️"`;

exports[`internet > 1337 > emoji > with options 1`] = `"🐪"`;

exports[`internet > 1337 > exampleEmail > noArgs 1`] = `"Devyn54@example.org"`;
exports[`internet > 1337 > exampleEmail > noArgs 1`] = `"Devyn54@example.com"`;

exports[`internet > 1337 > exampleEmail > with all options 1`] = `"Jane&Doe@example.org"`;
exports[`internet > 1337 > exampleEmail > with all options 1`] = `"Jane/Doe21@example.org"`;

exports[`internet > 1337 > exampleEmail > with allowSpecialCharacters option 1`] = `"Devyn54@example.org"`;
exports[`internet > 1337 > exampleEmail > with allowSpecialCharacters option 1`] = `"Devyn54@example.com"`;

exports[`internet > 1337 > exampleEmail > with firstName option 1`] = `"Jane27@example.org"`;

exports[`internet > 1337 > exampleEmail > with lastName option 1`] = `"Devyn21@example.com"`;
exports[`internet > 1337 > exampleEmail > with lastName option 1`] = `"Devyn.Doe@example.com"`;

exports[`internet > 1337 > exampleEmail > with legacy names 1`] = `"Jane.Doe@example.org"`;
exports[`internet > 1337 > exampleEmail > with legacy names 1`] = `"Jane.Doe21@example.org"`;

exports[`internet > 1337 > exampleEmail > with legacy names and options 1`] = `"Jane&Doe@example.org"`;
exports[`internet > 1337 > exampleEmail > with legacy names and options 1`] = `"Jane/Doe21@example.org"`;

exports[`internet > 1337 > httpMethod 1`] = `"POST"`;

Expand Down Expand Up @@ -410,18 +410,18 @@ exports[`internet > 1337 > userAgent 1`] = `"Mozilla/5.0 (Macintosh; U; Intel Ma

exports[`internet > 1337 > userName > noArgs 1`] = `"Devyn27"`;

exports[`internet > 1337 > userName > with Chinese names 1`] = `"hlzp8d56"`;
exports[`internet > 1337 > userName > with Chinese names 1`] = `"hlzp8d_tpv"`;

exports[`internet > 1337 > userName > with Cyrillic names 1`] = `"Fedor56"`;
exports[`internet > 1337 > userName > with Cyrillic names 1`] = `"Fedor_Dostoevskii"`;

exports[`internet > 1337 > userName > with Latin names 1`] = `"Jane56"`;
exports[`internet > 1337 > userName > with Latin names 1`] = `"Jane_Doe"`;

exports[`internet > 1337 > userName > with accented names 1`] = `"Helene56"`;
exports[`internet > 1337 > userName > with accented names 1`] = `"Helene_Muller"`;

exports[`internet > 1337 > userName > with all option 1`] = `"Jane56"`;
exports[`internet > 1337 > userName > with all option 1`] = `"Jane_Doe"`;

exports[`internet > 1337 > userName > with firstName option 1`] = `"Jane21"`;

exports[`internet > 1337 > userName > with lastName option 1`] = `"Devyn.Doe"`;
exports[`internet > 1337 > userName > with lastName option 1`] = `"Devyn.Doe21"`;

exports[`internet > 1337 > userName > with legacy names 1`] = `"Jane56"`;
exports[`internet > 1337 > userName > with legacy names 1`] = `"Jane_Doe"`;
1 change: 1 addition & 0 deletions test/modules/internet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ describe('internet', () => {
const [prefix, suffix] = email.split('@');

expect(prefix).includes('Aiden');
expect(prefix).includes('Harann');
amillwood marked this conversation as resolved.
Show resolved Hide resolved
expect(prefix).toMatch(
/^Aiden((\d{1,2})|([._]Harann\d{1,2})|([._](Harann)))/
amillwood marked this conversation as resolved.
Show resolved Hide resolved
);
Expand Down