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
test/tmp_*
test/fixtures/samples/*.actual.*

View File

@@ -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()
});
})

View File

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