mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-17 07:19:24 +02:00
Merge branch 'develop' into sidv/testCommand
This commit is contained in:
@@ -132,3 +132,10 @@ export const verifyScreenshot = (name: string): void => {
|
|||||||
cy.matchImageSnapshot(name);
|
cy.matchImageSnapshot(name);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const verifyNumber = (value: number, expected: number, deltaPercent = 10): void => {
|
||||||
|
expect(value).to.be.within(
|
||||||
|
expected * (1 - deltaPercent / 100),
|
||||||
|
expected * (1 + deltaPercent / 100)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
import { imgSnapshotTest, renderGraph, verifyNumber } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('Flowchart ELK', () => {
|
describe('Flowchart ELK', () => {
|
||||||
it('1-elk: should render a simple flowchart', () => {
|
it('1-elk: should render a simple flowchart', () => {
|
||||||
@@ -109,7 +109,7 @@ describe('Flowchart ELK', () => {
|
|||||||
const style = svg.attr('style');
|
const style = svg.attr('style');
|
||||||
expect(style).to.match(/^max-width: [\d.]+px;$/);
|
expect(style).to.match(/^max-width: [\d.]+px;$/);
|
||||||
const maxWidthValue = parseFloat(style.match(/[\d.]+/g).join(''));
|
const maxWidthValue = parseFloat(style.match(/[\d.]+/g).join(''));
|
||||||
expect(maxWidthValue).to.be.within(230 * 0.95, 230 * 1.05);
|
verifyNumber(maxWidthValue, 380);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('8-elk: should render a flowchart when useMaxWidth is false', () => {
|
it('8-elk: should render a flowchart when useMaxWidth is false', () => {
|
||||||
@@ -128,7 +128,7 @@ describe('Flowchart ELK', () => {
|
|||||||
const width = parseFloat(svg.attr('width'));
|
const width = parseFloat(svg.attr('width'));
|
||||||
// use within because the absolute value can be slightly different depending on the environment ±5%
|
// use within because the absolute value can be slightly different depending on the environment ±5%
|
||||||
// expect(height).to.be.within(446 * 0.95, 446 * 1.05);
|
// expect(height).to.be.within(446 * 0.95, 446 * 1.05);
|
||||||
expect(width).to.be.within(230 * 0.95, 230 * 1.05);
|
verifyNumber(width, 380);
|
||||||
expect(svg).to.not.have.attr('style');
|
expect(svg).to.not.have.attr('style');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -692,7 +692,7 @@ A --> B
|
|||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
cy.get('svg').should((svg) => {
|
cy.get('svg').should((svg) => {
|
||||||
const edges = svg.querySelectorAll('.edges > path');
|
const edges = svg[0].querySelectorAll('.edges > path');
|
||||||
edges.forEach((edge) => {
|
edges.forEach((edge) => {
|
||||||
expect(edge).to.have.class('flowchart-link');
|
expect(edge).to.have.class('flowchart-link');
|
||||||
});
|
});
|
||||||
@@ -739,7 +739,7 @@ NL\`") --"\`1o **bold**\`"--> c
|
|||||||
{ flowchart: { titleTopMargin: 0 } }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('Wrapping long text with a new line', () => {
|
it.skip('Wrapping long text with a new line', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`%%{init: {"flowchart": {"htmlLabels": true}} }%%
|
`%%{init: {"flowchart": {"htmlLabels": true}} }%%
|
||||||
flowchart-elk LR
|
flowchart-elk LR
|
||||||
|
Reference in New Issue
Block a user