mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-03 07:36:41 +02:00
fix gantt chart cli configuration one more time missing }; make sequenceConfig cli configuration work; added guantt and sequence files in tape cli output tests
This commit is contained in:
@@ -211,7 +211,7 @@ function executeInPage(data) {
|
|||||||
var xmlSerializer = new XMLSerializer()
|
var xmlSerializer = new XMLSerializer()
|
||||||
, contents = data.contents
|
, contents = data.contents
|
||||||
, sequenceConfig = JSON.stringify(data.sequenceConfig)
|
, sequenceConfig = JSON.stringify(data.sequenceConfig)
|
||||||
, ganttConfig = JSON.stringify(data.ganttConfig).replace(/"(function.*)}"/, "$1")
|
, ganttConfig = JSON.stringify(data.ganttConfig).replace(/"(function.*})"/, "$1")
|
||||||
, toRemove
|
, toRemove
|
||||||
, el
|
, el
|
||||||
, elContent
|
, elContent
|
||||||
@@ -222,35 +222,28 @@ function executeInPage(data) {
|
|||||||
, height
|
, height
|
||||||
, confWidth = data.confWidth
|
, confWidth = data.confWidth
|
||||||
|
|
||||||
toRemove = document.getElementsByClassName('mermaid')
|
var toRemove = document.getElementsByClassName('mermaid')
|
||||||
if (toRemove && toRemove.length) {
|
if (toRemove && toRemove.length) {
|
||||||
for (var i = 0, len = toRemove.length; i < len; i++) {
|
for (var i = 0, len = toRemove.length; i < len; i++) {
|
||||||
toRemove[i].parentNode.removeChild(toRemove[i])
|
toRemove[i].parentNode.removeChild(toRemove[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
el = document.createElement("div")
|
var el = document.createElement("div")
|
||||||
el.className = 'mermaid'
|
el.className = 'mermaid'
|
||||||
elContent = document.createTextNode(contents)
|
el.appendChild(document.createTextNode(contents))
|
||||||
el.appendChild(elContent)
|
|
||||||
//el.innerText = '<b>hello</b>\uD800' //contents;
|
|
||||||
|
|
||||||
document.body.appendChild(el)
|
document.body.appendChild(el)
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
sequenceDiagram: sequenceConfig,
|
sequenceDiagram: JSON.parse(sequenceConfig),
|
||||||
flowchart: {useMaxWidth: false},
|
flowchart: {useMaxWidth: false},
|
||||||
logLevel: 1
|
logLevel: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
mermaid.initialize(config);
|
mermaid.initialize(config);
|
||||||
|
|
||||||
//console.log('after initialize',sequenceConfig);
|
var sc = document.createElement("script")
|
||||||
|
sc.appendChild(document.createTextNode('mermaid.ganttConfig = ' + ganttConfig + ';'))
|
||||||
sc = document.createElement("script")
|
|
||||||
scContent = document.createTextNode('mermaid.ganttConfig = ' + ganttConfig + ';')
|
|
||||||
sc.appendChild(scContent)
|
|
||||||
|
|
||||||
document.body.appendChild(sc)
|
document.body.appendChild(sc)
|
||||||
|
|
||||||
mermaid.init();
|
mermaid.init();
|
||||||
|
@@ -71,8 +71,7 @@ function Log(level) {
|
|||||||
args.unshift('[' + formatTime(new Date()) + '] ');
|
args.unshift('[' + formatTime(new Date()) + '] ');
|
||||||
console.log.apply(console, args.map(function(a){
|
console.log.apply(console, args.map(function(a){
|
||||||
if (typeof a === "object") {
|
if (typeof a === "object") {
|
||||||
if (a.stack !== undefined) { return a.stack; }
|
return a.toString() + JSON.stringify(a, null, 2);
|
||||||
return JSON.stringify(a, null, 2);
|
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}));
|
}));
|
||||||
|
@@ -13,15 +13,14 @@ var isWin = /^win/.test(process.platform);
|
|||||||
var phantomCmd;
|
var phantomCmd;
|
||||||
if(isWin){
|
if(isWin){
|
||||||
phantomCmd = 'node_modules/.bin/phantomjs.cmd'
|
phantomCmd = 'node_modules/.bin/phantomjs.cmd'
|
||||||
console.log('is win');
|
console.log('is win')
|
||||||
console.log('is win');
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
phantomCmd = 'node_modules/.bin/phantomjs'
|
phantomCmd = 'node_modules/.bin/phantomjs'
|
||||||
}
|
}
|
||||||
var singleFile = {
|
var singleFile = {
|
||||||
files: [fileTestMermaid]
|
files: [fileTestMermaid]
|
||||||
, outputDir: path.join(process.cwd(),'test/tmp2/')
|
, outputDir: path.join(process.cwd(),'test/tmp_single')
|
||||||
, phantomPath: path.join(process.cwd(),phantomCmd)
|
, phantomPath: path.join(process.cwd(),phantomCmd)
|
||||||
, width : 1200
|
, width : 1200
|
||||||
, css: path.join(__dirname, '..', 'dist', 'mermaid.css')
|
, css: path.join(__dirname, '..', 'dist', 'mermaid.css')
|
||||||
@@ -29,8 +28,12 @@ var singleFile = {
|
|||||||
, ganttConfig: null
|
, ganttConfig: null
|
||||||
}
|
}
|
||||||
, multiFile = {
|
, multiFile = {
|
||||||
files: [path.join('test','fixtures','test.mermaid'), path.join('test','fixtures','test2.mermaid')]
|
files: [path.join('test','fixtures','test.mermaid'),
|
||||||
, outputDir: 'test/tmp2/'
|
path.join('test','fixtures','test2.mermaid'),
|
||||||
|
path.join('test','fixtures','gantt.mermaid'),
|
||||||
|
path.join('test','fixtures','sequence.mermaid'),
|
||||||
|
]
|
||||||
|
, outputDir: 'test/tmp_multi'
|
||||||
, phantomPath: path.join(process.cwd(),phantomCmd)
|
, phantomPath: path.join(process.cwd(),phantomCmd)
|
||||||
, width : 1200
|
, width : 1200
|
||||||
, css: path.join(__dirname, '..', 'dist', 'mermaid.css')
|
, css: path.join(__dirname, '..', 'dist', 'mermaid.css')
|
||||||
@@ -45,6 +48,7 @@ test('output of single png', function(t) {
|
|||||||
var expected = ['test.mermaid.png']
|
var expected = ['test.mermaid.png']
|
||||||
|
|
||||||
opt = clone(singleFile)
|
opt = clone(singleFile)
|
||||||
|
opt.outputDir += '_png'
|
||||||
opt.png = true
|
opt.png = true
|
||||||
|
|
||||||
mermaid.process(opt.files, opt, function(code) {
|
mermaid.process(opt.files, opt, function(code) {
|
||||||
@@ -57,9 +61,11 @@ test('output of single png', function(t) {
|
|||||||
test('output of multiple png', function(t) {
|
test('output of multiple png', function(t) {
|
||||||
t.plan(3)
|
t.plan(3)
|
||||||
|
|
||||||
var expected = ['test.mermaid.png', 'test2.mermaid.png']
|
var expected = ['test.mermaid.png', 'test2.mermaid.png',
|
||||||
|
'gantt.mermaid.png', 'sequence.mermaid.png']
|
||||||
|
|
||||||
opt = clone(multiFile)
|
opt = clone(multiFile)
|
||||||
|
opt.outputDir += '_png'
|
||||||
opt.png = true
|
opt.png = true
|
||||||
|
|
||||||
mermaid.process(opt.files, opt, function(code) {
|
mermaid.process(opt.files, opt, function(code) {
|
||||||
@@ -75,6 +81,7 @@ test('output of single svg', function(t) {
|
|||||||
var expected = ['test.mermaid.svg']
|
var expected = ['test.mermaid.svg']
|
||||||
|
|
||||||
opt = clone(singleFile)
|
opt = clone(singleFile)
|
||||||
|
opt.outputDir += '_svg'
|
||||||
opt.svg = true
|
opt.svg = true
|
||||||
|
|
||||||
mermaid.process(opt.files, opt, function(code) {
|
mermaid.process(opt.files, opt, function(code) {
|
||||||
@@ -87,9 +94,11 @@ test('output of single svg', function(t) {
|
|||||||
test('output of multiple svg', function(t) {
|
test('output of multiple svg', function(t) {
|
||||||
t.plan(3)
|
t.plan(3)
|
||||||
|
|
||||||
var expected = ['test.mermaid.svg', 'test2.mermaid.svg']
|
var expected = ['test.mermaid.svg', 'test2.mermaid.svg',
|
||||||
|
'gantt.mermaid.svg', 'sequence.mermaid.svg']
|
||||||
|
|
||||||
opt = clone(multiFile)
|
opt = clone(multiFile)
|
||||||
|
opt.outputDir += '_svg'
|
||||||
opt.svg = true
|
opt.svg = true
|
||||||
|
|
||||||
mermaid.process(opt.files, opt, function(code) {
|
mermaid.process(opt.files, opt, function(code) {
|
||||||
@@ -110,28 +119,22 @@ test('output including CSS', function(t) {
|
|||||||
, two
|
, two
|
||||||
|
|
||||||
opt.png = true
|
opt.png = true
|
||||||
|
opt.outputDir += '_css_png'
|
||||||
opt2.png = true
|
opt2.png = true
|
||||||
|
opt2.outputDir += '_css_png'
|
||||||
|
|
||||||
|
|
||||||
mermaid.process(opt.files, opt, function(code) {
|
mermaid.process(opt.files, opt, function(code) {
|
||||||
t.equal(code, 0, 'has clean exit code')
|
t.equal(code, 0, 'has clean exit code')
|
||||||
filename = path.join(opt.outputDir, path.basename(expected[0]))
|
filename = path.join(opt.outputDir, path.basename(expected[0]))
|
||||||
one = fs.statSync(filename)
|
one = fs.statSync(filename)
|
||||||
//console.log('one: '+opt.files[0]);
|
|
||||||
|
|
||||||
opt2.css = path.join('test','fixtures','test.css')
|
opt2.css = path.join('test','fixtures','test.css')
|
||||||
//console.log(opt2.css);
|
|
||||||
|
|
||||||
console.log('Generating #2');
|
console.log('Generating #2');
|
||||||
//console.log('two: '+opt2.files[0]);
|
|
||||||
mermaid.process(opt2.files, opt2, function(code) {
|
mermaid.process(opt2.files, opt2, function(code) {
|
||||||
t.equal(code, 0, 'has clean exit code')
|
t.equal(code, 0, 'has clean exit code')
|
||||||
two = fs.statSync(filename)
|
two = fs.statSync(filename)
|
||||||
|
|
||||||
//console.log('one: '+one.size);
|
|
||||||
//console.log('two: '+two.size);
|
|
||||||
|
|
||||||
|
|
||||||
t.notEqual(one.size, two.size)
|
t.notEqual(one.size, two.size)
|
||||||
|
|
||||||
verifyFiles(expected, opt.outputDir, t)
|
verifyFiles(expected, opt.outputDir, t)
|
||||||
@@ -151,8 +154,9 @@ function verifyFiles(expected, dir, t) {
|
|||||||
}
|
}
|
||||||
, function(err) {
|
, function(err) {
|
||||||
t.notOk(err, 'all files passed')
|
t.notOk(err, 'all files passed')
|
||||||
|
var delete_tmps = true
|
||||||
rimraf(dir, function(rmerr) {
|
var _rimraf=delete_tmps ? rimraf : function(dir, f) { f(0); }
|
||||||
|
_rimraf(dir, function(rmerr) {
|
||||||
t.notOk(rmerr, 'cleaned up')
|
t.notOk(rmerr, 'cleaned up')
|
||||||
t.end()
|
t.end()
|
||||||
})
|
})
|
||||||
|
8
test/fixtures/gantt.mermaid
vendored
Normal file
8
test/fixtures/gantt.mermaid
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
gantt
|
||||||
|
dateFormat YYYY-MM-DD
|
||||||
|
title Adding GANTT diagram functionality to mermaid
|
||||||
|
section A section
|
||||||
|
Completed task :done, des1, 2014-01-06,2014-01-08
|
||||||
|
Active task :active, des2, 2014-01-09, 3d
|
||||||
|
Future task : des3, after des2, 5d
|
||||||
|
Future task2 : des4, after des3, 5d
|
Reference in New Issue
Block a user