diff options
| author | ST-DDT <[email protected]> | 2024-11-14 22:50:04 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-11-14 21:50:04 +0000 |
| commit | 188309a59cfe6fbd33e120dedf3bdfef3276d641 (patch) | |
| tree | 079d062e07065b11ae0bcf8c8cb964174a842080 /test/modules/git.spec.ts | |
| parent | a54c1edb87e88b198966d248d5273c9898c32798 (diff) | |
| download | faker-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.ts | 23 |
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}.+$/); |
