mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-21 08:19:43 +02:00
fix: ensure configs from initialize and frontmatter are both handled correctly
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
@@ -82,6 +82,7 @@ describe('when working with site config', () => {
|
|||||||
describe('getUserDefinedConfig', () => {
|
describe('getUserDefinedConfig', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
configApi.reset();
|
configApi.reset();
|
||||||
|
configApi.saveConfigFromInitialize({});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return empty object when no user config is defined', () => {
|
it('should return empty object when no user config is defined', () => {
|
||||||
@@ -106,7 +107,6 @@ describe('getUserDefinedConfig', () => {
|
|||||||
|
|
||||||
expect(configApi.getUserDefinedConfig()).toMatchInlineSnapshot(`
|
expect(configApi.getUserDefinedConfig()).toMatchInlineSnapshot(`
|
||||||
{
|
{
|
||||||
"fontFamily": "Arial",
|
|
||||||
"fontSize": 14,
|
"fontSize": 14,
|
||||||
"layout": "elk",
|
"layout": "elk",
|
||||||
"theme": "forest",
|
"theme": "forest",
|
||||||
@@ -128,8 +128,8 @@ describe('getUserDefinedConfig', () => {
|
|||||||
{
|
{
|
||||||
"fontFamily": "Arial",
|
"fontFamily": "Arial",
|
||||||
"fontSize": 14,
|
"fontSize": 14,
|
||||||
"layout": "elk",
|
"layout": "dagre",
|
||||||
"theme": "forest",
|
"theme": "dark",
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
@@ -152,7 +152,7 @@ describe('getUserDefinedConfig', () => {
|
|||||||
{
|
{
|
||||||
"flowchart": {
|
"flowchart": {
|
||||||
"curve": "basis",
|
"curve": "basis",
|
||||||
"nodeSpacing": 75,
|
"nodeSpacing": 50,
|
||||||
"rankSpacing": 100,
|
"rankSpacing": 100,
|
||||||
},
|
},
|
||||||
"mindmap": {
|
"mindmap": {
|
||||||
@@ -196,8 +196,8 @@ describe('getUserDefinedConfig', () => {
|
|||||||
expect(userConfig).toMatchInlineSnapshot(`
|
expect(userConfig).toMatchInlineSnapshot(`
|
||||||
{
|
{
|
||||||
"flowchart": {
|
"flowchart": {
|
||||||
"curve": "basis",
|
"curve": "linear",
|
||||||
"nodeSpacing": 100,
|
"nodeSpacing": 50,
|
||||||
"rankSpacing": 100,
|
"rankSpacing": 100,
|
||||||
},
|
},
|
||||||
"fontSize": 12,
|
"fontSize": 12,
|
||||||
|
@@ -252,13 +252,13 @@ const checkConfig = (config: MermaidConfig) => {
|
|||||||
export const getUserDefinedConfig = (): MermaidConfig => {
|
export const getUserDefinedConfig = (): MermaidConfig => {
|
||||||
let userConfig: MermaidConfig = {};
|
let userConfig: MermaidConfig = {};
|
||||||
|
|
||||||
if (configFromInitialize) {
|
|
||||||
userConfig = assignWithDepth(userConfig, configFromInitialize);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const d of directives) {
|
for (const d of directives) {
|
||||||
userConfig = assignWithDepth(userConfig, d);
|
userConfig = assignWithDepth(userConfig, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (configFromInitialize) {
|
||||||
|
userConfig = assignWithDepth(userConfig, configFromInitialize);
|
||||||
|
}
|
||||||
|
|
||||||
return userConfig;
|
return userConfig;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user