mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-31 22:26:53 +02:00
add tests
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,3 +10,4 @@ bower_components
|
||||
coverage
|
||||
|
||||
test/tmp_*
|
||||
test/fixtures/samples/*.actual.*
|
||||
|
@@ -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()
|
||||
});
|
||||
})
|
||||
|
||||
|
2
test/fixtures/samples/sequence_err.mmd
vendored
Normal file
2
test/fixtures/samples/sequence_err.mmd
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
sequenceDiagram
|
||||
bad
|
Reference in New Issue
Block a user