fixed unit test

This commit is contained in:
khalil
2025-04-06 20:41:29 +01:00
parent 74a9336d42
commit f8d8f74f34
2 changed files with 22 additions and 20 deletions

View File

@@ -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');
});
});
});

View File

@@ -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');
});
});
});