Refactor code

This commit is contained in:
Tyler Long
2017-04-16 23:08:37 +08:00
parent 6a7a5b9249
commit 110e4ee586
5 changed files with 27 additions and 101 deletions

View File

@@ -5,40 +5,20 @@
/**
* Created by knut on 14-11-23.
*/
// var rewire = require('rewire');
var mermaid = require('./mermaid')
// var log = require('./logger').create();
describe('when using mermaid and ', function () {
describe('when detecting chart type ', function () {
// var mermaid;
// var document;
// var window;
beforeEach(function () {
// var MockBrowser = require('mock-browser').mocks.MockBrowser;
// var mock = new MockBrowser();
//
// delete global.mermaid_config;
//
/// / and in the run-code inside some object
// global.document = mock.getDocument();
// global.window = mock.getWindow();
})
it('should not start rendering with mermaid_config.startOnLoad set to false', function () {
// mermaid = rewire('./mermaid');
global.mermaid_config = {startOnLoad: false}
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'
spyOn(global.mermaid, 'init')
// log.debug(mermaid);
mermaid.contentLoaded()
expect(global.mermaid.init).not.toHaveBeenCalled()
})
it('should not start rendering with mermaid.startOnLoad set to false', function () {
// mermaid = rewire('./mermaid');
global.mermaid.startOnLoad = false
global.mermaid_config = {startOnLoad: true}
@@ -49,7 +29,6 @@ describe('when using mermaid and ', function () {
})
it('should start rendering with both startOnLoad set', function () {
// mermaid = rewire('./mermaid');
global.mermaid.startOnLoad = true
global.mermaid_config = {startOnLoad: true}
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'
@@ -59,7 +38,6 @@ describe('when using mermaid and ', function () {
})
it('should start rendering with mermaid.startOnLoad set and no mermaid_config defined', function () {
// mermaid = rewire('./mermaid');
global.mermaid.startOnLoad = true
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'
spyOn(global.mermaid, 'init')
@@ -68,7 +46,6 @@ describe('when using mermaid and ', function () {
})
it('should start rendering as a default with no changes performed', function () {
// mermaid = rewire('./mermaid');
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'
spyOn(global.mermaid, 'init')
mermaid.contentLoaded()
@@ -83,12 +60,8 @@ describe('when using mermaid and ', function () {
beforeEach(function () {
global.mermaid_config = {startOnLoad: false}
// var MockBrowser = require('mock-browser').mocks.MockBrowser;
// var mock = new MockBrowser();
flow.parser.yy = graph
graph.clear()
// global.document = mock.getDocument();
// mermaid = rewire('./mermaid');
})
it('it should handle edges with text', function () {
flow.parser.parse('graph TD;A-->|text ex|B;')