aboutsummaryrefslogtreecommitdiff
path: root/test/modules/git.spec.ts
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2024-11-14 22:50:04 +0100
committerGitHub <[email protected]>2024-11-14 21:50:04 +0000
commit188309a59cfe6fbd33e120dedf3bdfef3276d641 (patch)
tree079d062e07065b11ae0bcf8c8cb964174a842080 /test/modules/git.spec.ts
parenta54c1edb87e88b198966d248d5273c9898c32798 (diff)
downloadfaker-188309a59cfe6fbd33e120dedf3bdfef3276d641.tar.xz
faker-188309a59cfe6fbd33e120dedf3bdfef3276d641.zip
infra(unicorn): consistent-function-scoping (#3255)
Diffstat (limited to 'test/modules/git.spec.ts')
-rw-r--r--test/modules/git.spec.ts23
1 files changed, 12 insertions, 11 deletions
diff --git a/test/modules/git.spec.ts b/test/modules/git.spec.ts
index e4692b20..164b19c6 100644
--- a/test/modules/git.spec.ts
+++ b/test/modules/git.spec.ts
@@ -8,6 +8,16 @@ const NON_SEEDED_BASED_RUN = 5;
const refDate = '2020-01-01T00:00:00.000Z';
+function isValidCommitAuthor(email: string): boolean {
+ // `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,
+ });
+}
+
describe('git', () => {
seededTests(faker, 'git', (t) => {
t.itEach('branch', 'commitMessage');
@@ -56,27 +66,18 @@ 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(authorRegex);
- expect(parts[2].substring(8)).toSatisfy(isValidAuthor);
+ expect(parts[2].substring(8)).toSatisfy(isValidCommitAuthor);
expect(parts[3]).toMatch(/^Date: .+$/);
expect(parts[4]).toBe('');
expect(parts[5]).toMatch(/^\s{4}.+$/);
} else {
expect(parts[1]).toMatch(authorRegex);
- expect(parts[1].substring(8)).toSatisfy(isValidAuthor);
+ expect(parts[1].substring(8)).toSatisfy(isValidCommitAuthor);
expect(parts[2]).toMatch(/^Date: .+$/);
expect(parts[3]).toBe('');
expect(parts[4]).toMatch(/^\s{4}.+$/);