diff options
| author | Shinigami <[email protected]> | 2023-02-23 00:59:29 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-02-22 23:59:29 +0000 |
| commit | aa3e771dbef3d17cd90d9b8941cb091136087ed1 (patch) | |
| tree | a9a501aa766fb80652df5db85476d510a40db3eb /test | |
| parent | 25bd847545acb13291ac0a3704688793ca9a0933 (diff) | |
| download | faker-aa3e771dbef3d17cd90d9b8941cb091136087ed1.tar.xz faker-aa3e771dbef3d17cd90d9b8941cb091136087ed1.zip | |
refactor(git): length for commit sha (#1863)
Diffstat (limited to 'test')
| -rw-r--r-- | test/__snapshots__/git.spec.ts.snap | 18 | ||||
| -rw-r--r-- | test/git.spec.ts | 36 |
2 files changed, 36 insertions, 18 deletions
diff --git a/test/__snapshots__/git.spec.ts.snap b/test/__snapshots__/git.spec.ts.snap index bdad5290..d1c74bd5 100644 --- a/test/__snapshots__/git.spec.ts.snap +++ b/test/__snapshots__/git.spec.ts.snap @@ -37,9 +37,11 @@ Date: Tue Dec 31 14:49:14 2019 +0100 exports[`git > 42 > commitMessage 1`] = `"navigate neural capacitor"`; -exports[`git > 42 > commitSha 1`] = `"8be4abdd39321ad7d3fe01ffce404f4d6db0906b"`; +exports[`git > 42 > commitSha > noArgs 1`] = `"8be4abdd39321ad7d3fe01ffce404f4d6db0906b"`; -exports[`git > 42 > shortSha 1`] = `"8be4abd"`; +exports[`git > 42 > commitSha > with length 7 1`] = `"8be4abd"`; + +exports[`git > 42 > commitSha > with length 8 1`] = `"8be4abdd"`; exports[`git > 1211 > branch 1`] = `"capacitor-connect"`; @@ -78,9 +80,11 @@ Date: Tue Dec 31 20:11:06 2019 -0600 exports[`git > 1211 > commitMessage 1`] = `"reboot online circuit"`; -exports[`git > 1211 > commitSha 1`] = `"eadb42f0e3f4a973fab0aeefce96dfcf49cd438d"`; +exports[`git > 1211 > commitSha > noArgs 1`] = `"eadb42f0e3f4a973fab0aeefce96dfcf49cd438d"`; + +exports[`git > 1211 > commitSha > with length 7 1`] = `"eadb42f"`; -exports[`git > 1211 > shortSha 1`] = `"eadb42f"`; +exports[`git > 1211 > commitSha > with length 8 1`] = `"eadb42f0"`; exports[`git > 1337 > branch 1`] = `"port-quantify"`; @@ -119,6 +123,8 @@ Date: Tue Dec 31 14:05:04 2019 +0800 exports[`git > 1337 > commitMessage 1`] = `"compress multi-byte panel"`; -exports[`git > 1337 > commitSha 1`] = `"5c346ba075bd57f5a62b82d72af39cbbb07a98cb"`; +exports[`git > 1337 > commitSha > noArgs 1`] = `"5c346ba075bd57f5a62b82d72af39cbbb07a98cb"`; + +exports[`git > 1337 > commitSha > with length 7 1`] = `"5c346ba"`; -exports[`git > 1337 > shortSha 1`] = `"5c346ba"`; +exports[`git > 1337 > commitSha > with length 8 1`] = `"5c346ba0"`; diff --git a/test/git.spec.ts b/test/git.spec.ts index a69b1baa..88c864ee 100644 --- a/test/git.spec.ts +++ b/test/git.spec.ts @@ -13,7 +13,15 @@ describe('git', () => { }); seededTests(faker, 'git', (t) => { - t.itEach('branch', 'commitMessage', 'commitSha', 'shortSha'); + t.itEach('branch', 'commitMessage'); + + t.describe('commitSha', (t) => { + t.it('noArgs') + .it('with length 7', { length: 7 }) + .it('with length 8', { length: 8 }); + }); + + t.skip('shortSha'); t.describeEach( 'commitEntry', @@ -122,7 +130,7 @@ describe('git', () => { }); describe('commitSha', () => { - it('should return a random commitSha', () => { + it('should return a random full commitSha', () => { const commitSha = faker.git.commitSha(); expect(commitSha).toBeTruthy(); @@ -130,17 +138,21 @@ describe('git', () => { expect(commitSha).toSatisfy(validator.isHexadecimal); expect(commitSha).toHaveLength(40); }); - }); - describe('shortSha', () => { - it('should return a random shortSha', () => { - const shortSha = faker.git.shortSha(); - - expect(shortSha).toBeTruthy(); - expect(shortSha).toBeTypeOf('string'); - expect(shortSha).toSatisfy(validator.isHexadecimal); - expect(shortSha).toHaveLength(7); - }); + it.each([ + ['GitHub', 7], + ['GitLab', 8], + ])( + 'should return a random short commitSha for %s', + (_provider, length) => { + const commitSha = faker.git.commitSha({ length }); + + expect(commitSha).toBeTruthy(); + expect(commitSha).toBeTypeOf('string'); + expect(commitSha).toSatisfy(validator.isHexadecimal); + expect(commitSha).toHaveLength(length); + } + ); }); } }); |
