aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHarsohail Brar <[email protected]>2022-04-08 10:34:05 -0600
committerGitHub <[email protected]>2022-04-08 16:34:05 +0000
commit3b5a21f3aae52f263f2c91e763fcee613092166c (patch)
tree071e5486094849dc1e996dcf70e4283a2804b7fc /test
parent4ac2a0424fffcf48dedea58148ac1b4b510a68a5 (diff)
downloadfaker-3b5a21f3aae52f263f2c91e763fcee613092166c.tar.xz
faker-3b5a21f3aae52f263f2c91e763fcee613092166c.zip
feat: special characters in emails (#792)
Diffstat (limited to 'test')
-rw-r--r--test/internet.spec.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/internet.spec.ts b/test/internet.spec.ts
index b7d9a7ea..fa9ad963 100644
--- a/test/internet.spec.ts
+++ b/test/internet.spec.ts
@@ -191,6 +191,21 @@ describe('internet', () => {
expect(prefix).match(/^思源_唐3/);
expect(faker.definitions.internet.free_email).toContain(suffix);
});
+
+ it('should return an email with special characters', () => {
+ const email = faker.internet.email('Mike', 'Smith', null, {
+ allowSpecialCharacters: true,
+ });
+
+ expect(email).toBeTruthy();
+ expect(email).toBeTypeOf('string');
+ expect(email).satisfy(validator.isEmail);
+
+ const [prefix, suffix] = email.split('@');
+
+ expect(prefix).match(/^Mike([.!#$%&'*+-/=?^_`{|}~]Smith)?\d*/);
+ expect(faker.definitions.internet.free_email).toContain(suffix);
+ });
});
describe('exampleEmail()', () => {
@@ -248,6 +263,22 @@ describe('internet', () => {
expect(faker.definitions.internet.example_email).toContain(suffix);
expect(prefix).match(/^思源_唐3/);
});
+
+ it('should return an email with special characters', () => {
+ const email = faker.internet.exampleEmail('Mike', 'Smith', {
+ allowSpecialCharacters: true,
+ });
+
+ expect(email).toBeTruthy();
+ expect(email).toBeTypeOf('string');
+ expect(email).satisfy(validator.isEmail);
+
+ const [prefix, suffix] = email.split('@');
+
+ expect(suffix).match(/^example\.(com|net|org)$/);
+ expect(faker.definitions.internet.example_email).toContain(suffix);
+ expect(prefix).match(/^Mike([.!#$%&'*+-/=?^_`{|}~]Smith)?\d*/);
+ });
});
describe('userName()', () => {