mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-21 08:19:43 +02:00
support orientation, commit msg, branch checkout
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
var proxyquire = require('proxyquire');
|
||||
var parser = require('./parser/gitGraph').parser;
|
||||
var ast = require("./gitGraphAst.js");
|
||||
describe('when parsing a gitGraph',function() {
|
||||
"use strict";
|
||||
beforeEach(function () {
|
||||
parser.yy = ast;
|
||||
parser.yy.reset();
|
||||
});
|
||||
it('should handle a gitGraph defintion', function () {
|
||||
str = 'gitGraph:\n' +
|
||||
'commit';
|
||||
var str = 'gitGraph:\n' +
|
||||
'commit\n';
|
||||
|
||||
parser.parse(str);
|
||||
var commits = parser.yy.getCommits();
|
||||
@@ -16,17 +16,58 @@ describe('when parsing a gitGraph',function() {
|
||||
|
||||
expect(Object.keys(commits).length).toBe(1);
|
||||
expect(parser.yy.getCurrentBranch()).toBe("master");
|
||||
expect(parser.yy.getDirection()).toBe("LR");
|
||||
expect(Object.keys(parser.yy.getBranches()).length).toBe(1);
|
||||
});
|
||||
|
||||
it('should handle set direction', function () {
|
||||
var str = 'gitGraph TB:\n' +
|
||||
'commit\n';
|
||||
|
||||
parser.parse(str);
|
||||
var commits = parser.yy.getCommits();
|
||||
console.log(commits);
|
||||
|
||||
expect(Object.keys(commits).length).toBe(1);
|
||||
expect(parser.yy.getCurrentBranch()).toBe("master");
|
||||
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' +
|
||||
'checkout new\n'
|
||||
|
||||
parser.parse(str);
|
||||
var commits = parser.yy.getCommits();
|
||||
|
||||
expect(Object.keys(commits).length).toBe(0);
|
||||
expect(parser.yy.getCurrentBranch()).toBe("new");
|
||||
});
|
||||
|
||||
it('should handle commit with args', function () {
|
||||
var str = 'gitGraph:\n' +
|
||||
'commit "a commit"\n';
|
||||
|
||||
parser.parse(str);
|
||||
var commits = parser.yy.getCommits();
|
||||
console.log(commits);
|
||||
|
||||
expect(Object.keys(commits).length).toBe(1);
|
||||
var key = Object.keys(commits)[0];
|
||||
expect(commits[key].message).toBe("a commit");
|
||||
expect(parser.yy.getCurrentBranch()).toBe("master");
|
||||
});
|
||||
|
||||
it('should handle branch statement', function () {
|
||||
str = 'gitGraph:\n' +
|
||||
var str = 'gitGraph:\n' +
|
||||
'commit\n' +
|
||||
'commit\n' +
|
||||
'branch newbranch\n' +
|
||||
'commit\n' +
|
||||
'commit\n';
|
||||
|
||||
parser.parse(str);
|
||||
console.log(parser.parse(str));
|
||||
var commits = parser.yy.getCommits();
|
||||
console.log(commits);
|
||||
|
||||
@@ -35,4 +76,5 @@ describe('when parsing a gitGraph',function() {
|
||||
expect(Object.keys(parser.yy.getBranches())).toContain('newbranch');
|
||||
expect(Object.keys(parser.yy.getBranches()).length).toBe(2);
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user