Create helper function for subgraph title margin fetching.
This commit is contained in:
parent
b134766647
commit
0bcd5d28e8
|
@ -1,5 +1,7 @@
|
|||
import { vi } from 'vitest';
|
||||
import utils, { calculatePoint, cleanAndMerge, detectDirective } from './utils.js';
|
||||
import { getSubGraphTitleMargins } from './utils/getSubGraphTitleMargins.js';
|
||||
import * as configApi from './config.js';
|
||||
import assignWithDepth from './assignWithDepth.js';
|
||||
import { detectType } from './diagram-api/detectType.js';
|
||||
import { addDiagrams } from './diagram-api/diagram-orchestration.js';
|
||||
|
@ -593,4 +595,24 @@ describe('calculatePoint', () => {
|
|||
'Could not find a suitable point for the given distance'
|
||||
);
|
||||
});
|
||||
|
||||
describe('getSubGraphTitleMargins', () => {
|
||||
it('should get subgraph title margins after config has been set', () => {
|
||||
const config_0 = {
|
||||
flowchart: {
|
||||
subGraphTitleMargin: {
|
||||
top: 10,
|
||||
bottom: 5,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
configApi.setSiteConfig(config_0);
|
||||
expect(getSubGraphTitleMargins()).toEqual({
|
||||
subGraphTitleTopMargin: 10,
|
||||
subGraphTitleBottomMargin: 5,
|
||||
subGraphTitleTotalMargin: 15,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
import { getConfig } from '../diagram-api/diagramAPI.js';
|
||||
|
||||
export const getSubGraphTitleMargins = (): {
|
||||
subGraphTitleTopMargin: number;
|
||||
subGraphTitleBottomMargin: number;
|
||||
subGraphTitleTotalMargin: number;
|
||||
} => {
|
||||
const subGraphTitleTopMargin = getConfig().flowchart?.subGraphTitleMargin?.top || 0;
|
||||
const subGraphTitleBottomMargin = getConfig().flowchart?.subGraphTitleMargin?.bottom || 0;
|
||||
const subGraphTitleTotalMargin = subGraphTitleTopMargin + subGraphTitleBottomMargin;
|
||||
|
||||
return {
|
||||
subGraphTitleTopMargin,
|
||||
subGraphTitleBottomMargin,
|
||||
subGraphTitleTotalMargin,
|
||||
};
|
||||
};
|
Loading…
Reference in New Issue