| 1 | import { imgSnapshotTest } from '../../helpers/util'; |
| 2 | /* eslint-disable no-useless-escape */ |
| 3 | describe('Block diagram', () => { |
| 4 | it('BL1: should calculate the block widths', () => { |
| 5 | imgSnapshotTest( |
| 6 | `block-beta |
| 7 | columns 2 |
| 8 | block |
| 9 | id2["I am a wide one"] |
| 10 | id1 |
| 11 | end |
| 12 | id["Next row"] |
| 13 | ` |
| 14 | ); |
| 15 | }); |
| 16 | |
| 17 | it('BL2: should handle columns statement in sub-blocks', () => { |
| 18 | imgSnapshotTest( |
| 19 | `block |
| 20 | id1["Hello"] |
| 21 | block |
| 22 | columns 3 |
| 23 | id2["to"] |
| 24 | id3["the"] |
| 25 | id4["World"] |
| 26 | id5["World"] |
| 27 | end |
| 28 | `, |
| 29 | {} |
| 30 | ); |
| 31 | }); |
| 32 | |
| 33 | it('BL3: should align block widths and handle columns statement in sub-blocks', () => { |
| 34 | imgSnapshotTest( |
| 35 | `block |
| 36 | block |
| 37 | columns 1 |
| 38 | id1 |
| 39 | id2 |
| 40 | id2.1 |
| 41 | end |
| 42 | id3 |
| 43 | id4 |
| 44 | `, |
| 45 | {} |
| 46 | ); |
| 47 | }); |
| 48 | |
| 49 | it('BL4: should align block widths and handle columns statements in deeper sub-blocks then 1 level', () => { |
| 50 | imgSnapshotTest( |
| 51 | `block |
| 52 | columns 1 |
| 53 | block |
| 54 | columns 1 |
| 55 | block |
| 56 | columns 3 |
| 57 | id1 |
| 58 | id2 |
| 59 | id2.1(("XYZ")) |
| 60 | end |
| 61 | id48 |
| 62 | end |
| 63 | id3 |
| 64 | `, |
| 65 | {} |
| 66 | ); |
| 67 | }); |
| 68 | |
| 69 | it('BL5: should align block widths and handle columns statements in deeper sub-blocks then 1 level (alt)', () => { |
| 70 | imgSnapshotTest( |
| 71 | `block |
| 72 | columns 1 |
| 73 | block |
| 74 | id1 |
| 75 | id2 |
| 76 | block |
| 77 | columns 1 |
| 78 | id3("Wider then") |
| 79 | id5(("id5")) |
| 80 | end |
| 81 | end |
| 82 | id4 |
| 83 | `, |
| 84 | {} |
| 85 | ); |
| 86 | }); |
| 87 | |
| 88 | it('BL6: should handle block arrows and spece statements', () => { |
| 89 | imgSnapshotTest( |
| 90 | `block |
| 91 | columns 3 |
| 92 | space:3 |
| 93 | ida idb idc |
| 94 | id1 id2 |
| 95 | blockArrowId<["Label"]>(right) |
| 96 | blockArrowId2<["Label"]>(left) |
| 97 | blockArrowId3<["Label"]>(up) |
| 98 | blockArrowId4<["Label"]>(down) |
| 99 | blockArrowId5<["Label"]>(x) |
| 100 | blockArrowId6<["Label"]>(y) |
| 101 | blockArrowId6<["Label"]>(x, down) |
| 102 | `, |
| 103 | {} |
| 104 | ); |
| 105 | }); |
| 106 | |
| 107 | it('BL7: should handle different types of edges', () => { |
| 108 | imgSnapshotTest( |
| 109 | `block |
| 110 | columns 3 |
| 111 | A space:5 |
| 112 | A --o B |
| 113 | A --> C |
| 114 | A --x D |
| 115 | `, |
| 116 | {} |
| 117 | ); |
| 118 | }); |
| 119 | |
| 120 | it('BL8: should handle sub-blocks without columns statements', () => { |
| 121 | imgSnapshotTest( |
| 122 | `block |
| 123 | columns 2 |
| 124 | C A B |
| 125 | block |
| 126 | D |
| 127 | E |
| 128 | end |
| 129 | `, |
| 130 | {} |
| 131 | ); |
| 132 | }); |
| 133 | |
| 134 | it('BL9: should handle edges from blocks in sub blocks to other blocks', () => { |
| 135 | imgSnapshotTest( |
| 136 | `block |
| 137 | columns 3 |
| 138 | B space |
| 139 | block |
| 140 | D |
| 141 | end |
| 142 | D --> B |
| 143 | `, |
| 144 | {} |
| 145 | ); |
| 146 | }); |
| 147 | |
| 148 | it('BL10: should handle edges from composite blocks', () => { |
| 149 | imgSnapshotTest( |
| 150 | `block |
| 151 | columns 3 |
| 152 | B space |
| 153 | block BL |
| 154 | D |
| 155 | end |
| 156 | BL --> B |
| 157 | `, |
| 158 | {} |
| 159 | ); |
| 160 | }); |
| 161 | |
| 162 | it('BL11: should handle edges to composite blocks', () => { |
| 163 | imgSnapshotTest( |
| 164 | `block |
| 165 | columns 3 |
| 166 | B space |
| 167 | block BL |
| 168 | D |
| 169 | end |
| 170 | B --> BL |
| 171 | `, |
| 172 | {} |
| 173 | ); |
| 174 | }); |
| 175 | |
| 176 | it('BL12: edges should handle labels', () => { |
| 177 | imgSnapshotTest( |
| 178 | `block |
| 179 | A |
| 180 | space |
| 181 | A -- "apa" --> E |
| 182 | `, |
| 183 | {} |
| 184 | ); |
| 185 | }); |
| 186 | |
| 187 | it('BL13: should handle block arrows in different directions', () => { |
| 188 | imgSnapshotTest( |
| 189 | `block |
| 190 | columns 3 |
| 191 | space blockArrowId1<["down"]>(down) space |
| 192 | blockArrowId2<["right"]>(right) blockArrowId3<["Sync"]>(x, y) blockArrowId4<["left"]>(left) |
| 193 | space blockArrowId5<["up"]>(up) space |
| 194 | blockArrowId6<["x"]>(x) space blockArrowId7<["y"]>(y) |
| 195 | `, |
| 196 | {} |
| 197 | ); |
| 198 | }); |
| 199 | |
| 200 | it('BL14: should style statements and class statements', () => { |
| 201 | imgSnapshotTest( |
| 202 | `block |
| 203 | A |
| 204 | B |
| 205 | classDef blue fill:#66f,stroke:#333,stroke-width:2px; |
| 206 | class A blue |
| 207 | style B fill:#f9F,stroke:#333,stroke-width:4px |
| 208 | `, |
| 209 | {} |
| 210 | ); |
| 211 | }); |
| 212 | |
| 213 | it('BL15: width alignment - D and E should share available space', () => { |
| 214 | imgSnapshotTest( |
| 215 | `block |
| 216 | block |
| 217 | D |
| 218 | E |
| 219 | end |
| 220 | db("This is the text in the box") |
| 221 | `, |
| 222 | {} |
| 223 | ); |
| 224 | }); |
| 225 | |
| 226 | it('BL16: width alignment - C should be as wide as the composite block', () => { |
| 227 | imgSnapshotTest( |
| 228 | `block |
| 229 | block |
| 230 | A("This is the text") |
| 231 | B |
| 232 | end |
| 233 | C |
| 234 | `, |
| 235 | {} |
| 236 | ); |
| 237 | }); |
| 238 | |
| 239 | it('BL17: width alignment - blocks should be equal in width', () => { |
| 240 | imgSnapshotTest( |
| 241 | `block |
| 242 | A("This is the text") |
| 243 | B |
| 244 | C |
| 245 | `, |
| 246 | {} |
| 247 | ); |
| 248 | }); |
| 249 | |
| 250 | it('BL18: block types 1 - square, rounded and circle', () => { |
| 251 | imgSnapshotTest( |
| 252 | `block |
| 253 | A["square"] |
| 254 | B("rounded") |
| 255 | C(("circle")) |
| 256 | `, |
| 257 | {} |
| 258 | ); |
| 259 | }); |
| 260 | |
| 261 | it('BL19: block types 2 - odd, diamond and hexagon', () => { |
| 262 | imgSnapshotTest( |
| 263 | `block |
| 264 | A>"rect_left_inv_arrow"] |
| 265 | B{"diamond"} |
| 266 | C{{"hexagon"}} |
| 267 | `, |
| 268 | {} |
| 269 | ); |
| 270 | }); |
| 271 | |
| 272 | it('BL20: block types 3 - stadium', () => { |
| 273 | imgSnapshotTest( |
| 274 | `block |
| 275 | A(["stadium"]) |
| 276 | `, |
| 277 | {} |
| 278 | ); |
| 279 | }); |
| 280 | |
| 281 | it('BL21: block types 4 - lean right, lean left, trapezoid and inv trapezoid', () => { |
| 282 | imgSnapshotTest( |
| 283 | `block |
| 284 | A[/"lean right"/] |
| 285 | B[\"lean left"\] |
| 286 | C[/"trapezoid"\] |
| 287 | D[\"trapezoid alt"/] |
| 288 | `, |
| 289 | {} |
| 290 | ); |
| 291 | }); |
| 292 | |
| 293 | it('BL22: block types 1 - square, rounded and circle', () => { |
| 294 | imgSnapshotTest( |
| 295 | `block |
| 296 | A["square"] |
| 297 | B("rounded") |
| 298 | C(("circle")) |
| 299 | `, |
| 300 | {} |
| 301 | ); |
| 302 | }); |
| 303 | |
| 304 | it('BL23: sizing - it should be possible to make a block wider', () => { |
| 305 | imgSnapshotTest( |
| 306 | `block |
| 307 | A("rounded"):2 |
| 308 | B:2 |
| 309 | C |
| 310 | `, |
| 311 | {} |
| 312 | ); |
| 313 | }); |
| 314 | |
| 315 | it('BL24: sizing - it should be possible to make a composite block wider', () => { |
| 316 | imgSnapshotTest( |
| 317 | `block |
| 318 | block:2 |
| 319 | A |
| 320 | end |
| 321 | B |
| 322 | `, |
| 323 | {} |
| 324 | ); |
| 325 | }); |
| 326 | |
| 327 | it('BL25: block in the middle with space on each side', () => { |
| 328 | imgSnapshotTest( |
| 329 | `block |
| 330 | columns 3 |
| 331 | space |
| 332 | middle["In the middle"] |
| 333 | space |
| 334 | `, |
| 335 | {} |
| 336 | ); |
| 337 | }); |
| 338 | it('BL26: space and an edge', () => { |
| 339 | imgSnapshotTest( |
| 340 | `block |
| 341 | columns 5 |
| 342 | A space B |
| 343 | A --x B |
| 344 | `, |
| 345 | {} |
| 346 | ); |
| 347 | }); |
| 348 | it('BL27: block sizes for regular blocks', () => { |
| 349 | imgSnapshotTest( |
| 350 | `block |
| 351 | columns 3 |
| 352 | a["A wide one"] b:2 c:2 d |
| 353 | `, |
| 354 | {} |
| 355 | ); |
| 356 | }); |
| 357 | it('BL28: composite block with a set width - f should use the available space', () => { |
| 358 | imgSnapshotTest( |
| 359 | `block |
| 360 | columns 3 |
| 361 | a:3 |
| 362 | block:e:3 |
| 363 | f |
| 364 | end |
| 365 | g |
| 366 | `, |
| 367 | {} |
| 368 | ); |
| 369 | }); |
| 370 | |
| 371 | it('BL29: composite block with a set width - f and g should split the available space', () => { |
| 372 | imgSnapshotTest( |
| 373 | `block |
| 374 | columns 3 |
| 375 | a:3 |
| 376 | block:e:3 |
| 377 | f |
| 378 | g |
| 379 | end |
| 380 | h |
| 381 | i |
| 382 | j |
| 383 | `, |
| 384 | {} |
| 385 | ); |
| 386 | }); |
| 387 | |
| 388 | it('BL30: block should overflow if too wide for columns', () => { |
| 389 | imgSnapshotTest( |
| 390 | `block-beta |
| 391 | columns 2 |
| 392 | fit:2 |
| 393 | overflow:3 |
| 394 | short:1 |
| 395 | also_overflow:2 |
| 396 | `, |
| 397 | {} |
| 398 | ); |
| 399 | }); |
| 400 | |
| 401 | it('BL31: edge without arrow syntax should render with no arrowheads', () => { |
| 402 | imgSnapshotTest( |
| 403 | `block-beta |
| 404 | a |
| 405 | b |
| 406 | a --- b |
| 407 | `, |
| 408 | {} |
| 409 | ); |
| 410 | }); |
| 411 | }); |
| 412 | |