mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-09 18:39:41 +02:00
Fix for tests
This commit is contained in:
@@ -63,8 +63,8 @@ const sanitizeMore = (text, config) => {
|
|||||||
return txt;
|
return txt;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const sanitizeText = (text) => {
|
export const sanitizeText = (text, config) => {
|
||||||
const txt = sanitizeMore(DOMPurify.sanitize(text));
|
const txt = sanitizeMore(DOMPurify.sanitize(text), config);
|
||||||
|
|
||||||
return txt;
|
return txt;
|
||||||
};
|
};
|
||||||
@@ -78,7 +78,9 @@ export const hasBreaks = (text) => {
|
|||||||
export const splitBreaks = (text) => {
|
export const splitBreaks = (text) => {
|
||||||
return text.split(/<br\s*[/]?>/gi);
|
return text.split(/<br\s*[/]?>/gi);
|
||||||
};
|
};
|
||||||
|
const placeholderToBreak = (s) => {
|
||||||
|
return s.replace(/#br#/g, '<br/>');
|
||||||
|
};
|
||||||
const breakToPlaceholder = (s) => {
|
const breakToPlaceholder = (s) => {
|
||||||
return s.replace(lineBreakRegex, '#br#');
|
return s.replace(lineBreakRegex, '#br#');
|
||||||
};
|
};
|
||||||
|
@@ -121,7 +121,7 @@ describe('[Singlenodes] when parsing', () => {
|
|||||||
|
|
||||||
expect(edges.length).toBe(0);
|
expect(edges.length).toBe(0);
|
||||||
expect(vert['a'].type).toBe('diamond');
|
expect(vert['a'].type).toBe('diamond');
|
||||||
expect(vert['a'].text).toBe('A <br> end');
|
expect(vert['a'].text).toBe('A <br/> end');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle a single hexagon node', function() {
|
it('should handle a single hexagon node', function() {
|
||||||
@@ -144,7 +144,7 @@ describe('[Singlenodes] when parsing', () => {
|
|||||||
|
|
||||||
expect(edges.length).toBe(0);
|
expect(edges.length).toBe(0);
|
||||||
expect(vert['a'].type).toBe('hexagon');
|
expect(vert['a'].type).toBe('hexagon');
|
||||||
expect(vert['a'].text).toBe('A <br> end');
|
expect(vert['a'].text).toBe('A <br/> end');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle a single round node with html in it', function() {
|
it('should handle a single round node with html in it', function() {
|
||||||
@@ -156,7 +156,7 @@ describe('[Singlenodes] when parsing', () => {
|
|||||||
|
|
||||||
expect(edges.length).toBe(0);
|
expect(edges.length).toBe(0);
|
||||||
expect(vert['a'].type).toBe('round');
|
expect(vert['a'].type).toBe('round');
|
||||||
expect(vert['a'].text).toBe('A <br> end');
|
expect(vert['a'].text).toBe('A <br/> end');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle a single node with alphanumerics starting on a char', function() {
|
it('should handle a single node with alphanumerics starting on a char', function() {
|
||||||
|
@@ -328,7 +328,7 @@ describe('[Text] when parsing', () => {
|
|||||||
const edges = flow.parser.yy.getEdges();
|
const edges = flow.parser.yy.getEdges();
|
||||||
|
|
||||||
expect(vert['C'].type).toBe('round');
|
expect(vert['C'].type).toBe('round');
|
||||||
expect(vert['C'].text).toBe('Chimpansen hoppar åäö <br> - ÅÄÖ');
|
expect(vert['C'].text).toBe('Chimpansen hoppar åäö <br/> - ÅÄÖ');
|
||||||
});
|
});
|
||||||
// xit('it should handle åäö, minus and space and br',function(){
|
// xit('it should handle åäö, minus and space and br',function(){
|
||||||
// const res = flow.parser.parse('graph TD; A[Object(foo,bar)]-->B(Thing);');
|
// const res = flow.parser.parse('graph TD; A[Object(foo,bar)]-->B(Thing);');
|
||||||
|
Reference in New Issue
Block a user