collab/mermaid/cypress/integration/rendering/iconShape.spec.tsblame
View source
6dd74de1import { imgSnapshotTest } from '../../helpers/util';
6dd74de2
6dd74de3const looks = ['classic', 'handDrawn'] as const;
6dd74de4const directions = [
6dd74de5 'TB',
6dd74de6 //'BT',
6dd74de7 'LR',
6dd74de8 // 'RL'
6dd74de9] as const;
6dd74de10const forms = [undefined, 'square', 'circle', 'rounded'] as const;
6dd74de11const labelPos = [undefined, 't', 'b'] as const;
6dd74de12
6dd74de13looks.forEach((look) => {
6dd74de14 directions.forEach((direction) => {
6dd74de15 forms.forEach((form) => {
6dd74de16 labelPos.forEach((pos) => {
6dd74de17 describe(`Test iconShape in ${form ? `${form} form,` : ''} ${look} look and dir ${direction} with label position ${pos ? pos : 'not defined'}`, () => {
6dd74de18 it(`without label`, () => {
6dd74de19 let flowchartCode = `flowchart ${direction}\n`;
6dd74de20 flowchartCode += ` nA --> nAA@{ icon: 'fa:bell'`;
6dd74de21 if (form) {
6dd74de22 flowchartCode += `, form: '${form}'`;
6dd74de23 }
6dd74de24 flowchartCode += ` }\n`;
6dd74de25 imgSnapshotTest(flowchartCode, { look });
6dd74de26 });
6dd74de27
6dd74de28 it(`with label`, () => {
6dd74de29 let flowchartCode = `flowchart ${direction}\n`;
6dd74de30 flowchartCode += ` nA --> nAA@{ icon: 'fa:bell', label: 'This is a label for icon shape'`;
6dd74de31 if (form) {
6dd74de32 flowchartCode += `, form: '${form}'`;
6dd74de33 }
6dd74de34 if (pos) {
6dd74de35 flowchartCode += `, pos: '${pos}'`;
6dd74de36 }
6dd74de37 flowchartCode += ` }\n`;
6dd74de38 imgSnapshotTest(flowchartCode, { look });
6dd74de39 });
6dd74de40
6dd74de41 it(`with very long label`, () => {
6dd74de42 let flowchartCode = `flowchart ${direction}\n`;
6dd74de43 flowchartCode += ` nA --> nAA@{ icon: 'fa:bell', label: 'This is a very very very very very long long long label for icon shape'`;
6dd74de44 if (form) {
6dd74de45 flowchartCode += `, form: '${form}'`;
6dd74de46 }
6dd74de47 if (pos) {
6dd74de48 flowchartCode += `, pos: '${pos}'`;
6dd74de49 }
6dd74de50 flowchartCode += ` }\n`;
6dd74de51 imgSnapshotTest(flowchartCode, { look });
6dd74de52 });
6dd74de53
6dd74de54 it(`with markdown htmlLabels:true`, () => {
6dd74de55 let flowchartCode = `flowchart ${direction}\n`;
6dd74de56 flowchartCode += ` nA --> nAA@{ icon: 'fa:bell', label: 'This is **bold** </br>and <strong>strong</strong> for icon shape'`;
6dd74de57 if (form) {
6dd74de58 flowchartCode += `, form: '${form}'`;
6dd74de59 }
6dd74de60 if (pos) {
6dd74de61 flowchartCode += `, pos: '${pos}'`;
6dd74de62 }
6dd74de63 flowchartCode += ` }\n`;
6dd74de64 imgSnapshotTest(flowchartCode, { look });
6dd74de65 });
6dd74de66
6dd74de67 it(`with markdown htmlLabels:false`, () => {
6dd74de68 let flowchartCode = `flowchart ${direction}\n`;
6dd74de69 flowchartCode += ` nA --> nAA@{ icon: 'fa:bell', label: 'This is **bold** </br>and <strong>strong</strong> for icon shape'`;
6dd74de70 if (form) {
6dd74de71 flowchartCode += `, form: '${form}'`;
6dd74de72 }
6dd74de73 if (pos) {
6dd74de74 flowchartCode += `, pos: '${pos}'`;
6dd74de75 }
6dd74de76 flowchartCode += ` }\n`;
6dd74de77 imgSnapshotTest(flowchartCode, {
6dd74de78 look,
6dd74de79 htmlLabels: false,
6dd74de80 flowchart: { htmlLabels: false },
6dd74de81 });
6dd74de82 });
6dd74de83
6dd74de84 it(`with styles`, () => {
6dd74de85 let flowchartCode = `flowchart ${direction}\n`;
6dd74de86 flowchartCode += ` nA --> nAA@{ icon: 'fa:bell', label: 'new icon shape'`;
6dd74de87 if (form) {
6dd74de88 flowchartCode += `, form: '${form}'`;
6dd74de89 }
6dd74de90 if (pos) {
6dd74de91 flowchartCode += `, pos: '${pos}'`;
6dd74de92 }
6dd74de93 flowchartCode += ` }\n`;
6dd74de94 flowchartCode += ` style nAA fill:#f9f,stroke:#333,stroke-width:4px \n`;
6dd74de95 imgSnapshotTest(flowchartCode, { look });
6dd74de96 });
6dd74de97
6dd74de98 it(`with classDef`, () => {
6dd74de99 let flowchartCode = `flowchart ${direction}\n`;
6dd74de100 flowchartCode += ` classDef customClazz fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5\n`;
6dd74de101 flowchartCode += ` nA --> nAA@{ icon: 'fa:bell', label: 'new icon shape'`;
6dd74de102 if (form) {
6dd74de103 flowchartCode += `, form: '${form}'`;
6dd74de104 }
6dd74de105 if (pos) {
6dd74de106 flowchartCode += `, pos: '${pos}'`;
6dd74de107 }
6dd74de108 flowchartCode += ` }\n`;
6dd74de109 flowchartCode += ` nAA:::customClazz\n`;
6dd74de110 imgSnapshotTest(flowchartCode, { look });
6dd74de111 });
6dd74de112 });
6dd74de113 });
6dd74de114 });
6dd74de115 });
6dd74de116});
6dd74de117
6dd74de118describe('Test iconShape with different h', () => {
6dd74de119 it('with different h', () => {
6dd74de120 let flowchartCode = `flowchart TB\n`;
6dd74de121 const icon = 'fa:bell';
6dd74de122 const iconHeight = 64;
6dd74de123 flowchartCode += ` nA --> nAA@{ icon: '${icon}', label: 'icon with different h', h: ${iconHeight} }\n`;
6dd74de124 imgSnapshotTest(flowchartCode);
6dd74de125 });
6dd74de126});
6dd74de127
6dd74de128describe('Test colored iconShape', () => {
6dd74de129 it('with no styles', () => {
6dd74de130 let flowchartCode = `flowchart TB\n`;
6dd74de131 const icon = 'fluent-emoji:tropical-fish';
6dd74de132 flowchartCode += ` nA --> nAA@{ icon: '${icon}', form: 'square', label: 'icon with color' }\n`;
6dd74de133 imgSnapshotTest(flowchartCode);
6dd74de134 });
6dd74de135
6dd74de136 it('with styles', () => {
6dd74de137 let flowchartCode = `flowchart TB\n`;
6dd74de138 const icon = 'fluent-emoji:tropical-fish';
6dd74de139 flowchartCode += ` nA --> nAA@{ icon: '${icon}', form: 'square', label: 'icon with color' }\n`;
6dd74de140 flowchartCode += ` style nAA fill:#f9f,stroke:#333,stroke-width:4px \n`;
6dd74de141 imgSnapshotTest(flowchartCode);
6dd74de142 });
6dd74de143});