mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-12-07 04:56:37 +01:00
tsConversion: fix DiagramAPI
This commit is contained in:
29
src/diagram-api/diagramAPI.spec.ts
Normal file
29
src/diagram-api/diagramAPI.spec.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { detectType } from './detectType';
|
||||
import { getDiagram, registerDiagram } from './diagramAPI';
|
||||
|
||||
describe('DiagramAPI', () => {
|
||||
it('should return default diagrams', () => {
|
||||
expect(getDiagram('sequence')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should throw error if diagram is not defined', () => {
|
||||
expect(() => getDiagram('loki')).toThrow();
|
||||
});
|
||||
|
||||
it('should handle diagram registrations', () => {
|
||||
expect(() => getDiagram('loki')).toThrow();
|
||||
// TODO Q: Shouldn't this be throwing an error?
|
||||
expect(detectType('loki diagram')).toBe('flowchart');
|
||||
registerDiagram(
|
||||
'loki',
|
||||
{
|
||||
db: {},
|
||||
parser: {},
|
||||
renderer: {},
|
||||
},
|
||||
(text: string) => text.includes('loki')
|
||||
);
|
||||
expect(getDiagram('loki')).not.toBeNull();
|
||||
expect(detectType('loki diagram')).toBe('loki');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user