From 95d92999bb55a1e62570496771de8919ec6e2fee Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Sun, 18 Sep 2022 06:59:44 +0100 Subject: [PATCH] test(git): add basic parsing test for cherry-pick Currently, cherry-pick in gitGraphs only has e2e tests, no parsing unit tests. --- src/diagrams/git/gitGraphParserV2.spec.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/diagrams/git/gitGraphParserV2.spec.js b/src/diagrams/git/gitGraphParserV2.spec.js index b6c9c2459..8db1d6074 100644 --- a/src/diagrams/git/gitGraphParserV2.spec.js +++ b/src/diagrams/git/gitGraphParserV2.spec.js @@ -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