mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-21 00:09:51 +02:00
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
import flowDb from '../flowDb';
|
|
import flow from './flow';
|
|
import { setConfig } from '../../../config';
|
|
|
|
setConfig({
|
|
securityLevel: 'strict'
|
|
});
|
|
|
|
describe('[Interactions] when parsing', () => {
|
|
beforeEach(function() {
|
|
flow.parser.yy = flowDb;
|
|
flow.parser.yy.clear();
|
|
});
|
|
|
|
it('it should be possible to use click to a callback', function() {
|
|
spyOn(flowDb, 'setClickEvent');
|
|
const res = flow.parser.parse('graph TD\nA-->B\nclick A callback');
|
|
|
|
const vert = flow.parser.yy.getVertices();
|
|
const edges = flow.parser.yy.getEdges();
|
|
|
|
expect(flowDb.setClickEvent).toHaveBeenCalledWith('A', 'callback', undefined);
|
|
});
|
|
|
|
it('it should be possible to use click to a callback with toolip', function() {
|
|
spyOn(flowDb, 'setClickEvent');
|
|
const res = flow.parser.parse('graph TD\nA-->B\nclick A callback "tooltip"');
|
|
|
|
const vert = flow.parser.yy.getVertices();
|
|
const edges = flow.parser.yy.getEdges();
|
|
|
|
expect(flowDb.setClickEvent).toHaveBeenCalledWith('A', 'callback', 'tooltip');
|
|
});
|
|
|
|
it('should handle interaction - click to a link', function() {
|
|
spyOn(flowDb, 'setLink');
|
|
const res = flow.parser.parse('graph TD\nA-->B\nclick A "click.html"');
|
|
|
|
const vert = flow.parser.yy.getVertices();
|
|
const edges = flow.parser.yy.getEdges();
|
|
|
|
expect(flowDb.setLink).toHaveBeenCalledWith('A', 'click.html', undefined);
|
|
});
|
|
|
|
it('should handle interaction - click to a link with tooltip', function() {
|
|
spyOn(flowDb, 'setLink');
|
|
const res = flow.parser.parse('graph TD\nA-->B\nclick A "click.html" "tooltip"');
|
|
|
|
const vert = flow.parser.yy.getVertices();
|
|
const edges = flow.parser.yy.getEdges();
|
|
|
|
expect(flowDb.setLink).toHaveBeenCalledWith('A', 'click.html', 'tooltip');
|
|
});
|
|
});
|