From 96a25935acd5c7e926808beebe3d3a93500ee4b0 Mon Sep 17 00:00:00 2001 From: whyzdev Date: Sat, 17 Dec 2016 18:03:11 -0500 Subject: [PATCH 1/6] fix warnings per code climate --- .gitignore | 4 +++- src/diagrams/sequenceDiagram/svgDraw.js | 32 ++++++++++++------------- test/cli_test-output.js | 10 ++++---- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index 683edb13eb..383d087d46 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,6 @@ bower_components .DS_Store .idea -coverage \ No newline at end of file +coverage + +test/tmp_* diff --git a/src/diagrams/sequenceDiagram/svgDraw.js b/src/diagrams/sequenceDiagram/svgDraw.js index defd454f13..16204c7631 100644 --- a/src/diagrams/sequenceDiagram/svgDraw.js +++ b/src/diagrams/sequenceDiagram/svgDraw.js @@ -271,16 +271,14 @@ var _drawTextCandidateFunc = (function() { .attr('x', x + width / 2).attr('y', y + height / 2 + 5) .style('text-anchor', 'middle') .text(content); - for (var key in textAttrs) { - text.attr(key, textAttrs[key]); - } - }; + _setTextAttrs(text, textAttrs); + } function byTspan(content, g, x, y, width, height, textAttrs) { var text = g.append('text') .attr('x', x + width / 2).attr('y', y) .style('text-anchor', 'middle'); - var tspan = text.append('tspan') + text.append('tspan') .attr('x', x + width / 2).attr('dy', '0') .text(content); @@ -293,16 +291,13 @@ var _drawTextCandidateFunc = (function() { if (tspans.length > 0 && tspans[0].length > 0) { tspans = tspans[0]; //set y of to the mid y of the first line - text.attr('y', y + (height/2.- text[0][0].getBBox().height*(1 - 1.0/tspans.length)/2.)) + text.attr('y', y + (height/2.0 - text[0][0].getBBox().height*(1 - 1.0/tspans.length)/2.0)) .attr("dominant-baseline", "central") - .attr("alignment-baseline", "central") + .attr("alignment-baseline", "central"); } } - - for (var key in textAttrs) { - text.attr(key, textAttrs[key]); - } - }; + _setTextAttrs(text, textAttrs); + } function byFo(content, g, x, y, width, height, textAttrs) { var s = g.append('switch'); @@ -315,14 +310,19 @@ var _drawTextCandidateFunc = (function() { text.append('div').style('display', 'table-cell') .style('text-align', 'center').style('vertical-align', 'middle') - .text(content) + .text(content); byTspan(content, s, x, y, width, height, textAttrs); + _setTextAttrs(text, textAttrs); + } - for (var key in textAttrs) { - text.attr(key, textAttrs[key]); + function _setTextAttrs(toText, fromTextAttrsDict) { + for (var key in fromTextAttrsDict) { + if (fromTextAttrsDict.hasOwnProperty(key)) { + toText.attr(key, fromTextAttrsDict[key]); } - }; + } + } return function(conf) { return conf.textPlacement==='fo' ? byFo : ( diff --git a/test/cli_test-output.js b/test/cli_test-output.js index b853556553..9236cd95b5 100644 --- a/test/cli_test-output.js +++ b/test/cli_test-output.js @@ -47,7 +47,7 @@ test('output of single png', function(t) { var expected = ['test.mermaid.png'] - opt = clone(singleFile) + var opt = clone(singleFile) opt.outputDir += '_png' opt.png = true @@ -64,7 +64,7 @@ test('output of multiple png', function(t) { var expected = ['test.mermaid.png', 'test2.mermaid.png', 'gantt.mermaid.png', 'sequence.mermaid.png'] - opt = clone(multiFile) + var opt = clone(multiFile) opt.outputDir += '_png' opt.png = true @@ -80,7 +80,7 @@ test('output of single svg', function(t) { var expected = ['test.mermaid.svg'] - opt = clone(singleFile) + var opt = clone(singleFile) opt.outputDir += '_svg' opt.svg = true @@ -97,7 +97,7 @@ test('output of multiple svg', function(t) { var expected = ['test.mermaid.svg', 'test2.mermaid.svg', 'gantt.mermaid.svg', 'sequence.mermaid.svg'] - opt = clone(multiFile) + var opt = clone(multiFile) opt.outputDir += '_svg' opt.svg = true @@ -154,7 +154,7 @@ function verifyFiles(expected, dir, t) { } , function(err) { t.notOk(err, 'all files passed') - var delete_tmps = true + var delete_tmps = false var _rimraf=delete_tmps ? rimraf : function(dir, f) { f(0); } _rimraf(dir, function(rmerr) { t.notOk(rmerr, 'cleaned up') From e13c93958367d8a6e46633581c62eccc5db4eb61 Mon Sep 17 00:00:00 2001 From: whyzdev Date: Sun, 18 Dec 2016 12:30:37 -0500 Subject: [PATCH 2/6] added cli_test_run-samples to test samples from commandline; added --outputSuffix option --- lib/cli.js | 6 +- lib/index.js | 2 + lib/phantomscript.js | 11 ++-- test/cli_test-output.js | 2 +- test/cli_test-run-samples.js | 62 +++++++++++++++++++ test/fixtures/samples/sequence_text.mmd | 6 ++ test/fixtures/samples/sequence_text_fo.cfg | 3 + test/fixtures/samples/sequence_text_old.cfg | 3 + test/fixtures/samples/sequence_text_tspan.cfg | 3 + test/fixtures/sequence.mermaid | 10 +-- 10 files changed, 95 insertions(+), 13 deletions(-) create mode 100644 test/cli_test-run-samples.js create mode 100644 test/fixtures/samples/sequence_text.mmd create mode 100644 test/fixtures/samples/sequence_text_fo.cfg create mode 100644 test/fixtures/samples/sequence_text_old.cfg create mode 100644 test/fixtures/samples/sequence_text_tspan.cfg diff --git a/lib/cli.js b/lib/cli.js index db28e62e49..0b389dc85b 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -21,6 +21,7 @@ function cli(options) { help: 'h' , png: 'p' , outputDir: 'o' + , outputSuffix: 'O' , svg: 's' , verbose: 'v' , phantomPath: 'e' @@ -30,7 +31,7 @@ function cli(options) { , width: 'w' } , 'boolean': ['help', 'png', 'svg', 'verbose'] - , 'string': ['outputDir'] + , 'string': ['outputDir', 'outputSuffix'] } this.errors = [] @@ -45,6 +46,7 @@ function cli(options) { , " -s --svg Output SVG instead of PNG (experimental)" , " -p --png If SVG was selected, and you also want PNG, set this flag" , " -o --outputDir Directory to save files, will be created automatically, defaults to `cwd`" + , " -O --outputSuffix Suffix to output filenames in front of '.svg' or '.png', defaults to ''" , " -e --phantomPath Specify the path to the phantomjs executable" , " -t --css Specify the path to a CSS file to be included when processing output" , " -c --sequenceConfig Specify the path to the file with the configuration to be applied in the sequence diagram" @@ -79,7 +81,7 @@ cli.prototype.parse = function(argv, next) { } // ensure that parameter-expecting options have parameters - ;['outputDir', 'phantomPath', 'sequenceConfig', 'ganttConfig', 'css'].forEach(function(i) { + ;['outputDir', 'outputSuffix', 'phantomPath', 'sequenceConfig', 'ganttConfig', 'css'].forEach(function(i) { if(typeof options[i] !== 'undefined') { if (typeof options[i] !== 'string' || options[i].length < 1) { this.errors.push(new Error(i + " expects a value.")) diff --git a/lib/index.js b/lib/index.js index 5da3683b25..540ccff962 100644 --- a/lib/index.js +++ b/lib/index.js @@ -12,6 +12,7 @@ module.exports = { process: processMermaid } function processMermaid(files, _options, _next) { var options = _options || {} , outputDir = options.outputDir || process.cwd() + , outputSuffix = options.outputSuffix || "" , next = _next || function() {} , phantomArgs = [ phantomscript @@ -23,6 +24,7 @@ function processMermaid(files, _options, _next) { , options.ganttConfig , options.verbose , options.width + , outputSuffix ]; files.forEach(function(file) { diff --git a/lib/phantomscript.js b/lib/phantomscript.js index 1e0edf1f04..12a73c6259 100644 --- a/lib/phantomscript.js +++ b/lib/phantomscript.js @@ -29,7 +29,7 @@ var system = require('system') , webpage = require('webpage') var page = webpage.create() - , files = system.args.slice(9, system.args.length) + , files = system.args.slice(10, system.args.length) , width = system.args[8] if(typeof width === 'undefined' || width==='undefined'){ @@ -44,6 +44,7 @@ var options = { , ganttConfig: system.args[6] !== 'null' ? JSON.parse(fs.read(system.args[6])) : {} , verbose: system.args[7] === 'true' ? true : false , width: width + , outputSuffix: system.args[9] } , log = logger(options.verbose) options.sequenceConfig.useMaxWidth = false; @@ -98,21 +99,21 @@ files.forEach(function(file) { for (var i = 0, len = allElements.length; i < len; i++) { resolveForeignObjects(allElements[i]) } - + + var outputPath=options.outputDir + fs.separator + filename + options.outputSuffix; if (options.png) { page.viewportSize = { width: ~~oDOM.documentElement.attributes.getNamedItem('width').value , height: ~~oDOM.documentElement.attributes.getNamedItem('height').value } - page.render(options.outputDir + fs.separator + filename + '.png') + page.render(outputPath+'.png') console.log('saved png: ' + filename + '.png') } if (options.svg) { var serialize = new XMLSerializer(); - fs.write( - options.outputDir + fs.separator + filename + '.svg' + fs.write(outputPath+'.svg' , serialize.serializeToString(oDOM)+'\n' , 'w' ) diff --git a/test/cli_test-output.js b/test/cli_test-output.js index 9236cd95b5..f57d8be602 100644 --- a/test/cli_test-output.js +++ b/test/cli_test-output.js @@ -154,7 +154,7 @@ function verifyFiles(expected, dir, t) { } , function(err) { t.notOk(err, 'all files passed') - var delete_tmps = false + var delete_tmps = true var _rimraf=delete_tmps ? rimraf : function(dir, f) { f(0); } _rimraf(dir, function(rmerr) { t.notOk(rmerr, 'cleaned up') diff --git a/test/cli_test-run-samples.js b/test/cli_test-run-samples.js new file mode 100644 index 0000000000..5ac8f5351e --- /dev/null +++ b/test/cli_test-run-samples.js @@ -0,0 +1,62 @@ +'use strict'; +var exec = require('child_process').exec; +var fs = require('fs') + , path = require('path') + + var test = require('tape') + , async = require('async') + , clone = require('clone') + , rimraf = require('rimraf') + +var test_dir = "test/fixtures/samples/" + +function exec_mermaid(args, verify) { + exec('bin/mermaid.js ' + args, + {env: {PATH: "./node_modules/.bin"+path.delimiter+process.env.PATH}}, + function(error, stdout, stderr) { + console.log('error:',error,'\nstdout:\n',stdout,'\nstderr:\n',stderr); + verify(error, stdout, stderr); + }); +} + +test('mermaid cli help', function(t) { + t.plan(1); + var args = [ "--help", ] + exec_mermaid(args.join(" "), + function(error, stdout, stderr) { + t.notOk(error, 'no error code') + t.end() + }); +}); + +test('sequence (actor) text default svg', function(t) { + t.plan(1); + var args = [ "--svg", + "--outputDir=" + test_dir, + test_dir+"sequence_text.mmd", + ] + exec_mermaid(args.join(" "), + function(error, stdout, stderr) { + t.notOk(error, 'no error code') + t.end() + }); +}); + +['fo', 'tspan', 'old'].forEach(function(textPlacement) { + test('sequence svg text placelment: '+textPlacement, function(t) { + t.plan(1); + var args = [ "--svg", + "--outputDir=" + test_dir, + "--outputSuffix=_"+textPlacement, + "--sequenceConfig="+test_dir+path.sep+"sequence_text_"+textPlacement+".cfg", + test_dir+"sequence_text.mmd", + ] + exec_mermaid(args.join(" "), + function(error, stdout, stderr) { + t.notOk(error, 'no error code') + t.end() + }); + }) +}); + + diff --git a/test/fixtures/samples/sequence_text.mmd b/test/fixtures/samples/sequence_text.mmd new file mode 100644 index 0000000000..c36663fd6b --- /dev/null +++ b/test/fixtures/samples/sequence_text.mmd @@ -0,0 +1,6 @@ +sequenceDiagram + participant A as actor + participant B as very very very long long long long-long-long text + A->>B: hi + B-->A: + B->>A: hello diff --git a/test/fixtures/samples/sequence_text_fo.cfg b/test/fixtures/samples/sequence_text_fo.cfg new file mode 100644 index 0000000000..f4667e30f8 --- /dev/null +++ b/test/fixtures/samples/sequence_text_fo.cfg @@ -0,0 +1,3 @@ +{ + "textPlacement": "fo" +} diff --git a/test/fixtures/samples/sequence_text_old.cfg b/test/fixtures/samples/sequence_text_old.cfg new file mode 100644 index 0000000000..f95a87978e --- /dev/null +++ b/test/fixtures/samples/sequence_text_old.cfg @@ -0,0 +1,3 @@ +{ + "textPlacement": "old" +} diff --git a/test/fixtures/samples/sequence_text_tspan.cfg b/test/fixtures/samples/sequence_text_tspan.cfg new file mode 100644 index 0000000000..10fa0ec4b2 --- /dev/null +++ b/test/fixtures/samples/sequence_text_tspan.cfg @@ -0,0 +1,3 @@ +{ + "textPlacement": "tspan" +} diff --git a/test/fixtures/sequence.mermaid b/test/fixtures/sequence.mermaid index e0f8a5b579..9774e65513 100644 --- a/test/fixtures/sequence.mermaid +++ b/test/fixtures/sequence.mermaid @@ -1,8 +1,8 @@ sequenceDiagram - Alice->Bob: Hello Bob, how are you? + Alice->>Bob: Hello Bob, how are you? Note right of Bob: Bob thinks - Bob-->Alice: I am good thanks! - Bob-->John the Long: How about you John? - Bob-->Alice: Checking with John... - Alice->John the Long: Yes... John, how are you? + Bob-->>Alice: I am good thanks! + Bob-->>John the Long: How about you John? + Bob-->>Alice: Checking with John... + Alice->>John the Long: Yes... John, how are you? John the Long-->Alice: Better than you! From b73698849d987895ae5bcd8da5b123ad3182616a Mon Sep 17 00:00:00 2001 From: whyzdev Date: Sun, 18 Dec 2016 18:05:37 -0500 Subject: [PATCH 3/6] rename tests --- ...est-run-samples.js => cli_test-samples.js} | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) rename test/{cli_test-run-samples.js => cli_test-samples.js} (70%) diff --git a/test/cli_test-run-samples.js b/test/cli_test-samples.js similarity index 70% rename from test/cli_test-run-samples.js rename to test/cli_test-samples.js index 5ac8f5351e..a0eafc0b55 100644 --- a/test/cli_test-run-samples.js +++ b/test/cli_test-samples.js @@ -29,26 +29,13 @@ test('mermaid cli help', function(t) { }); }); -test('sequence (actor) text default svg', function(t) { - t.plan(1); - var args = [ "--svg", - "--outputDir=" + test_dir, - test_dir+"sequence_text.mmd", - ] - exec_mermaid(args.join(" "), - function(error, stdout, stderr) { - t.notOk(error, 'no error code') - t.end() - }); -}); - -['fo', 'tspan', 'old'].forEach(function(textPlacement) { +[undefined, 'fo', 'tspan', 'old'].forEach(function(textPlacement) { test('sequence svg text placelment: '+textPlacement, function(t) { t.plan(1); var args = [ "--svg", "--outputDir=" + test_dir, - "--outputSuffix=_"+textPlacement, - "--sequenceConfig="+test_dir+path.sep+"sequence_text_"+textPlacement+".cfg", + textPlacement===undefined ? "" : "--outputSuffix=_"+textPlacement, + textPlacement===undefined ? "" : "--sequenceConfig="+test_dir+path.sep+"sequence_text_"+textPlacement+".cfg", test_dir+"sequence_text.mmd", ] exec_mermaid(args.join(" "), From 0ecbbf8ddfd946a4b275781f05df7ce014832fd5 Mon Sep 17 00:00:00 2001 From: whyzdev Date: Sun, 18 Dec 2016 22:52:41 -0500 Subject: [PATCH 4/6] add tests --- .gitignore | 1 + test/cli_test-samples.js | 52 +++++++++++++++++++++++--- test/fixtures/samples/sequence_err.mmd | 2 + 3 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 test/fixtures/samples/sequence_err.mmd diff --git a/.gitignore b/.gitignore index 383d087d46..145aed740a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ bower_components coverage test/tmp_* +test/fixtures/samples/*.actual.* diff --git a/test/cli_test-samples.js b/test/cli_test-samples.js index a0eafc0b55..0c0253fb4a 100644 --- a/test/cli_test-samples.js +++ b/test/cli_test-samples.js @@ -8,8 +8,10 @@ var fs = require('fs') , clone = require('clone') , rimraf = require('rimraf') -var test_dir = "test/fixtures/samples/" +var test_dir = "test/fixtures/samples/".replace('/',path.sep) +rimraf.sync(test_dir+'*.actual.*'); + function exec_mermaid(args, verify) { exec('bin/mermaid.js ' + args, {env: {PATH: "./node_modules/.bin"+path.delimiter+process.env.PATH}}, @@ -24,26 +26,64 @@ test('mermaid cli help', function(t) { var args = [ "--help", ] exec_mermaid(args.join(" "), function(error, stdout, stderr) { - t.notOk(error, 'no error code') + t.notOk(error, 'no error') t.end() }); }); -[undefined, 'fo', 'tspan', 'old'].forEach(function(textPlacement) { +test('mermaid cli help', function(t) { + t.plan(1); + var args = [ "--badopt", ] + exec_mermaid(args.join(" "), + function(error, stdout, stderr) { + t.ok(stderr, 'should get error') + t.end() + }); +}); + +//todo +test.skip('sequence syntax error', function(t) { + t.plan(1); + var args = [ "--svg", + "--outputDir=" + test_dir, + "--outputSuffix=.actual", + test_dir+"sequence_err.mmd", + ] + exec_mermaid(args.join(" "), + function(error, stdout, stderr) { + t.ok(stderr, 'should get error') + t.end() + }); +}); + +['', 'fo', 'tspan', 'old'].forEach(function(textPlacement) { test('sequence svg text placelment: '+textPlacement, function(t) { t.plan(1); var args = [ "--svg", "--outputDir=" + test_dir, - textPlacement===undefined ? "" : "--outputSuffix=_"+textPlacement, - textPlacement===undefined ? "" : "--sequenceConfig="+test_dir+path.sep+"sequence_text_"+textPlacement+".cfg", + "--outputSuffix="+(textPlacement ? "_"+textPlacement : "")+".actual", + textPlacement ? "--sequenceConfig="+test_dir+"sequence_text_"+textPlacement+".cfg" : "", test_dir+"sequence_text.mmd", ] exec_mermaid(args.join(" "), function(error, stdout, stderr) { - t.notOk(error, 'no error code') + t.notOk(stderr, 'no error') t.end() }); }) }); +test('sequence png', function(t) { + t.plan(1); + var args = [ "--png", + "--outputDir=" + test_dir, + "--outputSuffix=.actual", + test_dir+"sequence_text.mmd", + ] + exec_mermaid(args.join(" "), + function(error, stdout, stderr) { + t.notOk(stderr, 'no error') + t.end() + }); +}) diff --git a/test/fixtures/samples/sequence_err.mmd b/test/fixtures/samples/sequence_err.mmd new file mode 100644 index 0000000000..fe2e16f20a --- /dev/null +++ b/test/fixtures/samples/sequence_err.mmd @@ -0,0 +1,2 @@ +sequenceDiagram + bad From 4a5bbe1791cc60f6babcb1d20dc365758e205c00 Mon Sep 17 00:00:00 2001 From: whyzdev Date: Sun, 18 Dec 2016 23:11:27 -0500 Subject: [PATCH 5/6] added a flowchart cli test to reproduce #434 --- test/cli_test-samples.js | 13 +++++++++++++ test/fixtures/samples/flowchart_text.mmd | 4 ++++ 2 files changed, 17 insertions(+) create mode 100644 test/fixtures/samples/flowchart_text.mmd diff --git a/test/cli_test-samples.js b/test/cli_test-samples.js index 0c0253fb4a..4a233320be 100644 --- a/test/cli_test-samples.js +++ b/test/cli_test-samples.js @@ -87,3 +87,16 @@ test('sequence png', function(t) { }); }) +test('flowchart svg text', function(t) { + t.plan(1); + var args = [ "--svg", + "--outputDir=" + test_dir, + "--outputSuffix=.actual", + test_dir+"flowchart_text.mmd", + ] + exec_mermaid(args.join(" "), + function(error, stdout, stderr) { + t.notOk(stderr, 'no error') + t.end() + }); +}) diff --git a/test/fixtures/samples/flowchart_text.mmd b/test/fixtures/samples/flowchart_text.mmd new file mode 100644 index 0000000000..0d82cee4e2 --- /dev/null +++ b/test/fixtures/samples/flowchart_text.mmd @@ -0,0 +1,4 @@ +graph TD + A[label] + B[very very very long long long long-long-long text] + A--test-->B From 71125e7b868adb930b2c0e7b0ef16c71267c5f27 Mon Sep 17 00:00:00 2001 From: whyzdev Date: Mon, 19 Dec 2016 00:09:12 -0500 Subject: [PATCH 6/6] change " to ' per code climate --- lib/index.js | 2 +- test/cli_test-samples.js | 67 +++++++++++++++++----------------------- 2 files changed, 30 insertions(+), 39 deletions(-) diff --git a/lib/index.js b/lib/index.js index 540ccff962..edf2b37028 100644 --- a/lib/index.js +++ b/lib/index.js @@ -12,7 +12,7 @@ module.exports = { process: processMermaid } function processMermaid(files, _options, _next) { var options = _options || {} , outputDir = options.outputDir || process.cwd() - , outputSuffix = options.outputSuffix || "" + , outputSuffix = options.outputSuffix || '' , next = _next || function() {} , phantomArgs = [ phantomscript diff --git a/test/cli_test-samples.js b/test/cli_test-samples.js index 4a233320be..c043f01b91 100644 --- a/test/cli_test-samples.js +++ b/test/cli_test-samples.js @@ -1,20 +1,17 @@ 'use strict'; var exec = require('child_process').exec; -var fs = require('fs') - , path = require('path') +var path = require('path') var test = require('tape') - , async = require('async') - , clone = require('clone') , rimraf = require('rimraf') -var test_dir = "test/fixtures/samples/".replace('/',path.sep) +var test_dir = 'test/fixtures/samples/'.replace('/',path.sep) rimraf.sync(test_dir+'*.actual.*'); function exec_mermaid(args, verify) { exec('bin/mermaid.js ' + args, - {env: {PATH: "./node_modules/.bin"+path.delimiter+process.env.PATH}}, + {env: {PATH: './node_modules/.bin'+path.delimiter+process.env.PATH}}, function(error, stdout, stderr) { console.log('error:',error,'\nstdout:\n',stdout,'\nstderr:\n',stderr); verify(error, stdout, stderr); @@ -23,19 +20,17 @@ function exec_mermaid(args, verify) { test('mermaid cli help', function(t) { t.plan(1); - var args = [ "--help", ] - exec_mermaid(args.join(" "), - function(error, stdout, stderr) { - t.notOk(error, 'no error') + var args = [ '--help' ] + exec_mermaid(args.join(' '), function(error, stdout, stderr) { + t.notOk(stderr, 'no error') t.end() }); }); test('mermaid cli help', function(t) { t.plan(1); - var args = [ "--badopt", ] - exec_mermaid(args.join(" "), - function(error, stdout, stderr) { + var args = [ '--badopt' ] + exec_mermaid(args.join(' '), function(error, stdout, stderr) { t.ok(stderr, 'should get error') t.end() }); @@ -44,13 +39,12 @@ test('mermaid cli help', function(t) { //todo test.skip('sequence syntax error', function(t) { t.plan(1); - var args = [ "--svg", - "--outputDir=" + test_dir, - "--outputSuffix=.actual", - test_dir+"sequence_err.mmd", + var args = [ '--svg', + '--outputDir=' + test_dir, + '--outputSuffix=.actual', + test_dir+'sequence_err.mmd' ] - exec_mermaid(args.join(" "), - function(error, stdout, stderr) { + exec_mermaid(args.join(' '), function(error, stdout, stderr) { t.ok(stderr, 'should get error') t.end() }); @@ -59,14 +53,13 @@ test.skip('sequence syntax error', function(t) { ['', 'fo', 'tspan', 'old'].forEach(function(textPlacement) { test('sequence svg text placelment: '+textPlacement, function(t) { t.plan(1); - var args = [ "--svg", - "--outputDir=" + test_dir, - "--outputSuffix="+(textPlacement ? "_"+textPlacement : "")+".actual", - textPlacement ? "--sequenceConfig="+test_dir+"sequence_text_"+textPlacement+".cfg" : "", - test_dir+"sequence_text.mmd", + var args = [ '--svg', + '--outputDir=' + test_dir, + '--outputSuffix='+(textPlacement ? '_'+textPlacement : '')+'.actual', + textPlacement ? '--sequenceConfig='+test_dir+'sequence_text_'+textPlacement+'.cfg' : '', + test_dir+'sequence_text.mmd' ] - exec_mermaid(args.join(" "), - function(error, stdout, stderr) { + exec_mermaid(args.join(' '), function(error, stdout, stderr) { t.notOk(stderr, 'no error') t.end() }); @@ -75,13 +68,12 @@ test.skip('sequence syntax error', function(t) { test('sequence png', function(t) { t.plan(1); - var args = [ "--png", - "--outputDir=" + test_dir, - "--outputSuffix=.actual", - test_dir+"sequence_text.mmd", + var args = [ '--png', + '--outputDir=' + test_dir, + '--outputSuffix=.actual', + test_dir+'sequence_text.mmd' ] - exec_mermaid(args.join(" "), - function(error, stdout, stderr) { + exec_mermaid(args.join(' '), function(error, stdout, stderr) { t.notOk(stderr, 'no error') t.end() }); @@ -89,13 +81,12 @@ test('sequence png', function(t) { test('flowchart svg text', function(t) { t.plan(1); - var args = [ "--svg", - "--outputDir=" + test_dir, - "--outputSuffix=.actual", - test_dir+"flowchart_text.mmd", + var args = [ '--svg', + '--outputDir=' + test_dir, + '--outputSuffix=.actual', + test_dir+'flowchart_text.mmd' ] - exec_mermaid(args.join(" "), - function(error, stdout, stderr) { + exec_mermaid(args.join(' '), function(error, stdout, stderr) { t.notOk(stderr, 'no error') t.end() });