diff --git a/.gitignore b/.gitignore index 383d087d4..145aed740 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 a0eafc0b5..0c0253fb4 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 000000000..fe2e16f20 --- /dev/null +++ b/test/fixtures/samples/sequence_err.mmd @@ -0,0 +1,2 @@ +sequenceDiagram + bad