mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-05 16:46:43 +02:00
add tests
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,3 +10,4 @@ bower_components
|
|||||||
coverage
|
coverage
|
||||||
|
|
||||||
test/tmp_*
|
test/tmp_*
|
||||||
|
test/fixtures/samples/*.actual.*
|
||||||
|
@@ -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()
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
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