diff options
| author | ST-DDT <[email protected]> | 2022-11-08 20:49:08 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-11-08 20:49:08 +0100 |
| commit | 99b6fb2c8d6d3e8ead53d7cc8d58bf615408860d (patch) | |
| tree | 8f9179ce7f8620b36425cb5bc5040f6ccd54f574 /test | |
| parent | 7be37240bf0995902dfab5ba3e76c7246a04fd3e (diff) | |
| download | faker-99b6fb2c8d6d3e8ead53d7cc8d58bf615408860d.tar.xz faker-99b6fb2c8d6d3e8ead53d7cc8d58bf615408860d.zip | |
fix(git): adjust commitEntry to match `git log` output (#1539)
Diffstat (limited to 'test')
| -rw-r--r-- | test/__snapshots__/git.spec.ts.snap | 72 | ||||
| -rw-r--r-- | test/git.spec.ts | 21 |
2 files changed, 63 insertions, 30 deletions
diff --git a/test/__snapshots__/git.spec.ts.snap b/test/__snapshots__/git.spec.ts.snap index e61c0578..51a0c632 100644 --- a/test/__snapshots__/git.spec.ts.snap +++ b/test/__snapshots__/git.spec.ts.snap @@ -2,30 +2,36 @@ exports[`git > 42 > branch 1`] = `"array-transmit"`; +exports[`git > 42 > commitDate > with only Date refDate 1`] = `"Tue Dec 31 15:00:39 2019 +0800"`; + +exports[`git > 42 > commitDate > with only number refDate 1`] = `"Tue Dec 31 15:00:39 2019 +0800"`; + +exports[`git > 42 > commitDate > with only string refDate 1`] = `"Tue Dec 31 15:00:39 2019 +0800"`; + exports[`git > 42 > commitEntry > with only Date refDate 1`] = ` "commit be4abdd39321ad7d3fe01ffce404f4d6db0906bd -Author: Gregg Conn <[email protected]> -Date: Tue Dec 31 2019 13:03:15 GMT+0000 (Coordinated Universal Time) +Author: Gregg Conn <[email protected]> +Date: Tue Dec 31 14:49:14 2019 +0100 - bypass neural pixel + parse multi-byte sensor " `; exports[`git > 42 > commitEntry > with only number refDate 1`] = ` "commit be4abdd39321ad7d3fe01ffce404f4d6db0906bd -Author: Gregg Conn <[email protected]> -Date: Tue Dec 31 2019 13:03:15 GMT+0000 (Coordinated Universal Time) +Author: Gregg Conn <[email protected]> +Date: Tue Dec 31 14:49:14 2019 +0100 - bypass neural pixel + parse multi-byte sensor " `; exports[`git > 42 > commitEntry > with only string refDate 1`] = ` "commit be4abdd39321ad7d3fe01ffce404f4d6db0906bd -Author: Gregg Conn <[email protected]> -Date: Tue Dec 31 2019 13:03:15 GMT+0000 (Coordinated Universal Time) +Author: Gregg Conn <[email protected]> +Date: Tue Dec 31 14:49:14 2019 +0100 - bypass neural pixel + parse multi-byte sensor " `; @@ -37,30 +43,36 @@ exports[`git > 42 > shortSha 1`] = `"8be4abd"`; exports[`git > 1211 > branch 1`] = `"capacitor-connect"`; +exports[`git > 1211 > commitDate > with only Date refDate 1`] = `"Tue Dec 31 01:42:55 2019 +0000"`; + +exports[`git > 1211 > commitDate > with only number refDate 1`] = `"Tue Dec 31 01:42:55 2019 +0000"`; + +exports[`git > 1211 > commitDate > with only string refDate 1`] = `"Tue Dec 31 01:42:55 2019 +0000"`; + exports[`git > 1211 > commitEntry > with only Date refDate 1`] = ` "commit adb42f0e3f4a973fab0aeefce96dfcf49cd438df -Author: Imani Runolfsson <[email protected]> -Date: Tue Dec 31 2019 13:53:17 GMT+0000 (Coordinated Universal Time) +Author: Imani Runolfsson <[email protected]> +Date: Tue Dec 31 10:07:32 2019 -0400 - parse back-end program + override wireless interface " `; exports[`git > 1211 > commitEntry > with only number refDate 1`] = ` "commit adb42f0e3f4a973fab0aeefce96dfcf49cd438df -Author: Imani Runolfsson <[email protected]> -Date: Tue Dec 31 2019 13:53:17 GMT+0000 (Coordinated Universal Time) +Author: Imani Runolfsson <[email protected]> +Date: Tue Dec 31 10:07:32 2019 -0400 - parse back-end program + override wireless interface " `; exports[`git > 1211 > commitEntry > with only string refDate 1`] = ` "commit adb42f0e3f4a973fab0aeefce96dfcf49cd438df -Author: Imani Runolfsson <[email protected]> -Date: Tue Dec 31 2019 13:53:17 GMT+0000 (Coordinated Universal Time) +Author: Imani Runolfsson <[email protected]> +Date: Tue Dec 31 10:07:32 2019 -0400 - parse back-end program + override wireless interface " `; @@ -72,30 +84,36 @@ exports[`git > 1211 > shortSha 1`] = `"eadb42f"`; exports[`git > 1337 > branch 1`] = `"port-quantify"`; +exports[`git > 1337 > commitDate > with only Date refDate 1`] = `"Tue Dec 31 17:42:40 2019 +0200"`; + +exports[`git > 1337 > commitDate > with only number refDate 1`] = `"Tue Dec 31 17:42:40 2019 +0200"`; + +exports[`git > 1337 > commitDate > with only string refDate 1`] = `"Tue Dec 31 17:42:40 2019 +0200"`; + exports[`git > 1337 > commitEntry > with only Date refDate 1`] = ` "commit c346ba075bd57f5a62b82d72af39cbbb07a98cba -Author: Friedrich Dibbert <[email protected]> -Date: Tue Dec 31 2019 13:25:40 GMT+0000 (Coordinated Universal Time) +Author: Friedrich Dibbert <[email protected]> +Date: Tue Dec 31 04:18:56 2019 -0700 - override back-end interface + reboot haptic capacitor " `; exports[`git > 1337 > commitEntry > with only number refDate 1`] = ` "commit c346ba075bd57f5a62b82d72af39cbbb07a98cba -Author: Friedrich Dibbert <[email protected]> -Date: Tue Dec 31 2019 13:25:40 GMT+0000 (Coordinated Universal Time) +Author: Friedrich Dibbert <[email protected]> +Date: Tue Dec 31 04:18:56 2019 -0700 - override back-end interface + reboot haptic capacitor " `; exports[`git > 1337 > commitEntry > with only string refDate 1`] = ` "commit c346ba075bd57f5a62b82d72af39cbbb07a98cba -Author: Friedrich Dibbert <[email protected]> -Date: Tue Dec 31 2019 13:25:40 GMT+0000 (Coordinated Universal Time) +Author: Friedrich Dibbert <[email protected]> +Date: Tue Dec 31 04:18:56 2019 -0700 - override back-end interface + reboot haptic capacitor " `; diff --git a/test/git.spec.ts b/test/git.spec.ts index 18cb153a..9ab73ae6 100644 --- a/test/git.spec.ts +++ b/test/git.spec.ts @@ -15,7 +15,10 @@ describe('git', () => { seededTests(faker, 'git', (t) => { t.itEach('branch', 'commitMessage', 'commitSha', 'shortSha'); - t.describe('commitEntry', (t) => { + t.describeEach( + 'commitEntry', + 'commitDate' + )((t) => { t.it('with only string refDate', { refDate }) .it('with only Date refDate', { refDate: new Date(refDate) }) .it('with only number refDate', { @@ -51,12 +54,12 @@ describe('git', () => { expect(parts[0]).toMatch(/^commit [a-f0-9]+$/); if (parts.length === 7) { expect(parts[1]).toMatch(/^Merge: [a-f0-9]+ [a-f0-9]+$/); - expect(parts[2]).toMatch(/^Author: \w+ \w+ \<[\w\.]+@[\w\.]+\>$/); + expect(parts[2]).toMatch(/^Author: [\w_\. ]+ \<[\w\.]+@[\w\.]+\>$/); expect(parts[3]).toMatch(/^Date: .+$/); expect(parts[4]).toBe(''); expect(parts[5]).toMatch(/^\s{4}.+$/); } else { - expect(parts[1]).toMatch(/^Author: \w+ \w+ \<[\w\.]+@[\w\.]+\>$/); + expect(parts[1]).toMatch(/^Author: [\w_\. ]+ \<[\w\.]+@[\w\.]+\>$/); expect(parts[2]).toMatch(/^Date: .+$/); expect(parts[3]).toBe(''); expect(parts[4]).toMatch(/^\s{4}.+$/); @@ -106,6 +109,18 @@ describe('git', () => { }); }); + describe('commitDate', () => { + it('should return a random commitDate', () => { + const commitDate = faker.git.commitDate(); + + expect(commitDate).toBeTruthy(); + expect(commitDate).toBeTypeOf('string'); + + const parts = commitDate.split(' '); + expect(parts.length).toBe(6); + }); + }); + describe('commitSha', () => { it('should return a random commitSha', () => { const commitSha = faker.git.commitSha(); |
