mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 14:59:53 +02:00
resolved PR comments
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
@@ -102,7 +102,7 @@ const populateBlockDatabase = (_blockList: Block[], parent: Block): void => {
|
||||
typeof block.widthInColumns === 'number' &&
|
||||
block.widthInColumns > column
|
||||
) {
|
||||
throw new Error(
|
||||
log.warn(
|
||||
`Block ${block.id} width ${block.widthInColumns} exceeds configured column width ${column}`
|
||||
);
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
// @ts-ignore: jison doesn't export types
|
||||
import block from './block.jison';
|
||||
import db from '../blockDB.js';
|
||||
import { log } from '../../../logger.js';
|
||||
|
||||
describe('Block diagram', function () {
|
||||
describe('when parsing a block diagram graph it should handle > ', function () {
|
||||
@@ -402,20 +403,24 @@ columns 1
|
||||
const B = blocks[0];
|
||||
expect(B.styles).toContain('fill:#f9F');
|
||||
});
|
||||
it('should throw error when block width exceeds column width', () => {
|
||||
it('should log a warning when block width exceeds column width', () => {
|
||||
const str = `block-beta
|
||||
columns 1
|
||||
A:1
|
||||
B:2
|
||||
C:3
|
||||
D:4
|
||||
E:3
|
||||
F:2
|
||||
G:1`;
|
||||
columns 1
|
||||
A:1
|
||||
B:2
|
||||
C:3
|
||||
D:4
|
||||
E:3
|
||||
F:2
|
||||
G:1`;
|
||||
|
||||
expect(() => block.parse(str)).toThrowError(
|
||||
'Block B width 2 exceeds configured column width 1'
|
||||
);
|
||||
const logWarnSpy = vi.spyOn(log, 'warn').mockImplementation(() => undefined);
|
||||
|
||||
block.parse(str);
|
||||
|
||||
expect(logWarnSpy).toHaveBeenCalledWith('Block B width 2 exceeds configured column width 1');
|
||||
|
||||
logWarnSpy.mockRestore();
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user