From 92f0c8f8b14407b2c3e0064f2b22bf7dcf55eca6 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomae Date: Sat, 27 Aug 2022 15:29:23 +0200 Subject: [PATCH] Add test for structure of Person_Ext --- src/diagrams/c4/parser/c4PersonExt.spec.js | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/diagrams/c4/parser/c4PersonExt.spec.js diff --git a/src/diagrams/c4/parser/c4PersonExt.spec.js b/src/diagrams/c4/parser/c4PersonExt.spec.js new file mode 100644 index 000000000..71faabdc3 --- /dev/null +++ b/src/diagrams/c4/parser/c4PersonExt.spec.js @@ -0,0 +1,44 @@ +import c4Db from '../c4Db'; +import c4 from './c4Diagram.jison'; +import { setConfig } from '../../../config'; + +setConfig({ + securityLevel: 'strict', +}); + +describe('parsing a C4 diagram', function () { + beforeEach(function () { + c4.parser.yy = c4Db; + c4.parser.yy.clear(); + }); + + it('should parse a C4 diagram with one Person_Ext correctly', function () { + c4.parser.parse(`C4Context +title System Context diagram for Internet Banking System +Person_Ext(customerA, "Banking Customer A", "A customer of the bank, with personal bank accounts.")`); + + const yy = c4.parser.yy; + + const shapes = yy.getC4ShapeArray(); + expect(shapes.length).toBe(1); + const onlyShape = shapes[0]; + + expect(onlyShape).toEqual({ + alias: 'customerA', + descr: { + text: 'A customer of the bank, with personal bank accounts.', + }, + label: { + text: 'Banking Customer A', + }, + link: undefined, + sprite: undefined, + tags: undefined, + parentBoundary: 'global', + typeC4Shape: { + text: 'external_person', + }, + wrap: false, + }); + }); +});