test(git): add basic parsing test for cherry-pick

Currently, cherry-pick in gitGraphs only has e2e tests,
no parsing unit tests.
This commit is contained in:
Alois Klink
2022-09-18 06:59:44 +01:00
parent e8eb2ab03f
commit c39a6f27d4

View File

@@ -611,6 +611,22 @@ describe('when parsing a gitGraph', function () {
]);
});
it('should support cherry-picking commits', function () {
const str = `gitGraph
commit id: "ZERO"
branch develop
commit id:"A"
checkout main
cherry-pick id:"A"
`;
parser.parse(str);
const commits = parser.yy.getCommits();
const cherryPickCommitID = Object.keys(commits)[2];
expect(commits[cherryPickCommitID].tag).toBe('cherry-pick:A');
expect(commits[cherryPickCommitID].branch).toBe('main');
});
it('should throw error when try to branch existing branch: main', function () {
const str = `gitGraph
commit