2024-08-13 15:09:04 +02:00
import { imgSnapshotTest } from '../../helpers/util.ts' ;
2024-09-04 15:42:13 +05:30
const looks = [ 'classic' ] as const ;
const directions = [ 'TB' ] as const ;
2024-08-13 15:09:04 +02:00
const newShapesSet1 = [
'triangle' ,
2024-09-09 14:59:03 +02:00
'sloped-rect' ,
'tilted-cylinder' ,
'flipped-triangle' ,
2024-08-13 15:09:04 +02:00
'hourglass' ,
] as const ;
2024-08-14 18:48:12 +05:30
const newShapesSet2 = [
2024-09-09 14:59:03 +02:00
'tagged-rect' ,
'multi-rect' ,
'lightning-bolt' ,
'filled-circle' ,
'window-pane' ,
2024-08-14 18:48:12 +05:30
] as const ;
2024-08-13 15:09:04 +02:00
2024-08-16 12:23:52 +05:30
const newShapesSet3 = [
2024-09-09 14:59:03 +02:00
'curved-trapezoid' ,
'bow-tie-rect' ,
'wave-edge-rect' ,
'divided-rectangle' ,
'crossed-circle' ,
2024-08-16 12:23:52 +05:30
] as const ;
2024-08-20 12:48:57 +05:30
const newShapesSet4 = [
2024-09-09 14:59:03 +02:00
'wave-rectangle' ,
'notched-pentagon' ,
'lined-cylinder' ,
'multi-wave-edged-rectangle' ,
'half-rounded-rect' ,
2024-08-20 12:48:57 +05:30
] as const ;
2024-08-21 15:16:18 +02:00
const newShapesSet5 = [
2024-09-09 14:59:03 +02:00
'lined-wave-edged-rect' ,
'tagged-wave-edged-rectangle' ,
'brace-l' ,
'curved-trapezoid' ,
'wave-rectangle' ,
2024-08-27 15:50:42 +05:30
] as const ;
2024-08-16 12:23:52 +05:30
2024-09-09 14:59:03 +02:00
const newShapesSet6 = [ 'brace-r' , 'braces' ] as const ;
2024-08-13 15:09:04 +02:00
// Aggregate all shape sets into a single array
2024-09-09 14:59:03 +02:00
const newShapesSets = [
newShapesSet1 ,
newShapesSet2 ,
newShapesSet3 ,
newShapesSet4 ,
newShapesSet5 ,
newShapesSet6 ,
] ;
2024-08-13 15:09:04 +02:00
looks . forEach ( ( look ) = > {
directions . forEach ( ( direction ) = > {
newShapesSets . forEach ( ( newShapesSet ) = > {
describe ( ` Test ${ newShapesSet . join ( ', ' ) } in ${ look } look and dir ${ direction } ` , ( ) = > {
it ( ` without label ` , ( ) = > {
let flowchartCode = ` flowchart ${ direction } \ n ` ;
newShapesSet . forEach ( ( newShape , index ) = > {
2024-09-12 16:58:52 +02:00
flowchartCode += ` n ${ index } --> n ${ index } ${ index } { shape: ${ newShape } } \ n ` ;
2024-08-13 15:09:04 +02:00
} ) ;
imgSnapshotTest ( flowchartCode , { look } ) ;
} ) ;
it ( ` with label ` , ( ) = > {
let flowchartCode = ` flowchart ${ direction } \ n ` ;
newShapesSet . forEach ( ( newShape , index ) = > {
2024-09-12 16:58:52 +02:00
flowchartCode += ` n ${ index } --> n ${ index } ${ index } { shape: ${ newShape } , label: 'This is a label for ${ newShape } shape' } \ n ` ;
2024-08-13 15:09:04 +02:00
} ) ;
imgSnapshotTest ( flowchartCode , { look } ) ;
} ) ;
2024-08-21 15:16:18 +02:00
it ( ` connect all shapes with each other ` , ( ) = > {
let flowchartCode = ` flowchart ${ direction } \ n ` ;
newShapesSet . forEach ( ( newShape , index ) = > {
2024-09-12 16:58:52 +02:00
flowchartCode += ` n ${ index } ${ index } { shape: ${ newShape } , label: 'This is a label for ${ newShape } shape' } \ n ` ;
2024-08-21 15:16:18 +02:00
} ) ;
for ( let i = 0 ; i < newShapesSet . length ; i ++ ) {
for ( let j = i + 1 ; j < newShapesSet . length ; j ++ ) {
flowchartCode += ` n ${ i } ${ i } --> n ${ j } ${ j } \ n ` ;
}
}
imgSnapshotTest ( flowchartCode , { look } ) ;
} ) ;
2024-08-13 15:09:04 +02:00
it ( ` with very long label ` , ( ) = > {
let flowchartCode = ` flowchart ${ direction } \ n ` ;
newShapesSet . forEach ( ( newShape , index ) = > {
2024-09-12 16:58:52 +02:00
flowchartCode += ` n ${ index } --> n ${ index } ${ index } { shape: ${ newShape } , label: 'This is a very very very very very long long long label for ${ newShape } shape' } \ n ` ;
2024-08-13 15:09:04 +02:00
} ) ;
imgSnapshotTest ( flowchartCode , { look } ) ;
} ) ;
it ( ` with markdown htmlLabels:true ` , ( ) = > {
let flowchartCode = ` flowchart ${ direction } \ n ` ;
newShapesSet . forEach ( ( newShape , index ) = > {
2024-09-12 16:58:52 +02:00
flowchartCode += ` n ${ index } --> n ${ index } ${ index } { shape: ${ newShape } , label: 'This is **bold** </br>and <strong>strong</strong> for ${ newShape } shape' } \ n ` ;
2024-08-13 15:09:04 +02:00
} ) ;
imgSnapshotTest ( flowchartCode , { look } ) ;
} ) ;
it ( ` with markdown htmlLabels:false ` , ( ) = > {
let flowchartCode = ` flowchart ${ direction } \ n ` ;
newShapesSet . forEach ( ( newShape , index ) = > {
2024-09-12 16:58:52 +02:00
flowchartCode += ` n ${ index } --> n ${ index } ${ index } { shape: ${ newShape } , label: 'This is **bold** </br>and <strong>strong</strong> for ${ newShape } shape' } \ n ` ;
2024-08-13 15:09:04 +02:00
} ) ;
2024-08-20 12:48:57 +05:30
imgSnapshotTest ( flowchartCode , {
look ,
htmlLabels : false ,
flowchart : { htmlLabels : false } ,
} ) ;
2024-08-13 15:09:04 +02:00
} ) ;
2024-08-14 18:48:12 +05:30
it ( ` with styles ` , ( ) = > {
2024-08-13 15:09:04 +02:00
let flowchartCode = ` flowchart ${ direction } \ n ` ;
newShapesSet . forEach ( ( newShape , index ) = > {
2024-09-12 16:58:52 +02:00
flowchartCode += ` n ${ index } --> n ${ index } ${ index } { shape: ${ newShape } , label: 'new ${ newShape } shape' } \ n ` ;
2024-08-13 15:09:04 +02:00
flowchartCode += ` style n ${ index } ${ index } fill:#f9f,stroke:#333,stroke-width:4px \ n ` ;
} ) ;
imgSnapshotTest ( flowchartCode , { look } ) ;
} ) ;
it ( ` with classDef ` , ( ) = > {
let flowchartCode = ` flowchart ${ direction } \ n ` ;
flowchartCode += ` classDef customClazz fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5 \ n ` ;
newShapesSet . forEach ( ( newShape , index ) = > {
2024-09-12 16:58:52 +02:00
flowchartCode += ` n ${ index } --> n ${ index } ${ index } { shape: ${ newShape } , label: 'new ${ newShape } shape' } \ n ` ;
2024-08-13 15:09:04 +02:00
flowchartCode += ` n ${ index } ${ index } :::customClazz \ n ` ;
} ) ;
imgSnapshotTest ( flowchartCode , { look } ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;