diff options
| author | Matt Mayer <[email protected]> | 2023-01-21 02:24:06 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-01-20 20:24:06 +0100 |
| commit | 1e4e8699e59f3b5b9c1e1d6ad9b89ee4cc254e95 (patch) | |
| tree | e1f3fd268f970824639b0e94224e0dfc46c38c86 /test | |
| parent | dfa647dc07ea25f962c4df913bae2de082e8acc4 (diff) | |
| download | faker-1e4e8699e59f3b5b9c1e1d6ad9b89ee4cc254e95.tar.xz faker-1e4e8699e59f3b5b9c1e1d6ad9b89ee4cc254e95.zip | |
fix(internet): fix invalid emails in some locales (#1746)
Diffstat (limited to 'test')
| -rw-r--r-- | test/internet.spec.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/internet.spec.ts b/test/internet.spec.ts index 11cbb60e..16b6a804 100644 --- a/test/internet.spec.ts +++ b/test/internet.spec.ts @@ -156,6 +156,25 @@ describe('internet', () => { expect(faker.definitions.internet.free_email).toContain(suffix); }); + it('should return a valid email for very long names', () => { + const longFirstName = + 'Elizabeth Alexandra Mary Jane Annabel Victoria'; + const longSurname = 'Smith Jones Davidson Brown White Greene Black'; + const email = faker.internet.email(longFirstName, longSurname); + // should truncate to 50 chars + // e.g. [email protected] + expect(email).toSatisfy(validator.isEmail); + const localPart = email.split('@')[0]; + expect(localPart.length).toBeLessThanOrEqual(50); + }); + + it('should return a valid email for names with invalid chars', () => { + const email = faker.internet.email('Matthew (Matt)', 'Smith'); + // should strip invalid chars + // e.g. [email protected] + expect(email).toSatisfy(validator.isEmail); + }); + it('should return an email with special characters', () => { const email = faker.internet.email('Mike', 'Smith', null, { allowSpecialCharacters: true, |
