mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-12-09 22:14:10 +01:00
added test cases to check state diagram direction
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import stateDiagram, { parser } from './parser/stateDiagram.jison';
|
import stateDiagram, { parser } from './parser/stateDiagram.jison';
|
||||||
|
import { DEFAULT_DIAGRAM_DIRECTION } from './stateCommon.js';
|
||||||
import { StateDB } from './stateDb.js';
|
import { StateDB } from './stateDb.js';
|
||||||
|
|
||||||
describe('state diagram V2, ', function () {
|
describe('state diagram V2, ', function () {
|
||||||
@@ -412,5 +413,34 @@ describe('state diagram V2, ', function () {
|
|||||||
const rel_Active_Active = rels.find((rel) => rel.id1 === 'Active' && rel.id2 === 'Active');
|
const rel_Active_Active = rels.find((rel) => rel.id1 === 'Active' && rel.id2 === 'Active');
|
||||||
expect(rel_Active_Active.relationTitle).toEqual('LOG');
|
expect(rel_Active_Active.relationTitle).toEqual('LOG');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should check default diagram direction', () => {
|
||||||
|
const diagram = `
|
||||||
|
stateDiagram
|
||||||
|
[*] --> Still
|
||||||
|
Still --> [*]
|
||||||
|
`;
|
||||||
|
|
||||||
|
parser.parse(diagram);
|
||||||
|
|
||||||
|
// checking default direction if no direction is specified
|
||||||
|
const defaultDir = stateDb.getDirection();
|
||||||
|
expect(defaultDir).toEqual(DEFAULT_DIAGRAM_DIRECTION);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('retrieve the diagram direction correctly', () => {
|
||||||
|
const diagram = `
|
||||||
|
stateDiagram
|
||||||
|
direction LR
|
||||||
|
[*] --> Still
|
||||||
|
Still --> [*]
|
||||||
|
`;
|
||||||
|
|
||||||
|
parser.parse(diagram);
|
||||||
|
|
||||||
|
//retrieve the diagram direction
|
||||||
|
const currentDirection = stateDb.getDirection();
|
||||||
|
expect(currentDirection).toEqual('LR');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user