Merge branch 'develop' into standardized-pie-definitions

This commit is contained in:
Reda Al Sulais 2023-08-11 01:04:06 +03:00 committed by GitHub
commit 120bdabee1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 5 deletions

View File

@ -35,7 +35,12 @@ describe('DiagramAPI', () => {
'loki',
{
db: {},
parser: {},
parser: {
parse: (_text) => {
return;
},
parser: { yy: {} },
},
renderer: {},
styles: {},
},

View File

@ -37,7 +37,7 @@ export interface DiagramDB {
export interface DiagramDefinition {
db: DiagramDB;
renderer: any;
parser: any;
parser: ParserDefinition;
styles?: any;
init?: (config: MermaidConfig) => void;
injectUtils?: (
@ -80,6 +80,11 @@ export type DrawDefinition = (
diagramObject: Diagram
) => void;
export interface ParserDefinition {
parse: (text: string) => void;
parser: { yy: DiagramDB };
}
/**
* Type for function parse directive from diagram code.
*

View File

@ -3,6 +3,7 @@ import { mermaidAPI } from './mermaidAPI.js';
import './diagram-api/diagram-orchestration.js';
import { addDiagrams } from './diagram-api/diagram-orchestration.js';
import { beforeAll, describe, it, expect, vi } from 'vitest';
import type { DiagramDefinition } from './diagram-api/types.js';
beforeAll(async () => {
addDiagrams();
@ -92,13 +93,16 @@ describe('when using mermaid and ', () => {
it('should defer diagram load based on parameter', async () => {
let loaded = false;
const dummyDiagram = {
const dummyDiagram: DiagramDefinition = {
db: {},
renderer: () => {
// do nothing
},
parser: () => {
// do nothing
parser: {
parse: (_text) => {
return;
},
parser: { yy: {} },
},
styles: () => {
// do nothing