add tests

This commit is contained in:
whyzdev
2016-12-18 22:52:41 -05:00
parent b73698849d
commit 0ecbbf8ddf
3 changed files with 49 additions and 6 deletions

1
.gitignore vendored
View File

@@ -10,3 +10,4 @@ bower_components
coverage coverage
test/tmp_* test/tmp_*
test/fixtures/samples/*.actual.*

View File

@@ -8,7 +8,9 @@ var fs = require('fs')
, clone = require('clone') , clone = require('clone')
, rimraf = require('rimraf') , 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) { function exec_mermaid(args, verify) {
exec('bin/mermaid.js ' + args, exec('bin/mermaid.js ' + args,
@@ -24,26 +26,64 @@ test('mermaid cli help', function(t) {
var args = [ "--help", ] var args = [ "--help", ]
exec_mermaid(args.join(" "), exec_mermaid(args.join(" "),
function(error, stdout, stderr) { function(error, stdout, stderr) {
t.notOk(error, 'no error code') t.notOk(error, 'no error')
t.end() 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) { test('sequence svg text placelment: '+textPlacement, function(t) {
t.plan(1); t.plan(1);
var args = [ "--svg", var args = [ "--svg",
"--outputDir=" + test_dir, "--outputDir=" + test_dir,
textPlacement===undefined ? "" : "--outputSuffix=_"+textPlacement, "--outputSuffix="+(textPlacement ? "_"+textPlacement : "")+".actual",
textPlacement===undefined ? "" : "--sequenceConfig="+test_dir+path.sep+"sequence_text_"+textPlacement+".cfg", textPlacement ? "--sequenceConfig="+test_dir+"sequence_text_"+textPlacement+".cfg" : "",
test_dir+"sequence_text.mmd", test_dir+"sequence_text.mmd",
] ]
exec_mermaid(args.join(" "), exec_mermaid(args.join(" "),
function(error, stdout, stderr) { function(error, stdout, stderr) {
t.notOk(error, 'no error code') t.notOk(stderr, 'no error')
t.end() 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()
});
})

View File

@@ -0,0 +1,2 @@
sequenceDiagram
bad