feat: add use case diagram examples and update parser tests for error handling

on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
omkarht
2025-09-17 12:11:36 +05:30
parent 781554bf70
commit 5362d3f5ba
3 changed files with 62 additions and 3 deletions

View File

@@ -1489,14 +1489,18 @@ describe('Error Handling', () => {
const emptyInput = '';
expect(() => parseUsecaseWithAntlr(emptyInput)).toThrow(UsecaseParseError);
expect(() => parseUsecaseWithAntlr(emptyInput)).toThrow(/missing 'usecase'/);
expect(() => parseUsecaseWithAntlr(emptyInput)).toThrow(
/mismatched input '<EOF>' expecting {'usecase', NEWLINE}/
);
});
it('should throw UsecaseParseError for only whitespace input', () => {
const whitespaceInput = ' \n \t \n ';
expect(() => parseUsecaseWithAntlr(whitespaceInput)).toThrow(UsecaseParseError);
expect(() => parseUsecaseWithAntlr(whitespaceInput)).toThrow(/missing 'usecase'/);
expect(() => parseUsecaseWithAntlr(whitespaceInput)).toThrow(
/extraneous input '<EOF>' expecting {'usecase', NEWLINE}/
);
});
it('should throw UsecaseParseError for missing usecase keyword', () => {
@@ -1506,7 +1510,9 @@ describe('Error Handling', () => {
`;
expect(() => parseUsecaseWithAntlr(missingKeyword)).toThrow(UsecaseParseError);
expect(() => parseUsecaseWithAntlr(missingKeyword)).toThrow(/missing 'usecase'/);
expect(() => parseUsecaseWithAntlr(missingKeyword)).toThrow(
/extraneous input 'actor' expecting {'usecase', NEWLINE}/
);
});
});