mermaid/cypress/platform/bundle-test.js

62 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-07-26 08:20:45 +02:00
import mermaid from '../../dist/mermaid.core';
2020-07-26 08:03:56 +02:00
let code = `flowchart LR
Power_Supply --> Transmitter_A
Power_Supply --> Transmitter_B
Transmitter_A --> D
Transmitter_B --> D`;
let code2 = `gantt
dateFormat YYYY-MM-DD
title Adding GANTT diagram functionality to mermaid
section A section
Completed task :done, des1, 2014-01-06,2014-01-08
Active task :active, des2, 2014-01-09, 3d
Future task : des3, after des2, 5d
Future task2 : des4, after des3, 5d
section Critical tasks
Completed task in the critical line :crit, done, 2014-01-06,24h
Implement parser and jison :crit, done, after des1, 2d
Create tests for parser :crit, active, 3d
Future task in critical line :crit, 5d
Create tests for renderer :2d
Add to mermaid :1d`;
2020-07-26 08:20:45 +02:00
const code3 = `flowchart TD
2020-07-26 08:03:56 +02:00
A(<img scr='https://iconscout.com/ms-icon-310x310.png' width='20' height='20' />)
2020-07-26 08:20:45 +02:00
B(<b>Bold text!</b>)`;
2020-07-26 08:03:56 +02:00
2020-07-26 08:20:45 +02:00
if (location.href.match('test-html-escaping')) {
2020-07-26 08:03:56 +02:00
code = code3;
}
mermaid.initialize({
2020-07-26 08:03:56 +02:00
theme: 'default',
2020-07-26 08:20:45 +02:00
// fontFamily: '"Lucida Console", Monaco, monospace',
2020-07-26 08:03:56 +02:00
startOnLoad: false,
2020-07-26 08:20:45 +02:00
securityLevel: 'loose',
2020-07-26 08:03:56 +02:00
flowchart: {
2022-02-10 20:32:21 +01:00
htmlLabels: true,
2020-07-26 08:03:56 +02:00
},
gantt: {
axisFormatter: [
[
'%Y-%m-%d',
2022-02-10 20:32:21 +01:00
(d) => {
2020-07-26 08:03:56 +02:00
return d.getDay() === 1;
2022-02-10 20:32:21 +01:00
},
],
],
},
2020-07-26 08:03:56 +02:00
});
mermaid.render(
'the-id-of-the-svg',
code,
2022-02-10 20:32:21 +01:00
(svg) => {
2020-07-26 08:03:56 +02:00
console.log(svg);
const elem = document.querySelector('#graph-to-be');
elem.innerHTML = svg;
}
// ,document.querySelector('#tmp')
);