diff --git a/src/diagrams/gitGraph/gitGraphParser.spec.js b/src/diagrams/gitGraph/gitGraphParser.spec.js index d9c516be1..4f20d3b0c 100644 --- a/src/diagrams/gitGraph/gitGraphParser.spec.js +++ b/src/diagrams/gitGraph/gitGraphParser.spec.js @@ -33,6 +33,7 @@ describe('when parsing a gitGraph',function() { expect(parser.yy.getDirection()).toBe("TB"); expect(Object.keys(parser.yy.getBranches()).length).toBe(1); }); + it('should checkout a branch', function () { var str = 'gitGraph:\n' + 'branch new\n' + @@ -45,6 +46,22 @@ describe('when parsing a gitGraph',function() { expect(parser.yy.getCurrentBranch()).toBe("new"); }); + it('should add commits to checked out branch', function () { + var str = 'gitGraph:\n' + + 'branch new\n' + + 'checkout new\n' + + 'commit\n'+ + 'commit\n' + + parser.parse(str); + var commits = parser.yy.getCommits(); + + expect(Object.keys(commits).length).toBe(2); + expect(parser.yy.getCurrentBranch()).toBe("new"); + var branchCommit = parser.yy.getBranches()['new']; + expect(branchCommit).not.toBeNull(); + expect(commits[branchCommit].parent).not.toBeNull(); + }); it('should handle commit with args', function () { var str = 'gitGraph:\n' + 'commit "a commit"\n';