From b86476331fe74f4332f9ccd7de45be8fb82351b8 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomae Date: Sun, 28 Aug 2022 17:14:19 +0200 Subject: [PATCH] Add first test for Boundary --- src/diagrams/c4/parser/c4Boundary.spec.js | 45 +++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/diagrams/c4/parser/c4Boundary.spec.js diff --git a/src/diagrams/c4/parser/c4Boundary.spec.js b/src/diagrams/c4/parser/c4Boundary.spec.js new file mode 100644 index 000000000..b531b5bd5 --- /dev/null +++ b/src/diagrams/c4/parser/c4Boundary.spec.js @@ -0,0 +1,45 @@ +import c4Db from '../c4Db'; +import c4 from './c4Diagram.jison'; +import { setConfig } from '../../../config'; + +setConfig({ + securityLevel: 'strict', +}); + +describe.each(['Boundary'])('parsing a C4 %s', function (macroName) { + beforeEach(function () { + c4.parser.yy = c4Db; + c4.parser.yy.clear(); + }); + + it('should parse a C4 diagram with one Boundary correctly', function () { + c4.parser.parse(`C4Context +title System Context diagram for Internet Banking System +${macroName}(b1, "BankBoundary") { +System(SystemAA, "Internet Banking System") +}`); + + const yy = c4.parser.yy; + + const boundaries = yy.getBoundarys(); + expect(boundaries.length).toBe(2); + const onlyShape = boundaries[1]; + + expect(onlyShape).toEqual({ + alias: 'b1', + label: { + text: 'BankBoundary', + }, + // TODO: Why are link, and tags undefined instead of not appearing at all? + // Compare to Person where they don't show up. + link: undefined, + tags: undefined, + parentBoundary: 'global', + type: { + // TODO: Why is this `system` instead of `boundary`? + text: 'system', + }, + wrap: false, + }); + }); +});