mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 14:59:53 +02:00
add another test for checkout
This commit is contained in:
@@ -33,6 +33,7 @@ describe('when parsing a gitGraph',function() {
|
|||||||
expect(parser.yy.getDirection()).toBe("TB");
|
expect(parser.yy.getDirection()).toBe("TB");
|
||||||
expect(Object.keys(parser.yy.getBranches()).length).toBe(1);
|
expect(Object.keys(parser.yy.getBranches()).length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should checkout a branch', function () {
|
it('should checkout a branch', function () {
|
||||||
var str = 'gitGraph:\n' +
|
var str = 'gitGraph:\n' +
|
||||||
'branch new\n' +
|
'branch new\n' +
|
||||||
@@ -45,6 +46,22 @@ describe('when parsing a gitGraph',function() {
|
|||||||
expect(parser.yy.getCurrentBranch()).toBe("new");
|
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 () {
|
it('should handle commit with args', function () {
|
||||||
var str = 'gitGraph:\n' +
|
var str = 'gitGraph:\n' +
|
||||||
'commit "a commit"\n';
|
'commit "a commit"\n';
|
||||||
|
Reference in New Issue
Block a user