resolved PR comments

on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
darshanr0107
2025-07-17 20:11:21 +05:30
parent 8b86d617e7
commit 54640ce476
2 changed files with 18 additions and 13 deletions

View File

@@ -102,7 +102,7 @@ const populateBlockDatabase = (_blockList: Block[], parent: Block): void => {
typeof block.widthInColumns === 'number' && typeof block.widthInColumns === 'number' &&
block.widthInColumns > column block.widthInColumns > column
) { ) {
throw new Error( log.warn(
`Block ${block.id} width ${block.widthInColumns} exceeds configured column width ${column}` `Block ${block.id} width ${block.widthInColumns} exceeds configured column width ${column}`
); );
} }

View File

@@ -1,6 +1,7 @@
// @ts-ignore: jison doesn't export types // @ts-ignore: jison doesn't export types
import block from './block.jison'; import block from './block.jison';
import db from '../blockDB.js'; import db from '../blockDB.js';
import { log } from '../../../logger.js';
describe('Block diagram', function () { describe('Block diagram', function () {
describe('when parsing a block diagram graph it should handle > ', function () { describe('when parsing a block diagram graph it should handle > ', function () {
@@ -402,7 +403,7 @@ columns 1
const B = blocks[0]; const B = blocks[0];
expect(B.styles).toContain('fill:#f9F'); 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 const str = `block-beta
columns 1 columns 1
A:1 A:1
@@ -413,9 +414,13 @@ columns 1
F:2 F:2
G:1`; G:1`;
expect(() => block.parse(str)).toThrowError( const logWarnSpy = vi.spyOn(log, 'warn').mockImplementation(() => undefined);
'Block B width 2 exceeds configured column width 1'
); block.parse(str);
expect(logWarnSpy).toHaveBeenCalledWith('Block B width 2 exceeds configured column width 1');
logWarnSpy.mockRestore();
}); });
}); });