From ad8dc59290a1d71876c8dc49b1d3d17842813df2 Mon Sep 17 00:00:00 2001 From: kris71990 Date: Tue, 28 Jun 2022 14:14:01 -0700 Subject: [PATCH 1/4] chore: more rigorous matching for email and usernam tests #1044 --- test/internet.spec.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/internet.spec.ts b/test/internet.spec.ts index 04393b90146..b590d0aa34d 100644 --- a/test/internet.spec.ts +++ b/test/internet.spec.ts @@ -87,7 +87,10 @@ describe('internet', () => { const [prefix, suffix] = email.split('@'); - expect(prefix).toMatch(/^Aiden.Harann55/); + expect(prefix).includes('Aiden.Harann55'); + expect(prefix).toMatch( + /^(Aiden\.Harann55((\d{2})|([._][A-Za-z]*\d{2})|([._][A-Za-z]*)))/ + ); expect(faker.definitions.internet.free_email).toContain(suffix); }); @@ -100,7 +103,10 @@ describe('internet', () => { const [prefix, suffix] = email.split('@'); - expect(prefix).toMatch(/^Aiden([._]Harann)?\d*/); + expect(prefix).includes('Aiden'); + expect(prefix).toMatch( + /^Aiden((\d{2})|([._]Harann\d{2})|([._](Harann)))/ + ); expect(faker.definitions.internet.free_email).toContain(suffix); }); @@ -229,9 +235,10 @@ describe('internet', () => { expect(username).toBeTruthy(); expect(username).toBeTypeOf('string'); - expect(username).toMatch(/\w/); expect(username).includes('Aiden'); - // FIXME @Shinigami92 2022-02-11: The lastName is sometimes not taken + expect(username).toMatch( + /^Aiden((\d{2})|([._]Harann\d{2})|([._](Harann)))/ + ); }); }); From 9fe089077debd31af10c9fbe746ee85983bdcc67 Mon Sep 17 00:00:00 2001 From: kris71990 Date: Tue, 28 Jun 2022 15:06:19 -0700 Subject: [PATCH 2/4] chore: apply rigorous regex to test special characters --- test/internet.spec.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/internet.spec.ts b/test/internet.spec.ts index b590d0aa34d..8c9885487a0 100644 --- a/test/internet.spec.ts +++ b/test/internet.spec.ts @@ -134,7 +134,9 @@ describe('internet', () => { const [prefix, suffix] = email.split('@'); - expect(prefix).toMatch(/^Mike([.!#$%&'*+-/=?^_`{|}~]Smith)?\d*/); + expect(prefix).toMatch( + /^Mike((\d{2})|([.!#$%&'*+-/=?^_`{|}~]Smith\d{2})|([.!#$%&'*+-/=?^_`{|}~]Smith))/ + ); expect(faker.definitions.internet.free_email).toContain(suffix); }); }); From 8d083b90c7af18bdbc501aa619f73209a34cc688 Mon Sep 17 00:00:00 2001 From: kris71990 Date: Tue, 28 Jun 2022 15:51:43 -0700 Subject: [PATCH 3/4] chore: remove todo comment --- test/internet.spec.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/internet.spec.ts b/test/internet.spec.ts index 8c9885487a0..6b204fd6e8a 100644 --- a/test/internet.spec.ts +++ b/test/internet.spec.ts @@ -76,8 +76,6 @@ describe('internet', () => { expect(faker.definitions.internet.free_email).toContain(suffix); }); - // TODO @Shinigami92 2022-02-11: When providing params to `email`, it produces some not that predictable data - it('should return an email with given firstName', () => { const email = faker.internet.email('Aiden.Harann55'); From e4186374da5f32ff9793949bea6fcbf37c874369 Mon Sep 17 00:00:00 2001 From: Kris Date: Wed, 29 Jun 2022 13:57:36 -0700 Subject: [PATCH 4/4] Update test/internet.spec.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Leyla Jähnig --- test/internet.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/internet.spec.ts b/test/internet.spec.ts index 6b204fd6e8a..7d4d9aad6fc 100644 --- a/test/internet.spec.ts +++ b/test/internet.spec.ts @@ -87,7 +87,7 @@ describe('internet', () => { expect(prefix).includes('Aiden.Harann55'); expect(prefix).toMatch( - /^(Aiden\.Harann55((\d{2})|([._][A-Za-z]*\d{2})|([._][A-Za-z]*)))/ + /^(Aiden\.Harann55((\d{2})|([._][A-Za-z]*(\d{2})?)))/ ); expect(faker.definitions.internet.free_email).toContain(suffix); });