aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/__snapshots__/git.spec.ts.snap18
-rw-r--r--test/git.spec.ts36
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);
+ }
+ );
});
}
});