mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-09 02:27:05 +02:00
Added tests for colors and fully setup cypress in Docker
This commit is contained in:
85
cypress/integration/rendering/sankey.spec.ts
Normal file
85
cypress/integration/rendering/sankey.spec.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
||||
|
||||
describe('Sankey Diagram', () => {
|
||||
it('should render a simple example', () => {
|
||||
imgSnapshotTest(
|
||||
`
|
||||
sankey-beta
|
||||
|
||||
sourceNode,targetNode,10
|
||||
`,
|
||||
{}
|
||||
);
|
||||
});
|
||||
|
||||
describe('when given a linkColor', function () {
|
||||
it('links should be the same color as source node', () => {
|
||||
renderGraph(
|
||||
`
|
||||
sankey-beta
|
||||
|
||||
sourceNode,targetNode,10
|
||||
`,
|
||||
{
|
||||
sankey: { linkColor: 'source' },
|
||||
}
|
||||
);
|
||||
|
||||
cy.get('.link path').then((link) => {
|
||||
cy.get('.node[id="node-1"] rect').should(node =>
|
||||
expect(link.attr('stroke')).to.equal(node.attr('fill'))
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should change link color to hex code', () => {
|
||||
renderGraph(
|
||||
`
|
||||
sankey-beta
|
||||
a,b,10
|
||||
`,
|
||||
{
|
||||
sankey: { linkColor: '#636465' },
|
||||
}
|
||||
);
|
||||
|
||||
cy.get('.link path').should((link) => {
|
||||
expect(link.attr('stroke')).to.equal('#636465');
|
||||
});
|
||||
});
|
||||
|
||||
it('links should be the same color as target node', () => {
|
||||
renderGraph(
|
||||
`
|
||||
sankey-beta
|
||||
sourceNode,targetNode,10
|
||||
`,
|
||||
{
|
||||
sankey: { linkColor: 'target' },
|
||||
}
|
||||
);
|
||||
|
||||
cy.get('.link path').then((link) => {
|
||||
cy.get('.node[id="node-2"] rect').should(node =>
|
||||
expect(link.attr('stroke')).to.equal(node.attr('fill'))
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('links must be gradient', () => {
|
||||
renderGraph(
|
||||
`
|
||||
sankey-beta
|
||||
sourceNode,targetNode,10
|
||||
`,
|
||||
{
|
||||
sankey: { linkColor: 'gradient' },
|
||||
}
|
||||
);
|
||||
|
||||
cy.get('.link path').should((link) => {
|
||||
expect(link.attr('stroke')).to.equal('url(#linearGradient-3)');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user