From d63934637f0ce92c56175d6cf4cfb8020cdc63e0 Mon Sep 17 00:00:00 2001 From: whyzdev Date: Sun, 1 Jan 2017 23:36:42 -0500 Subject: [PATCH] remove dups --- test/cli_test-samples.js | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/test/cli_test-samples.js b/test/cli_test-samples.js index 043a8145d..8e18d31ac 100644 --- a/test/cli_test-samples.js +++ b/test/cli_test-samples.js @@ -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' rimraf.sync(test_dir+'*.actual.*'); - + +function prepend_output_args(args) { + return '--outputDir=' + test_dir + ' --outputSuffix=.actual' + args +} + 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}}, function(error, stdout, 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) { var cmd = (phantomjs + ' ' + load_html_save_screenshot_png_scripts + ' ' + html + ' ' + html + '.actual.png'); - console.log(cmd) + console.log('cmd: ', cmd) exec(cmd, {env: {PATH: './node_modules/.bin'+path.delimiter+process.env.PATH}}, function(error, stdout, stderr) { @@ -58,15 +64,12 @@ test('mermaid cli help', function(t) { exec_mermaid(args.join(' '), verify_error(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' ] - exec_mermaid(args.join(' '), verify_error(t)); + exec_mermaid(prepend_output_args(args.join(' ')), verify_no_error(t)); }); ['', 'fo', 'tspan', 'old'].forEach(function(textPlacement) { @@ -85,62 +88,52 @@ 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' ] - 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) { t.plan(1); var args = [ '--svg', - '--outputDir=' + test_dir, - '--outputSuffix=.actual', '--css=dist/mermaid.css', '--width=500', 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) { test('flowchart '+format+'text2', function(t) { t.plan(1); var args = [ '--'+format, - '--outputDir=' + test_dir, - '--outputSuffix=.actual', '--css=dist/mermaid.forest.css', '--width=500', 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) { t.plan(1); var args = [ '--svg', - '--outputDir=' + test_dir, - '--outputSuffix=.actual', '--css=dist/mermaid.css', '--width=500', '--ganttConfig='+test_dir+'gantt_axis_formatter.cfg', 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) { t.plan(1); - var args = [ '-s', "-v", - '--outputDir=' + test_dir, - '--outputSuffix=.actual', + var args = [ '-s', '-v', '--width=500', 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) {