remove dups

This commit is contained in:
whyzdev
2017-01-01 23:36:42 -05:00
parent 256c529de8
commit d63934637f

View File

@@ -10,9 +10,15 @@ var phantomjs = 'node_modules/.bin/phantomjs '.replace('/',path.sep)
var load_html_save_screenshot_png_scripts = test_dir+path.sep+'load_html_save_screenshot_png.phantomjs' var load_html_save_screenshot_png_scripts = test_dir+path.sep+'load_html_save_screenshot_png.phantomjs'
rimraf.sync(test_dir+'*.actual.*'); rimraf.sync(test_dir+'*.actual.*');
function prepend_output_args(args) {
return '--outputDir=' + test_dir + ' --outputSuffix=.actual' + args
}
function exec_mermaid(args, verify) { function exec_mermaid(args, verify) {
exec('bin/mermaid.js ' + args, var cmd = 'bin/mermaid.js ' + args
console.log('cmd: ', cmd)
exec(cmd,
{env: {PATH: './node_modules/.bin'+path.delimiter+process.env.PATH}}, {env: {PATH: './node_modules/.bin'+path.delimiter+process.env.PATH}},
function(error, stdout, stderr) { function(error, stdout, stderr) {
console.log('error:',error,'\nstdout:\n',stdout,'\nstderr:\n',stderr); console.log('error:',error,'\nstdout:\n',stdout,'\nstderr:\n',stderr);
@@ -23,7 +29,7 @@ function exec_mermaid(args, verify) {
function exec_phantomjs_to_load_html_save_screenshot_png(html, verify) { function exec_phantomjs_to_load_html_save_screenshot_png(html, verify) {
var cmd = (phantomjs + ' ' + load_html_save_screenshot_png_scripts + var cmd = (phantomjs + ' ' + load_html_save_screenshot_png_scripts +
' ' + html + ' ' + html + '.actual.png'); ' ' + html + ' ' + html + '.actual.png');
console.log(cmd) console.log('cmd: ', cmd)
exec(cmd, exec(cmd,
{env: {PATH: './node_modules/.bin'+path.delimiter+process.env.PATH}}, {env: {PATH: './node_modules/.bin'+path.delimiter+process.env.PATH}},
function(error, stdout, stderr) { function(error, stdout, stderr) {
@@ -58,15 +64,12 @@ test('mermaid cli help', function(t) {
exec_mermaid(args.join(' '), verify_error(t)); exec_mermaid(args.join(' '), verify_error(t));
}); });
//todo
test.skip('sequence syntax error', function(t) { test.skip('sequence syntax error', function(t) {
t.plan(1); t.plan(1);
var args = [ '--svg', var args = [ '--svg',
'--outputDir=' + test_dir,
'--outputSuffix=.actual',
test_dir+'sequence_err.mmd' test_dir+'sequence_err.mmd'
] ]
exec_mermaid(args.join(' '), verify_error(t)); exec_mermaid(prepend_output_args(args.join(' ')), verify_no_error(t));
}); });
['', 'fo', 'tspan', 'old'].forEach(function(textPlacement) { ['', 'fo', 'tspan', 'old'].forEach(function(textPlacement) {
@@ -85,62 +88,52 @@ test.skip('sequence syntax error', function(t) {
test('sequence png', function(t) { test('sequence png', function(t) {
t.plan(1); t.plan(1);
var args = [ '--png', var args = [ '--png',
'--outputDir=' + test_dir,
'--outputSuffix=.actual',
test_dir+'sequence_text.mmd' test_dir+'sequence_text.mmd'
] ]
exec_mermaid(args.join(' '), verify_no_error(t)); exec_mermaid(prepend_output_args(args.join(' ')), verify_no_error(t));
}); });
test('flowchart svg text', function(t) { test('flowchart svg text', function(t) {
t.plan(1); t.plan(1);
var args = [ '--svg', var args = [ '--svg',
'--outputDir=' + test_dir,
'--outputSuffix=.actual',
'--css=dist/mermaid.css', '--css=dist/mermaid.css',
'--width=500', '--width=500',
test_dir+'flowchart_text.mmd' test_dir+'flowchart_text.mmd'
] ]
exec_mermaid(args.join(' '), verify_no_error(t)); exec_mermaid(prepend_output_args(args.join(' ')), verify_no_error(t));
}); });
['svg', 'png'].forEach(function(format) { ['svg', 'png'].forEach(function(format) {
test('flowchart '+format+'text2', function(t) { test('flowchart '+format+'text2', function(t) {
t.plan(1); t.plan(1);
var args = [ '--'+format, var args = [ '--'+format,
'--outputDir=' + test_dir,
'--outputSuffix=.actual',
'--css=dist/mermaid.forest.css', '--css=dist/mermaid.forest.css',
'--width=500', '--width=500',
test_dir+'flowchart_text2.mmd' test_dir+'flowchart_text2.mmd'
] ]
exec_mermaid(args.join(' '), verify_no_error(t)); exec_mermaid(prepend_output_args(args.join(' ')), verify_no_error(t));
}) }); }) });
test('gantt axis formatter svg', function(t) { test('gantt axis formatter svg', function(t) {
t.plan(1); t.plan(1);
var args = [ '--svg', var args = [ '--svg',
'--outputDir=' + test_dir,
'--outputSuffix=.actual',
'--css=dist/mermaid.css', '--css=dist/mermaid.css',
'--width=500', '--width=500',
'--ganttConfig='+test_dir+'gantt_axis_formatter.cfg', '--ganttConfig='+test_dir+'gantt_axis_formatter.cfg',
test_dir+'gantt_axis_formatter.mmd' test_dir+'gantt_axis_formatter.mmd'
] ]
exec_mermaid(args.join(' '), verify_no_error(t)); exec_mermaid(prepend_output_args(args.join(' ')), verify_no_error(t));
}); });
test('gitgraph sample svg', function(t) { test('gitgraph sample svg', function(t) {
t.plan(1); t.plan(1);
var args = [ '-s', "-v", var args = [ '-s', '-v',
'--outputDir=' + test_dir,
'--outputSuffix=.actual',
'--width=500', '--width=500',
test_dir+'gitgraph.mmd' test_dir+'gitgraph.mmd'
] ]
exec_mermaid(args.join(' '), verify_no_error(t)); exec_mermaid(prepend_output_args(args.join(' ')), verify_no_error(t));
}); });
test('load sample.html in phantomjs and save screenshot png', function(t) { test('load sample.html in phantomjs and save screenshot png', function(t) {