mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
Merge branch 'develop' into develop
This commit is contained in:
commit
39ccad8e5e
135
packages/mermaid/src/diagrams/c4/parser/c4Container.spec.js
Normal file
135
packages/mermaid/src/diagrams/c4/parser/c4Container.spec.js
Normal file
@ -0,0 +1,135 @@
|
||||
import c4Db from '../c4Db.js';
|
||||
import c4 from './c4Diagram.jison';
|
||||
import { setConfig } from '../../../config.js';
|
||||
|
||||
setConfig({
|
||||
securityLevel: 'strict',
|
||||
});
|
||||
|
||||
describe.each([
|
||||
['Container', 'container'],
|
||||
['ContainerDb', 'container_db'],
|
||||
['ContainerQueue', 'container_queue'],
|
||||
['Container_Ext', 'external_container'],
|
||||
['ContainerDb_Ext', 'external_container_db'],
|
||||
['ContainerQueue_Ext', 'external_container_queue'],
|
||||
])('parsing a C4 %s', function (macroName, elementName) {
|
||||
beforeEach(function () {
|
||||
c4.parser.yy = c4Db;
|
||||
c4.parser.yy.clear();
|
||||
});
|
||||
|
||||
it('should parse a C4 diagram with one Container correctly', function () {
|
||||
c4.parser.parse(`C4Context
|
||||
title Container diagram for Internet Banking Container
|
||||
${macroName}(ContainerAA, "Internet Banking Container", "Technology", "Allows customers to view information about their bank accounts, and make payments.")`);
|
||||
|
||||
const yy = c4.parser.yy;
|
||||
|
||||
const shapes = yy.getC4ShapeArray();
|
||||
expect(shapes.length).toBe(1);
|
||||
const onlyShape = shapes[0];
|
||||
|
||||
expect(onlyShape).toEqual({
|
||||
alias: 'ContainerAA',
|
||||
descr: {
|
||||
text: 'Allows customers to view information about their bank accounts, and make payments.',
|
||||
},
|
||||
label: {
|
||||
text: 'Internet Banking Container',
|
||||
},
|
||||
link: undefined,
|
||||
sprite: undefined,
|
||||
tags: undefined,
|
||||
parentBoundary: 'global',
|
||||
typeC4Shape: {
|
||||
text: elementName,
|
||||
},
|
||||
techn: {
|
||||
text: 'Technology',
|
||||
},
|
||||
wrap: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('should parse the alias', function () {
|
||||
c4.parser.parse(`C4Context
|
||||
${macroName}(ContainerAA, "Internet Banking Container")`);
|
||||
|
||||
expect(c4.parser.yy.getC4ShapeArray()[0]).toMatchObject({
|
||||
alias: 'ContainerAA',
|
||||
});
|
||||
});
|
||||
|
||||
it('should parse the label', function () {
|
||||
c4.parser.parse(`C4Context
|
||||
${macroName}(ContainerAA, "Internet Banking Container")`);
|
||||
|
||||
expect(c4.parser.yy.getC4ShapeArray()[0]).toMatchObject({
|
||||
label: {
|
||||
text: 'Internet Banking Container',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should parse the technology', function () {
|
||||
c4.parser.parse(`C4Context
|
||||
${macroName}(ContainerAA, "", "Java")`);
|
||||
|
||||
expect(c4.parser.yy.getC4ShapeArray()[0]).toMatchObject({
|
||||
techn: {
|
||||
text: 'Java',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should parse the description', function () {
|
||||
c4.parser.parse(`C4Context
|
||||
${macroName}(ContainerAA, "", "", "Allows customers to view information about their bank accounts, and make payments.")`);
|
||||
|
||||
expect(c4.parser.yy.getC4ShapeArray()[0]).toMatchObject({
|
||||
descr: {
|
||||
text: 'Allows customers to view information about their bank accounts, and make payments.',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should parse a sprite', function () {
|
||||
c4.parser.parse(`C4Context
|
||||
${macroName}(ContainerAA, $sprite="users")`);
|
||||
|
||||
expect(c4.parser.yy.getC4ShapeArray()[0]).toMatchObject({
|
||||
label: {
|
||||
text: {
|
||||
sprite: 'users',
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should parse a link', function () {
|
||||
c4.parser.parse(`C4Context
|
||||
${macroName}(ContainerAA, $link="https://github.com/mermaidjs")`);
|
||||
|
||||
expect(c4.parser.yy.getC4ShapeArray()[0]).toMatchObject({
|
||||
label: {
|
||||
text: {
|
||||
link: 'https://github.com/mermaidjs',
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should parse tags', function () {
|
||||
c4.parser.parse(`C4Context
|
||||
${macroName}(ContainerAA, $tags="tag1,tag2")`);
|
||||
|
||||
expect(c4.parser.yy.getC4ShapeArray()[0]).toMatchObject({
|
||||
label: {
|
||||
text: {
|
||||
tags: 'tag1,tag2',
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
@ -167,10 +167,10 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multiline");}
|
||||
"UpdateRelStyle" { this.begin("update_rel_style"); return 'UPDATE_REL_STYLE';}
|
||||
"UpdateLayoutConfig" { this.begin("update_layout_config"); return 'UPDATE_LAYOUT_CONFIG';}
|
||||
|
||||
<person,person_ext,system_ext_queue,system_ext_db,system_ext,system_queue,system_db,system,boundary,enterprise_boundary,system_boundary,container_ext_db,container_ext,container_queue,container_db,container,container_boundary,component_ext_db,component_ext,component_queue,component_db,component,node,node_l,node_r,rel,birel,rel_u,rel_d,rel_l,rel_r,rel_b,rel_index,update_el_style,update_rel_style,update_layout_config><<EOF>> return "EOF_IN_STRUCT";
|
||||
<person,person_ext,system_ext_queue,system_ext_db,system_ext,system_queue,system_db,system,boundary,enterprise_boundary,system_boundary,container_ext_db,container_ext,container_queue,container_db,container,container_boundary,component_ext_db,component_ext,component_queue,component_db,component,node,node_l,node_r,rel,birel,rel_u,rel_d,rel_l,rel_r,rel_b,rel_index,update_el_style,update_rel_style,update_layout_config>[(][ ]*[,] { this.begin("attribute"); return "ATTRIBUTE_EMPTY";}
|
||||
<person,person_ext,system_ext_queue,system_ext_db,system_ext,system_queue,system_db,system,boundary,enterprise_boundary,system_boundary,container_ext_db,container_ext,container_queue,container_db,container,container_boundary,component_ext_db,component_ext,component_queue,component_db,component,node,node_l,node_r,rel,birel,rel_u,rel_d,rel_l,rel_r,rel_b,rel_index,update_el_style,update_rel_style,update_layout_config>[(] { this.begin("attribute"); }
|
||||
<person,person_ext,system_ext_queue,system_ext_db,system_ext,system_queue,system_db,system,boundary,enterprise_boundary,system_boundary,container_ext_db,container_ext,container_queue,container_db,container,container_boundary,component_ext_db,component_ext,component_queue,component_db,component,node,node_l,node_r,rel,birel,rel_u,rel_d,rel_l,rel_r,rel_b,rel_index,update_el_style,update_rel_style,update_layout_config,attribute>[)] { this.popState();this.popState();}
|
||||
<person,person_ext,system_ext_queue,system_ext_db,system_ext,system_queue,system_db,system,boundary,enterprise_boundary,system_boundary,container_ext_db,container_ext_queue,container_ext,container_queue,container_db,container,container_boundary,component_ext_db,component_ext,component_queue,component_db,component,node,node_l,node_r,rel,birel,rel_u,rel_d,rel_l,rel_r,rel_b,rel_index,update_el_style,update_rel_style,update_layout_config><<EOF>> return "EOF_IN_STRUCT";
|
||||
<person,person_ext,system_ext_queue,system_ext_db,system_ext,system_queue,system_db,system,boundary,enterprise_boundary,system_boundary,container_ext_db,container_ext_queue,container_ext,container_queue,container_db,container,container_boundary,component_ext_db,component_ext,component_queue,component_db,component,node,node_l,node_r,rel,birel,rel_u,rel_d,rel_l,rel_r,rel_b,rel_index,update_el_style,update_rel_style,update_layout_config>[(][ ]*[,] { this.begin("attribute"); return "ATTRIBUTE_EMPTY";}
|
||||
<person,person_ext,system_ext_queue,system_ext_db,system_ext,system_queue,system_db,system,boundary,enterprise_boundary,system_boundary,container_ext_db,container_ext_queue,container_ext,container_queue,container_db,container,container_boundary,component_ext_db,component_ext,component_queue,component_db,component,node,node_l,node_r,rel,birel,rel_u,rel_d,rel_l,rel_r,rel_b,rel_index,update_el_style,update_rel_style,update_layout_config>[(] { this.begin("attribute"); }
|
||||
<person,person_ext,system_ext_queue,system_ext_db,system_ext,system_queue,system_db,system,boundary,enterprise_boundary,system_boundary,container_ext_db,container_ext_queue,container_ext,container_queue,container_db,container,container_boundary,component_ext_db,component_ext,component_queue,component_db,component,node,node_l,node_r,rel,birel,rel_u,rel_d,rel_l,rel_r,rel_b,rel_index,update_el_style,update_rel_style,update_layout_config,attribute>[)] { this.popState();this.popState();}
|
||||
|
||||
<attribute>",," { return 'ATTRIBUTE_EMPTY';}
|
||||
<attribute>"," { }
|
||||
|
Loading…
x
Reference in New Issue
Block a user