mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-21 06:53:17 +08:00
217bd1f4bf
Updated config to match a conversation knut and i had about the relationship between global, site, and integrator configuration (Will update docs) Renamed wrapEnabled to wrap Poor man's caching for calculateTextDimensions, wrapLabel, and breakString (actually makes a huge difference)
53 lines
2.0 KiB
JavaScript
53 lines
2.0 KiB
JavaScript
/* eslint-env jasmine */
|
|
import configApi from './config';
|
|
|
|
describe('when working with site config', function() {
|
|
beforeEach(() => {
|
|
configApi.reset(configApi.defaultConfig);
|
|
});
|
|
it('should set site config and config properly', function() {
|
|
let config_0 = { foo: 'bar', bar: 0 };
|
|
configApi.setSiteConfig(config_0);
|
|
let config_1 = configApi.getSiteConfig();
|
|
let config_2 = configApi.getConfig();
|
|
expect(config_1.foo).toEqual(config_0.foo);
|
|
expect(config_1.bar).toEqual(config_0.bar);
|
|
expect(config_1).toEqual(config_2);
|
|
});
|
|
it('should set config and respect secure keys', function() {
|
|
let config_0 = { foo: 'bar', bar: 0, secure: [...configApi.defaultConfig.secure, 'bar'] };
|
|
configApi.setSiteConfig(config_0);
|
|
let config_1 = { foo: 'baf', bar: 'foo'};
|
|
configApi.setConfig(config_1);
|
|
let config_2 = configApi.getConfig();
|
|
expect(config_2.foo).toEqual(config_1.foo);
|
|
expect(config_2.bar).toEqual(0); // Should be siteConfig.bar
|
|
});
|
|
it('should set reset config properly', function() {
|
|
let config_0 = { foo: 'bar', bar: 0};
|
|
configApi.setSiteConfig(config_0);
|
|
let config_1 = { foo: 'baf'};
|
|
configApi.setConfig(config_1);
|
|
let config_2 = configApi.getConfig();
|
|
expect(config_2.foo).toEqual(config_1.foo);
|
|
configApi.reset();
|
|
let config_3 = configApi.getConfig();
|
|
expect(config_3.foo).toEqual(config_0.foo);
|
|
let config_4 = configApi.getSiteConfig();
|
|
expect(config_4.foo).toEqual(config_0.foo);
|
|
});
|
|
it('should set global reset config properly', function() {
|
|
let config_0 = { foo: 'bar', bar: 0};
|
|
configApi.setSiteConfig(config_0);
|
|
let config_1 = configApi.getSiteConfig();
|
|
expect(config_1.foo).toEqual(config_0.foo);
|
|
let config_2 = configApi.getConfig();
|
|
expect(config_2.foo).toEqual(config_0.foo);
|
|
configApi.reset(configApi.defaultConfig);
|
|
let config_3 = configApi.getSiteConfig();
|
|
expect(config_3.foo).toBeUndefined();
|
|
let config_4 = configApi.getConfig();
|
|
expect(config_4.foo).toBeUndefined();
|
|
});
|
|
});
|