mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
add spec
This commit is contained in:
parent
2a8323f951
commit
fff25e7e2c
@ -19,6 +19,14 @@ export interface InjectUtils {
|
|||||||
_parseDirective: any;
|
_parseDirective: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type Message = {
|
||||||
|
type: number;
|
||||||
|
to: string;
|
||||||
|
from: string;
|
||||||
|
message: string;
|
||||||
|
wrap: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic Diagram DB that may apply to any diagram type.
|
* Generic Diagram DB that may apply to any diagram type.
|
||||||
*/
|
*/
|
||||||
@ -37,6 +45,7 @@ export interface DiagramDB {
|
|||||||
|
|
||||||
setDisplayMode?: (title: string) => void;
|
setDisplayMode?: (title: string) => void;
|
||||||
bindFunctions?: (element: Element) => void;
|
bindFunctions?: (element: Element) => void;
|
||||||
|
getMessages?: () => Message[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is what is returned from getClasses(...) methods.
|
// This is what is returned from getClasses(...) methods.
|
||||||
|
@ -69,4 +69,18 @@ Expecting 'TXT', got 'NEWLINE'"
|
|||||||
'"No diagram type detected matching given configuration for text: thor TD; A-->B"'
|
'"No diagram type detected matching given configuration for text: thor TD; A-->B"'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should consider entity codes when present in diagram defination', async () => {
|
||||||
|
const diagram = await getDiagramFromText(`sequenceDiagram
|
||||||
|
A->>B: I #9829; you!
|
||||||
|
B->>A: I #9829; you #infin; times more!`);
|
||||||
|
const messages = diagram.db?.getMessages?.();
|
||||||
|
if (!messages) {
|
||||||
|
throw new Error('Messages not found!');
|
||||||
|
}
|
||||||
|
const result = ['I fl°°9829¶ß you!', 'I fl°°9829¶ß you fl°infin¶ß times more!'];
|
||||||
|
messages.forEach((message, index: number) => {
|
||||||
|
expect(message.message).toBe(result[index]);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -436,8 +436,6 @@ const render = async function (
|
|||||||
appendDivSvgG(root, id, enclosingDivID);
|
appendDivSvgG(root, id, enclosingDivID);
|
||||||
}
|
}
|
||||||
|
|
||||||
text = encodeEntities(text);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------
|
||||||
// Create the diagram
|
// Create the diagram
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user