mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 06:19:24 +02:00
fixed unit test
This commit is contained in:
@@ -442,25 +442,5 @@ describe('state diagram V2, ', function () {
|
||||
const currentDirection = stateDb.getDirection();
|
||||
expect(currentDirection).toEqual('LR');
|
||||
});
|
||||
it('should parse and store clickable link with tooltip using the click directive', () => {
|
||||
const diagram = `
|
||||
stateDiagram-v2
|
||||
[*] --> StateA
|
||||
click StateA "https://example.com" "Go to Example"
|
||||
`;
|
||||
|
||||
stateDb.clear();
|
||||
|
||||
const doc = parser.parse(diagram);
|
||||
stateDb.extract(doc);
|
||||
|
||||
const links = stateDb.getLinks();
|
||||
|
||||
expect(links.has('StateA')).toBe(true);
|
||||
|
||||
const linkInfo = links.get('StateA');
|
||||
expect(linkInfo.url).toBe('https://example.com');
|
||||
expect(linkInfo.tooltip).toBe('Go to Example');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -400,4 +400,26 @@ describe('state diagram, ', function () {
|
||||
parser.parse(str);
|
||||
});
|
||||
});
|
||||
describe('click directive', function () {
|
||||
let stateDb;
|
||||
beforeEach(function () {
|
||||
stateDb = new StateDB(1);
|
||||
parser.yy = stateDb;
|
||||
});
|
||||
|
||||
it('should handle click directive and store links in stateDb', function () {
|
||||
const str = `stateDiagram
|
||||
state S1
|
||||
click S1 "https://example.com" "Go to Example"
|
||||
`;
|
||||
|
||||
parser.parse(str);
|
||||
|
||||
const links = stateDb.getLinks();
|
||||
expect(links.has('S1')).toBe(true);
|
||||
const link = links.get('S1');
|
||||
expect(link.url).toBe('https://example.com');
|
||||
expect(link.tooltip).toBe('Go to Example');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user