Skip to content

Commit

Permalink
Merge branch 'develop' into chore/standardized-error-definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Yokozuna59 authored Aug 10, 2023
2 parents 9ab048c + 1078b1c commit 0d380bb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
7 changes: 6 additions & 1 deletion packages/mermaid/src/diagram-api/diagramAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ describe('DiagramAPI', () => {
'loki',
{
db: {},
parser: {},
parser: {
parse: (_text) => {
return;
},
parser: { yy: {} },
},
renderer: {},
styles: {},
},
Expand Down
9 changes: 7 additions & 2 deletions packages/mermaid/src/diagram-api/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Diagram } from '../Diagram.js';
import { MermaidConfig } from '../config.type.js';
import type { MermaidConfig } from '../config.type.js';
import type * as d3 from 'd3';

export interface InjectUtils {
Expand Down Expand Up @@ -27,7 +27,7 @@ export interface DiagramDB {
export interface DiagramDefinition {
db: DiagramDB;
renderer: any;
parser: any;
parser: ParserDefinition;
styles?: any;
init?: (config: MermaidConfig) => void;
injectUtils?: (
Expand Down Expand Up @@ -70,6 +70,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.
*
Expand Down
10 changes: 7 additions & 3 deletions packages/mermaid/src/mermaid.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0d380bb

Please sign in to comment.