2014-11-27 18:21:15 +01:00
|
|
|
/**
|
|
|
|
* Created by knut on 14-11-26.
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* Created by knut on 14-11-23.
|
|
|
|
*/
|
|
|
|
var rewire = require("rewire");
|
|
|
|
var utils = require("./utils");
|
|
|
|
|
2014-11-28 18:08:36 +01:00
|
|
|
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();
|
2014-11-27 18:21:15 +01:00
|
|
|
|
2014-11-28 18:08:36 +01:00
|
|
|
// and in the run-code inside some object
|
|
|
|
document = mock.getDocument();
|
2014-11-27 18:21:15 +01:00
|
|
|
|
|
|
|
|
2014-11-28 18:08:36 +01:00
|
|
|
});
|
|
|
|
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');
|
2014-11-27 18:21:15 +01:00
|
|
|
|
2014-11-28 18:08:36 +01:00
|
|
|
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();
|
|
|
|
});
|
2014-11-27 18:21:15 +01:00
|
|
|
|
|
|
|
});
|
2014-11-28 18:08:36 +01:00
|
|
|
|
|
|
|
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();
|
|
|
|
});
|
|
|
|
|
2014-11-27 18:21:15 +01:00
|
|
|
});
|
|
|
|
});
|