mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-17 06:20:07 +02:00
Auto fix standard style voilations
This commit is contained in:
@@ -4,71 +4,69 @@
|
||||
/**
|
||||
* Created by knut on 14-11-23.
|
||||
*/
|
||||
var api = require('./mermaidAPI.js');
|
||||
//var log = require('./logger').create();
|
||||
var api = require('./mermaidAPI.js')
|
||||
// var log = require('./logger').create();
|
||||
|
||||
describe('when using mermaidAPI and ',function() {
|
||||
describe('doing initialize ',function() {
|
||||
//var main;
|
||||
//var document;
|
||||
//var window;
|
||||
beforeEach(function () {
|
||||
//var MockBrowser = require('mock-browser').mocks.MockBrowser;
|
||||
//var mock = new MockBrowser();
|
||||
describe('when using mermaidAPI and ', function () {
|
||||
describe('doing initialize ', function () {
|
||||
// var main;
|
||||
// var document;
|
||||
// var window;
|
||||
beforeEach(function () {
|
||||
// var MockBrowser = require('mock-browser').mocks.MockBrowser;
|
||||
// var mock = new MockBrowser();
|
||||
|
||||
delete global.mermaid_config;
|
||||
delete global.mermaid_config
|
||||
|
||||
// and in the run-code inside some object
|
||||
//global.document = mock.getDocument();
|
||||
//global.window = mock.getWindow();
|
||||
document.body.innerHTML = '';
|
||||
});
|
||||
// global.document = mock.getDocument();
|
||||
// global.window = mock.getWindow();
|
||||
document.body.innerHTML = ''
|
||||
})
|
||||
|
||||
it('should copy a literal into the configuration', function () {
|
||||
var orgConfig = api.getConfig();
|
||||
expect(orgConfig.testLiteral).toBe(undefined);
|
||||
it('should copy a literal into the configuration', function () {
|
||||
var orgConfig = api.getConfig()
|
||||
expect(orgConfig.testLiteral).toBe(undefined)
|
||||
|
||||
api.initialize({'testLiteral':true});
|
||||
var config = api.getConfig();
|
||||
api.initialize({'testLiteral': true})
|
||||
var config = api.getConfig()
|
||||
|
||||
expect(config.testLiteral).toBe(true);
|
||||
});
|
||||
it('should copy a an object into the configuration', function () {
|
||||
var orgConfig = api.getConfig();
|
||||
expect(orgConfig.testObject).toBe(undefined);
|
||||
expect(config.testLiteral).toBe(true)
|
||||
})
|
||||
it('should copy a an object into the configuration', function () {
|
||||
var orgConfig = api.getConfig()
|
||||
expect(orgConfig.testObject).toBe(undefined)
|
||||
|
||||
|
||||
var object = {
|
||||
test1:1,
|
||||
test2:false
|
||||
};
|
||||
|
||||
api.initialize({'testObject':object});
|
||||
api.initialize({'testObject':{'test3':true}});
|
||||
var config = api.getConfig();
|
||||
var object = {
|
||||
test1: 1,
|
||||
test2: false
|
||||
}
|
||||
|
||||
expect(config.testObject.test1).toBe(1);
|
||||
expect(config.testObject.test2).toBe(false);
|
||||
expect(config.testObject.test3).toBe(true);
|
||||
expect(config.cloneCssStyles).toBe(orgConfig.cloneCssStyles);
|
||||
});
|
||||
api.initialize({'testObject': object})
|
||||
api.initialize({'testObject': {'test3': true}})
|
||||
var config = api.getConfig()
|
||||
|
||||
});
|
||||
describe('checking validity of input ', function(){
|
||||
it('it should return false for an invalid definiton',function(){
|
||||
global.mermaidAPI.parseError= function(){};
|
||||
spyOn(global.mermaidAPI,'parseError');
|
||||
var res = api.parse('this is not a mermaid diagram definition');
|
||||
expect(config.testObject.test1).toBe(1)
|
||||
expect(config.testObject.test2).toBe(false)
|
||||
expect(config.testObject.test3).toBe(true)
|
||||
expect(config.cloneCssStyles).toBe(orgConfig.cloneCssStyles)
|
||||
})
|
||||
})
|
||||
describe('checking validity of input ', function () {
|
||||
it('it should return false for an invalid definiton', function () {
|
||||
global.mermaidAPI.parseError = function () {}
|
||||
spyOn(global.mermaidAPI, 'parseError')
|
||||
var res = api.parse('this is not a mermaid diagram definition')
|
||||
|
||||
expect(res).toBe(false);
|
||||
expect(global.mermaidAPI.parseError).toHaveBeenCalled();
|
||||
});
|
||||
it('it should return true for a valid definiton',function(){
|
||||
spyOn(global.mermaidAPI,'parseError');
|
||||
var res = api.parse('graph TD;A--x|text including URL space|B;');
|
||||
expect(res).toBe(false)
|
||||
expect(global.mermaidAPI.parseError).toHaveBeenCalled()
|
||||
})
|
||||
it('it should return true for a valid definiton', function () {
|
||||
spyOn(global.mermaidAPI, 'parseError')
|
||||
var res = api.parse('graph TD;A--x|text including URL space|B;')
|
||||
|
||||
expect(res).toBe(true);
|
||||
expect(global.mermaidAPI.parseError).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
expect(res).toBe(true)
|
||||
expect(global.mermaidAPI.parseError).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user