diff options
| author | Kris <[email protected]> | 2022-06-30 03:41:59 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-06-30 10:41:59 +0000 |
| commit | e5ebaefb1fc9c169762f7a1f185bfefb355f059b (patch) | |
| tree | 735f387749a96c27126f8aabe71b03b763f642d0 | |
| parent | 1cb931211f87298f3b802bdd6faf38ecde11dcc0 (diff) | |
| download | faker-e5ebaefb1fc9c169762f7a1f185bfefb355f059b.tar.xz faker-e5ebaefb1fc9c169762f7a1f185bfefb355f059b.zip | |
chore: testing unpredictable emails and usernames (#1115)
Co-authored-by: Leyla Jähnig <[email protected]>
Co-authored-by: ST-DDT <[email protected]>
| -rw-r--r-- | test/internet.spec.ts | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/test/internet.spec.ts b/test/internet.spec.ts index 04393b90..7d4d9aad 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'); @@ -87,7 +85,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})?)))/ + ); expect(faker.definitions.internet.free_email).toContain(suffix); }); @@ -100,7 +101,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); }); @@ -128,7 +132,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); }); }); @@ -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)))/ + ); }); }); |
