forked from mermaid-js/mermaid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mermaid-js#1713, mermaid-js#1719, # 1720
- Loading branch information
1 parent
f67a374
commit 3f6296b
Showing
4 changed files
with
336 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<html> | ||
<head> | ||
<link | ||
href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" | ||
rel="stylesheet" | ||
/> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> | ||
<link href="https://fonts.googleapis.com/css?family=Noto+Sans+SC&display=swap" rel="stylesheet"> | ||
<style> | ||
body { | ||
background: rgb(221, 208, 208); | ||
/*background:#333;*/ | ||
font-family: 'Arial'; | ||
} | ||
h1 { color: white;} | ||
.mermaid2 { | ||
display: none; | ||
} | ||
.customCss > rect, .customCss{ | ||
fill:#FF0000 !important; | ||
stroke:#FFFF00 !important; | ||
stroke-width:4px !important; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>info below</h1> | ||
<div class="mermaid" style="width: 100%; height: 20%;"> | ||
gitGraph: | ||
commit "Ashish" | ||
branch newbranch | ||
checkout newbranch | ||
commit id:"1111" | ||
commit tag:"test" | ||
checkout master | ||
commit type: HIGHLIGHT | ||
commit | ||
merge newbranch | ||
commit | ||
branch b2 | ||
commit | ||
|
||
</div> | ||
<div class="mermaid2" style="width: 100%; height: 20%;"> | ||
gitGraph: | ||
commit | ||
commit | ||
branch newbranch | ||
checkout newbranch | ||
commit | ||
reset master | ||
</div> | ||
<script src="./mermaid.js"></script> | ||
<script> | ||
mermaid.parseError = function (err, hash) { | ||
// console.error('Mermaid error: ', err); | ||
}; | ||
mermaid.initialize({ | ||
theme: 'default', | ||
// arrowMarkerAbsolute: true, | ||
// themeCSS: '.edgePath .path {stroke: red;} .arrowheadPath {fill: red;}', | ||
logLevel: 0, | ||
flowchart: { curve: 'linear', "htmlLabels": true }, | ||
// gantt: { axisFormat: '%m/%d/%Y' }, | ||
sequence: { actorMargin: 50, showSequenceNumbers: true }, | ||
// sequenceDiagram: { actorMargin: 300 } // deprecated | ||
// fontFamily: '"arial", sans-serif', | ||
// themeVariables: { | ||
// fontFamily: '"arial", sans-serif', | ||
// }, | ||
curve: 'linear', | ||
securityLevel: 'loose' | ||
}); | ||
function callback(){alert('It worked');} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
/* eslint-env jasmine */ | ||
// Todo reintroduce without cryptoRandomString | ||
import gitGraphAst from './gitGraphAst'; | ||
import { parser } from './parser/gitGraph'; | ||
//import randomString from 'crypto-random-string'; | ||
//import cryptoRandomString from 'crypto-random-string'; | ||
import { logger } from '../../logger'; | ||
|
||
//jest.mock('crypto-random-string'); | ||
|
||
describe('when parsing a gitGraph', function() { | ||
let randomNumber; | ||
beforeEach(function() { | ||
parser.yy = gitGraphAst; | ||
parser.yy.clear(); | ||
randomNumber = 0; | ||
|
||
}); | ||
// afterEach(function() { | ||
// cryptoRandomString.mockReset(); | ||
// }); | ||
it('should handle a gitGraph commit with NO pararms, get auto-genrated reandom ID', function() { | ||
const str = `gitGraph: | ||
commit | ||
`; | ||
parser.parse(str); | ||
const commits = parser.yy.getCommits(); | ||
//console.info(commits); | ||
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); | ||
const key = Object.keys(commits)[0]; | ||
expect(commits[key].message).toBe(''); | ||
expect(commits[key].id).not.toBeNull(); | ||
expect(commits[key].tag).toBe(''); | ||
expect(commits[key].type).toBe(0); | ||
}); | ||
|
||
it('should handle a gitGraph commit with custom commit id only', function() { | ||
const str = `gitGraph: | ||
commit id:"1111" | ||
`; | ||
//console.log(str); | ||
parser.parse(str); | ||
const commits = parser.yy.getCommits(); | ||
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); | ||
const key = Object.keys(commits)[0]; | ||
expect(commits[key].message).toBe(''); | ||
expect(commits[key].id).toBe('1111'); | ||
expect(commits[key].tag).toBe(''); | ||
expect(commits[key].type).toBe(0); | ||
}); | ||
|
||
it('should handle a gitGraph commit with custom commit tag only', function() { | ||
const str = `gitGraph: | ||
commit tag:"test" | ||
`; | ||
|
||
parser.parse(str); | ||
const commits = parser.yy.getCommits(); | ||
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); | ||
const key = Object.keys(commits)[0]; | ||
expect(commits[key].message).toBe(''); | ||
expect(commits[key].id).not.toBeNull(); | ||
expect(commits[key].tag).toBe('test'); | ||
expect(commits[key].type).toBe(0); | ||
}); | ||
|
||
it('should handle a gitGraph commit with custom commit type HIGHLIGHT only', function() { | ||
const str = `gitGraph: | ||
commit type: HIGHLIGHT | ||
`; | ||
|
||
parser.parse(str); | ||
const commits = parser.yy.getCommits(); | ||
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); | ||
const key = Object.keys(commits)[0]; | ||
expect(commits[key].message).toBe(''); | ||
expect(commits[key].id).not.toBeNull(); | ||
expect(commits[key].tag).toBe(''); | ||
expect(commits[key].type).toBe(2); | ||
}); | ||
|
||
it('should handle a gitGraph commit with custom commit type REVERSE only', function() { | ||
const str = `gitGraph: | ||
commit type: REVERSE | ||
`; | ||
|
||
parser.parse(str); | ||
const commits = parser.yy.getCommits(); | ||
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); | ||
const key = Object.keys(commits)[0]; | ||
expect(commits[key].message).toBe(''); | ||
expect(commits[key].id).not.toBeNull(); | ||
expect(commits[key].tag).toBe(''); | ||
expect(commits[key].type).toBe(1); | ||
}); | ||
|
||
it('should handle a gitGraph commit with custom commit type NORMAL only', function() { | ||
const str = `gitGraph: | ||
commit type: NORMAL | ||
`; | ||
|
||
parser.parse(str); | ||
const commits = parser.yy.getCommits(); | ||
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); | ||
const key = Object.keys(commits)[0]; | ||
expect(commits[key].message).toBe(''); | ||
expect(commits[key].id).not.toBeNull(); | ||
expect(commits[key].tag).toBe(''); | ||
expect(commits[key].type).toBe(0); | ||
}); | ||
|
||
it('should handle a gitGraph commit with custom commit msg only', function() { | ||
const str = `gitGraph: | ||
commit "test commit" | ||
`; | ||
|
||
parser.parse(str); | ||
const commits = parser.yy.getCommits(); | ||
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); | ||
const key = Object.keys(commits)[0]; | ||
expect(commits[key].message).toBe('test commit'); | ||
expect(commits[key].id).not.toBeNull(); | ||
expect(commits[key].tag).toBe(''); | ||
expect(commits[key].type).toBe(0); | ||
}); | ||
|
||
it('should handle a gitGraph commit with custom commit id, tag only', function() { | ||
const str = `gitGraph: | ||
commit id:"1111" tag: "test tag" | ||
`; | ||
|
||
parser.parse(str); | ||
const commits = parser.yy.getCommits(); | ||
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); | ||
const key = Object.keys(commits)[0]; | ||
expect(commits[key].message).toBe(''); | ||
expect(commits[key].id).toBe('1111'); | ||
expect(commits[key].tag).toBe('test tag'); | ||
expect(commits[key].type).toBe(0); | ||
}); | ||
|
||
it('should handle a gitGraph commit with custom commit type, tag only', function() { | ||
const str = `gitGraph: | ||
commit type:HIGHLIGHT tag: "test tag" | ||
`; | ||
|
||
parser.parse(str); | ||
const commits = parser.yy.getCommits(); | ||
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); | ||
const key = Object.keys(commits)[0]; | ||
expect(commits[key].message).toBe(''); | ||
expect(commits[key].id).not.toBeNull(); | ||
expect(commits[key].tag).toBe('test tag'); | ||
expect(commits[key].type).toBe(2); | ||
}); | ||
|
||
it('should handle a gitGraph commit with custom commit tag and type only', function() { | ||
const str = `gitGraph: | ||
commit tag: "test tag" type:HIGHLIGHT | ||
`; | ||
|
||
parser.parse(str); | ||
const commits = parser.yy.getCommits(); | ||
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); | ||
const key = Object.keys(commits)[0]; | ||
expect(commits[key].message).toBe(''); | ||
expect(commits[key].id).not.toBeNull(); | ||
expect(commits[key].tag).toBe('test tag'); | ||
expect(commits[key].type).toBe(2); | ||
}); | ||
|
||
it('should handle a gitGraph commit with custom commit id, type and tag only', function() { | ||
const str = `gitGraph: | ||
commit id:"1111" type:REVERSE tag: "test tag" | ||
`; | ||
|
||
parser.parse(str); | ||
const commits = parser.yy.getCommits(); | ||
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); | ||
const key = Object.keys(commits)[0]; | ||
expect(commits[key].message).toBe(''); | ||
expect(commits[key].id).toBe('1111'); | ||
expect(commits[key].tag).toBe('test tag'); | ||
expect(commits[key].type).toBe(1); | ||
}); | ||
|
||
|
||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters