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, + }); + }); +});