From 0658a363cb5ca830df6a8450b087c4b85d0c5c1a Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Thu, 26 Aug 2021 17:05:10 +0200 Subject: [PATCH 1/2] #2270 Add support for direction statements for classDiagrams --- .../rendering/classDiagram-v2.spec.js | 96 +++++++++++++++++++ cypress/platform/knsv.html | 33 ++++--- src/diagrams/class/classDb.js | 8 ++ src/diagrams/class/classRenderer-v2.js | 2 +- src/diagrams/class/parser/classDiagram.jison | 17 ++++ 5 files changed, 141 insertions(+), 15 deletions(-) diff --git a/cypress/integration/rendering/classDiagram-v2.spec.js b/cypress/integration/rendering/classDiagram-v2.spec.js index 05f7545e8..66fd1c51f 100644 --- a/cypress/integration/rendering/classDiagram-v2.spec.js +++ b/cypress/integration/rendering/classDiagram-v2.spec.js @@ -370,4 +370,100 @@ describe('Class diagram V2', () => { ); cy.get('svg'); }); + it('16: should handle the direction statemment with TB', () => { + imgSnapshotTest( + ` + classDiagram + direction TB + class Student { + -idCard : IdCard + } + class IdCard{ + -id : int + -name : string + } + class Bike{ + -id : int + -name : string + } + Student "1" --o "1" IdCard : carries + Student "1" --o "1" Bike : rides + + `, + {logLevel : 1, flowchart: { "htmlLabels": false },} + ); + cy.get('svg'); + }); + it('17: should handle the direction statemment with BT', () => { + imgSnapshotTest( + ` + classDiagram + direction BT + class Student { + -idCard : IdCard + } + class IdCard{ + -id : int + -name : string + } + class Bike{ + -id : int + -name : string + } + Student "1" --o "1" IdCard : carries + Student "1" --o "1" Bike : rides + + `, + {logLevel : 1, flowchart: { "htmlLabels": false },} + ); + cy.get('svg'); + }); + it('17: should handle the direction statemment with RL', () => { + imgSnapshotTest( + ` + classDiagram + direction RL + class Student { + -idCard : IdCard + } + class IdCard{ + -id : int + -name : string + } + class Bike{ + -id : int + -name : string + } + Student "1" --o "1" IdCard : carries + Student "1" --o "1" Bike : rides + + `, + {logLevel : 1, flowchart: { "htmlLabels": false },} + ); + cy.get('svg'); + }); + it('18: should handle the direction statemment with LR', () => { + imgSnapshotTest( + ` + classDiagram + direction LR + class Student { + -idCard : IdCard + } + class IdCard{ + -id : int + -name : string + } + class Bike{ + -id : int + -name : string + } + Student "1" --o "1" IdCard : carries + Student "1" --o "1" Bike : rides + + `, + {logLevel : 1, flowchart: { "htmlLabels": false },} + ); + cy.get('svg'); + }); }); diff --git a/cypress/platform/knsv.html b/cypress/platform/knsv.html index 474132392..3968e0055 100644 --- a/cypress/platform/knsv.html +++ b/cypress/platform/knsv.html @@ -10,7 +10,7 @@