mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-02-04 07:13:25 +08:00
#1078 Using the configuration of the arrowMarkerAbsolute
This commit is contained in:
parent
3f8f9f6711
commit
f6028b63b6
@ -26,3 +26,9 @@ export const imgSnapshotTest = (graphStr, options, api) => {
|
|||||||
cy.get('svg');
|
cy.get('svg');
|
||||||
cy.percySnapshot();
|
cy.percySnapshot();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const renderGraph = (graphStr, options, api) => {
|
||||||
|
const url = mermaidUrl(graphStr, options, api);
|
||||||
|
|
||||||
|
cy.visit(url);
|
||||||
|
};
|
||||||
|
100
cypress/integration/other/configuration.spec.js
Normal file
100
cypress/integration/other/configuration.spec.js
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
import { renderGraph } from '../../helpers/util';
|
||||||
|
/* eslint-env jest */
|
||||||
|
describe('Configuration', () => {
|
||||||
|
describe('arrowMarkerAbsolute', () => {
|
||||||
|
it('should handle default value false of arrowMarkerAbsolute', () => {
|
||||||
|
renderGraph(
|
||||||
|
`graph TD
|
||||||
|
A[Christmas] -->|Get money| B(Go shopping)
|
||||||
|
B --> C{Let me think}
|
||||||
|
C -->|One| D[Laptop]
|
||||||
|
C -->|Two| E[iPhone]
|
||||||
|
C -->|Three| F[fa:fa-car Car]
|
||||||
|
`,
|
||||||
|
{ }
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check the marker-end property to make sure it is properly set to
|
||||||
|
// start with #
|
||||||
|
cy.get('.edgePath path').first().should('have.attr', 'marker-end')
|
||||||
|
.should('exist')
|
||||||
|
.and('include', 'url(#');
|
||||||
|
});
|
||||||
|
it('should handle default value false of arrowMarkerAbsolute', () => {
|
||||||
|
renderGraph(
|
||||||
|
`graph TD
|
||||||
|
A[Christmas] -->|Get money| B(Go shopping)
|
||||||
|
B --> C{Let me think}
|
||||||
|
C -->|One| D[Laptop]
|
||||||
|
C -->|Two| E[iPhone]
|
||||||
|
C -->|Three| F[fa:fa-car Car]
|
||||||
|
`,
|
||||||
|
{ }
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check the marker-end property to make sure it is properly set to
|
||||||
|
// start with #
|
||||||
|
cy.get('.edgePath path').first().should('have.attr', 'marker-end')
|
||||||
|
.should('exist')
|
||||||
|
.and('include', 'url(#');
|
||||||
|
});
|
||||||
|
it('should handle arrowMarkerAbsolute excplicitly set to false', () => {
|
||||||
|
renderGraph(
|
||||||
|
`graph TD
|
||||||
|
A[Christmas] -->|Get money| B(Go shopping)
|
||||||
|
B --> C{Let me think}
|
||||||
|
C -->|One| D[Laptop]
|
||||||
|
C -->|Two| E[iPhone]
|
||||||
|
C -->|Three| F[fa:fa-car Car]
|
||||||
|
`,
|
||||||
|
{
|
||||||
|
arrowMarkerAbsolute: false
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check the marker-end property to make sure it is properly set to
|
||||||
|
// start with #
|
||||||
|
cy.get('.edgePath path').first().should('have.attr', 'marker-end')
|
||||||
|
.should('exist')
|
||||||
|
.and('include', 'url(#');
|
||||||
|
});
|
||||||
|
it('should handle arrowMarkerAbsolute excplicitly set to "false" as false', () => {
|
||||||
|
renderGraph(
|
||||||
|
`graph TD
|
||||||
|
A[Christmas] -->|Get money| B(Go shopping)
|
||||||
|
B --> C{Let me think}
|
||||||
|
C -->|One| D[Laptop]
|
||||||
|
C -->|Two| E[iPhone]
|
||||||
|
C -->|Three| F[fa:fa-car Car]
|
||||||
|
`,
|
||||||
|
{
|
||||||
|
arrowMarkerAbsolute: "false"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check the marker-end property to make sure it is properly set to
|
||||||
|
// start with #
|
||||||
|
cy.get('.edgePath path').first().should('have.attr', 'marker-end')
|
||||||
|
.should('exist')
|
||||||
|
.and('include', 'url(#');
|
||||||
|
});
|
||||||
|
it('should handle arrowMarkerAbsolute set to true', () => {
|
||||||
|
renderGraph(
|
||||||
|
`graph TD
|
||||||
|
A[Christmas] -->|Get money| B(Go shopping)
|
||||||
|
B --> C{Let me think}
|
||||||
|
C -->|One| D[Laptop]
|
||||||
|
C -->|Two| E[iPhone]
|
||||||
|
C -->|Three| F[fa:fa-car Car]
|
||||||
|
`,
|
||||||
|
{
|
||||||
|
arrowMarkerAbsolute: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
cy.get('.edgePath path').first().should('have.attr', 'marker-end')
|
||||||
|
.should('exist')
|
||||||
|
.and('include', 'url(http://localhost');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -4,9 +4,8 @@
|
|||||||
<link href="https://fonts.googleapis.com/css?family=Mansalva&display=swap" rel="stylesheet" />
|
<link href="https://fonts.googleapis.com/css?family=Mansalva&display=swap" rel="stylesheet" />
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
/* font-family: 'Mansalva', cursive;
|
/* font-family: 'Mansalva', cursive;*/
|
||||||
font-family: 'Mansalva', cursive; */
|
font-family: 'Mansalva', cursive;
|
||||||
font-family: 'times';
|
|
||||||
}
|
}
|
||||||
/* .mermaid-main-font {
|
/* .mermaid-main-font {
|
||||||
font-family: "trebuchet ms", verdana, arial;
|
font-family: "trebuchet ms", verdana, arial;
|
||||||
|
@ -598,10 +598,11 @@ const render = function(id, txt, cb, container) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fix for when the base tag is used
|
// Fix for when the base tag is used
|
||||||
let svgCode = d3
|
let svgCode = d3.select('#d' + id).node().innerHTML;
|
||||||
.select('#d' + id)
|
|
||||||
.node()
|
if (!config.arrowMarkerAbsolute || config.arrowMarkerAbsolute === 'false') {
|
||||||
.innerHTML.replace(/url\(#arrowhead/g, 'url(' + url + '#arrowhead', 'g');
|
svgCode = svgCode.replace(/marker-end=\"url\(.*?#/g, 'marker-end="url(#', 'g');
|
||||||
|
}
|
||||||
|
|
||||||
svgCode = decodeEntities(svgCode);
|
svgCode = decodeEntities(svgCode);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user