aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Mayer <[email protected]>2023-03-17 01:04:45 +0700
committerGitHub <[email protected]>2023-03-16 18:04:45 +0000
commit65e6b7f64e870906746f041bd0dc8ffd2f7f0ff7 (patch)
tree42fc29c7242986d5f65c23f65a4c1edff715d706
parent256631d6be4b2b40ae660a7e9052cde07a3da18c (diff)
downloadfaker-65e6b7f64e870906746f041bd0dc8ffd2f7f0ff7.tar.xz
faker-65e6b7f64e870906746f041bd0dc8ffd2f7f0ff7.zip
test(git): relax email validation in commitEntry results (#1876)
-rw-r--r--test/git.spec.ts17
1 files changed, 15 insertions, 2 deletions
diff --git a/test/git.spec.ts b/test/git.spec.ts
index 805b6bb6..c5042ad2 100644
--- a/test/git.spec.ts
+++ b/test/git.spec.ts
@@ -56,14 +56,27 @@ describe('git', () => {
expect(parts.length).toBeLessThanOrEqual(7);
expect(parts[0]).toMatch(/^commit [a-f0-9]+$/);
+ const isValidAuthor = (email: string) => {
+ // `validator.isEmail()` does not support display names
+ // that contain unquoted characters like . output by Git so we need
+ // to quote the display name
+ const quotedEmail = email.replace(/^(.*) </, '"$1" <');
+ return validator.isEmail(quotedEmail, {
+ require_display_name: true,
+ });
+ };
+
+ const authorRegex = /^Author: .*$/;
if (parts.length === 7) {
expect(parts[1]).toMatch(/^Merge: [a-f0-9]+ [a-f0-9]+$/);
- expect(parts[2]).toMatch(/^Author: [^\<\>]+ \<[\w\.]+@[\w\.]+\>$/);
+ expect(parts[2]).toMatch(authorRegex);
+ expect(parts[2].substring(8)).toSatisfy(isValidAuthor);
expect(parts[3]).toMatch(/^Date: .+$/);
expect(parts[4]).toBe('');
expect(parts[5]).toMatch(/^\s{4}.+$/);
} else {
- expect(parts[1]).toMatch(/^Author: [^\<\>]+ \<[\w\.]+@[\w\.]+\>$/);
+ expect(parts[1]).toMatch(authorRegex);
+ expect(parts[1].substring(8)).toSatisfy(isValidAuthor);
expect(parts[2]).toMatch(/^Date: .+$/);
expect(parts[3]).toBe('');
expect(parts[4]).toMatch(/^\s{4}.+$/);