This commit is contained in:
Aakansha Doshi 2023-10-31 19:32:20 +05:30
parent 2a8323f951
commit fff25e7e2c
3 changed files with 23 additions and 2 deletions

View File

@ -19,6 +19,14 @@ export interface InjectUtils {
_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.
*/
@ -37,6 +45,7 @@ export interface DiagramDB {
setDisplayMode?: (title: string) => void;
bindFunctions?: (element: Element) => void;
getMessages?: () => Message[];
}
// This is what is returned from getClasses(...) methods.

View File

@ -69,4 +69,18 @@ Expecting 'TXT', got 'NEWLINE'"
'"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]);
});
});
});

View File

@ -436,8 +436,6 @@ const render = async function (
appendDivSvgG(root, id, enclosingDivID);
}
text = encodeEntities(text);
// -------------------------------------------------------------------------------
// Create the diagram