Release 0.2.6

* Default shape set to rect when none is set
This commit is contained in:
knsv 2014-11-28 18:08:36 +01:00
parent 9a35844731
commit 0c87128902
8 changed files with 77 additions and 44 deletions

View File

@ -1,6 +1,6 @@
{
"name": "mermaid",
"version": "0.2.5",
"version": "0.2.6",
"authors": [
"knsv <knut@sveido.com>"
],

View File

@ -712,7 +712,7 @@ var addVertices = function (vert, g) {
style = styleFromStyleArr(style, vertice.styles);
// Use vertice id as text in the box if no text is provided by the graph definition
if (vertice.text === undefined) {
if (typeof vertice.text === 'undefined') {
verticeText = vertice.id;
}
else {
@ -740,8 +740,9 @@ var addVertices = function (vert, g) {
case 'circle':
_shape = 'circle';
break;
default:
_shape = 'rect';
}
// Add the node
g.setNode(vertice.id, {labelType: "html",shape:_shape, label: verticeText, rx: radious, ry: radious, style: style, id:vertice.id});
});
@ -958,12 +959,14 @@ var init = function () {
};
exports.tester = function(){};
/**
* Version management
* @returns {string}
*/
exports.version = function(){
return '0.2.5';
return '0.2.6';
};
var equals = function (val, variable){

File diff suppressed because one or more lines are too long

View File

@ -680,7 +680,7 @@ var addVertices = function (vert, g) {
style = styleFromStyleArr(style, vertice.styles);
// Use vertice id as text in the box if no text is provided by the graph definition
if (vertice.text === undefined) {
if (typeof vertice.text === 'undefined') {
verticeText = vertice.id;
}
else {
@ -708,8 +708,9 @@ var addVertices = function (vert, g) {
case 'circle':
_shape = 'circle';
break;
default:
_shape = 'rect';
}
// Add the node
g.setNode(vertice.id, {labelType: "html",shape:_shape, label: verticeText, rx: radious, ry: radious, style: style, id:vertice.id});
});
@ -926,12 +927,14 @@ var init = function () {
};
exports.tester = function(){};
/**
* Version management
* @returns {string}
*/
exports.version = function(){
return '0.2.5';
return '0.2.6';
};
var equals = function (val, variable){

File diff suppressed because one or more lines are too long

View File

@ -50,7 +50,7 @@ var addVertices = function (vert, g) {
style = styleFromStyleArr(style, vertice.styles);
// Use vertice id as text in the box if no text is provided by the graph definition
if (vertice.text === undefined) {
if (typeof vertice.text === 'undefined') {
verticeText = vertice.id;
}
else {
@ -78,8 +78,9 @@ var addVertices = function (vert, g) {
case 'circle':
_shape = 'circle';
break;
default:
_shape = 'rect';
}
// Add the node
g.setNode(vertice.id, {labelType: "html",shape:_shape, label: verticeText, rx: radious, ry: radious, style: style, id:vertice.id});
});
@ -296,12 +297,14 @@ var init = function () {
};
exports.tester = function(){};
/**
* Version management
* @returns {string}
*/
exports.version = function(){
return '0.2.5';
return '0.2.6';
};
var equals = function (val, variable){

View File

@ -7,38 +7,62 @@
var rewire = require("rewire");
var utils = require("./utils");
describe('when detecting chart type ',function() {
var main;
beforeEach(function () {
var MockBrowser = require('mock-browser').mocks.MockBrowser;
var mock = new MockBrowser();
describe('when using main and ',function() {
describe('when detecting chart type ',function() {
var main;
beforeEach(function () {
var MockBrowser = require('mock-browser').mocks.MockBrowser;
var mock = new MockBrowser();
// and in the run-code inside some object
document = mock.getDocument();
// and in the run-code inside some object
document = mock.getDocument();
});
it('should have a version', function () {
div = document.createElement('div');
mermaid_config ={startOnLoad : false};
main = rewire('./main');
expect(main.version()).toBe('0.2.6');
});
it('should not call start anything with an empty document', function () {
mermaid_config ={startOnLoad : false};
main = rewire('./main');
spyOn(utils,'detectType');
expect(utils.detectType).not.toHaveBeenCalled();
});
it('should start something with a mermaid document', function () {
mermaid_config ={startOnLoad : false};
main = rewire('./main');
document.body.innerHTML = '<div class="mermaid"></div>';
spyOn(utils,'detectType');
mermaid.init();
expect(utils.detectType).toHaveBeenCalled();
});
});
it('should have a version', function () {
div = document.createElement('div');
mermaid_config ={startOnLoad : false};
main = rewire('./main');
expect(main.version()).toBe('0.2.5');
});
it('should not call start anything with an empty document', function () {
mermaid_config ={startOnLoad : false};
main = rewire('./main');
xdescribe('when calling addEdges ',function() {
var main;
beforeEach(function () {
main = rewire('./main');
});
it('should have a version', function () {
var edge = {start: 'start', end: 'end', type: 'arrow', text: 'test text'};
var edges = [edge];
var mockG = {
setEdge:function(start, end,options,name){}
};
spyOn(mockG,'setEdge');
main.__set__('exports.apa',function(a,b){
addEdges(a,b);
});
main.apa(edges,mockG);
expect(mockG.setEdge).toHaveBeenCalled();
});
spyOn(utils,'detectType');
expect(utils.detectType).not.toHaveBeenCalled();
});
it('should start something with a mermaid document', function () {
mermaid_config ={startOnLoad : false};
main = rewire('./main');
document.body.innerHTML = '<div class="mermaid"></div>';
spyOn(utils,'detectType');
mermaid.init();
expect(utils.detectType).toHaveBeenCalled();
});
});

View File

@ -34,19 +34,19 @@
E-->I[Ingvild];
click A apa;
</div>
<div class="mermaid">
<div class="mermaid2">
graph TD;
id1>This is the text in the box];
</div>
<h1>Shapes</h1>
<div class="mermaidw">
<div class="mermaid">
graph TD;
sq[Square shape]-->ci((Circle shape));
od>Odd shape]---|Two line<br>edge comment|ro;
od2>Really long text in an Odd shape]-->od3>Really long text with linebreak<br>in an Odd shape];
di{Diamond is <br/> broken}-->ro(Rounded<br>square<br>shape);
di-->ro2(Rounded square shape);
e((Inner circle));
e((Inner circle))-->f;
style e red;
</div>