From 1a6305c0796780745d6c36edd496c80d02f7de37 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomae Date: Sun, 28 Aug 2022 17:22:22 +0200 Subject: [PATCH] Add tests for other boundary properties --- src/diagrams/c4/parser/c4Boundary.spec.js | 69 ++++++++++++++++++++++- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/src/diagrams/c4/parser/c4Boundary.spec.js b/src/diagrams/c4/parser/c4Boundary.spec.js index b531b5bd5..c7130f557 100644 --- a/src/diagrams/c4/parser/c4Boundary.spec.js +++ b/src/diagrams/c4/parser/c4Boundary.spec.js @@ -23,9 +23,9 @@ System(SystemAA, "Internet Banking System") const boundaries = yy.getBoundarys(); expect(boundaries.length).toBe(2); - const onlyShape = boundaries[1]; + const boundary = boundaries[1]; - expect(onlyShape).toEqual({ + expect(boundary).toEqual({ alias: 'b1', label: { text: 'BankBoundary', @@ -42,4 +42,69 @@ System(SystemAA, "Internet Banking System") wrap: false, }); }); + + it('should parse the alias', function () { + c4.parser.parse(`C4Context +${macroName}(b1, "BankBoundary") { +System(SystemAA, "Internet Banking System") +}`); + + expect(c4.parser.yy.getBoundarys()[1]).toMatchObject({ + alias: 'b1', + }); + }); + + it('should parse the label', function () { + c4.parser.parse(`C4Context +${macroName}(b1, "BankBoundary") { +System(SystemAA, "Internet Banking System") +}`); + + expect(c4.parser.yy.getBoundarys()[1]).toMatchObject({ + label: { + text: 'BankBoundary', + }, + }); + }); + + it('should parse the type', function () { + c4.parser.parse(`C4Context +${macroName}(b1, "", "company") { +System(SystemAA, "Internet Banking System") +}`); + + expect(c4.parser.yy.getBoundarys()[1]).toMatchObject({ + type: { text: 'company' }, + }); + }); + + it('should parse a link', function () { + c4.parser.parse(`C4Context +${macroName}(b1, $link="https://github.com/mermaidjs") { +System(SystemAA, "Internet Banking System") +}`); + + expect(c4.parser.yy.getBoundarys()[1]).toMatchObject({ + label: { + text: { + link: 'https://github.com/mermaidjs', + }, + }, + }); + }); + + it('should parse tags', function () { + c4.parser.parse(`C4Context +${macroName}(b1, $tags="tag1,tag2") { +System(SystemAA, "Internet Banking System") +}`); + + expect(c4.parser.yy.getBoundarys()[1]).toMatchObject({ + label: { + text: { + tags: 'tag1,tag2', + }, + }, + }); + }); });