mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-21 08:19:43 +02:00
first couple of tests for the half baked parser
This commit is contained in:
38
src/diagrams/gitGraph/gitGraphParser.spec.js
Normal file
38
src/diagrams/gitGraph/gitGraphParser.spec.js
Normal file
@@ -0,0 +1,38 @@
|
||||
var proxyquire = require('proxyquire');
|
||||
var parser = require('./parser/gitGraph').parser;
|
||||
var ast = require("./gitGraphAst.js");
|
||||
describe('when parsing a gitGraph',function() {
|
||||
beforeEach(function () {
|
||||
parser.yy = ast;
|
||||
parser.yy.reset();
|
||||
});
|
||||
it('should handle a gitGraph defintion', function () {
|
||||
str = 'gitGraph:\n' +
|
||||
'commit';
|
||||
|
||||
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(Object.keys(parser.yy.getBranches()).length).toBe(1);
|
||||
});
|
||||
it('should handle branch statement', function () {
|
||||
str = 'gitGraph:\n' +
|
||||
'commit\n' +
|
||||
'commit\n' +
|
||||
'branch newbranch\n' +
|
||||
'commit\n' +
|
||||
'commit\n';
|
||||
|
||||
parser.parse(str);
|
||||
var commits = parser.yy.getCommits();
|
||||
console.log(commits);
|
||||
|
||||
expect(Object.keys(commits).length).toBe(4);
|
||||
expect(parser.yy.getCurrentBranch()).toBe("master");
|
||||
expect(Object.keys(parser.yy.getBranches())).toContain('newbranch');
|
||||
expect(Object.keys(parser.yy.getBranches()).length).toBe(2);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user