mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 14:59:53 +02:00
merge from updated develop
This commit is contained in:
@@ -33,7 +33,7 @@ o\{ return 'ZERO_OR_MORE';
|
||||
\-\- return 'IDENTIFYING';
|
||||
\.\- return 'NON_IDENTIFYING';
|
||||
\-\. return 'NON_IDENTIFYING';
|
||||
[A-Za-z][A-Za-z0-9\-]* return 'ALPHANUM';
|
||||
[A-Za-z][A-Za-z0-9\-_]* return 'ALPHANUM';
|
||||
. return yytext[0];
|
||||
<<EOF>> return 'EOF';
|
||||
|
||||
|
@@ -14,15 +14,32 @@ describe('when parsing ER diagram it...', function() {
|
||||
erDiagram.parser.yy.clear();
|
||||
});
|
||||
|
||||
it ('should allow stand-alone entities with no relationships', function() {
|
||||
const line1 = 'ISLAND';
|
||||
const line2 = 'MAINLAND';
|
||||
erDiagram.parser.parse(`erDiagram\n${line1}\n${line2}`);
|
||||
|
||||
expect(Object.keys(erDb.getEntities()).length).toBe(2);
|
||||
expect(erDb.getRelationships().length).toBe(0);
|
||||
});
|
||||
|
||||
it ('should allow hyphens and underscores in entity names', function() {
|
||||
const line1 = 'DUCK-BILLED-PLATYPUS';
|
||||
const line2 = 'CHARACTER_SET';
|
||||
erDiagram.parser.parse(`erDiagram\n${line1}\n${line2}`);
|
||||
|
||||
const entities = erDb.getEntities();
|
||||
expect(entities.hasOwnProperty('DUCK-BILLED-PLATYPUS')).toBe(true);
|
||||
expect(entities.hasOwnProperty('CHARACTER_SET')).toBe(true);
|
||||
});
|
||||
|
||||
it('should associate two entities correctly', function() {
|
||||
erDiagram.parser.parse('erDiagram\nCAR ||--o{ DRIVER : "insured for"');
|
||||
const entities = erDb.getEntities();
|
||||
const relationships = erDb.getRelationships();
|
||||
const carEntity = entities.CAR;
|
||||
const driverEntity = entities.DRIVER;
|
||||
|
||||
expect(carEntity).toBe('CAR');
|
||||
expect(driverEntity).toBe('DRIVER');
|
||||
expect(entities.hasOwnProperty('CAR')).toBe(true);
|
||||
expect(entities.hasOwnProperty('DRIVER')).toBe(true);
|
||||
expect(relationships.length).toBe(1);
|
||||
expect(relationships[0].relSpec.cardA).toBe(erDb.Cardinality.ZERO_OR_MORE);
|
||||
expect(relationships[0].relSpec.cardB).toBe(erDb.Cardinality.ONLY_ONE);
|
||||
|
Reference in New Issue
Block a user