mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-02-04 07:13:25 +08:00
test(er): improve tests on multiple key constraints
This commit is contained in:
parent
3066a4b43a
commit
dc0a46f742
@ -191,19 +191,25 @@ describe('when parsing ER diagram it...', function () {
|
||||
});
|
||||
|
||||
it('should allow an entity with attributes that have many constraints and comments', function () {
|
||||
const entity = 'BOOK';
|
||||
const attribute1 = 'int customer_number PK,FK "comment"';
|
||||
const attribute2 = 'datetime customer_status_start_datetime PK,UK';
|
||||
const attribute3 = 'string customer_name';
|
||||
const entity = 'CUSTOMER';
|
||||
const attribute1 = 'int customer_number PK, FK "comment1"';
|
||||
const attribute2 = 'datetime customer_status_start_datetime PK,UK, FK';
|
||||
const attribute3 = 'datetime customer_status_end_datetime PK , UK "comment3"';
|
||||
const attribute4 = 'string customer_firstname';
|
||||
const attribute5 = 'string customer_lastname "comment5"';
|
||||
|
||||
erDiagram.parser.parse(
|
||||
`erDiagram\n${entity} {\n${attribute1} \n\n${attribute2}\n${attribute3}\n}`
|
||||
`erDiagram\n${entity} {\n${attribute1}\n${attribute2}\n${attribute3}\n${attribute4}\n${attribute5}\n}`
|
||||
);
|
||||
const entities = erDb.getEntities();
|
||||
expect(entities[entity].attributes[0].attributeKeyTypeList).toEqual(['PK', 'FK']);
|
||||
expect(entities[entity].attributes[0].attributeComment).toBe('comment');
|
||||
expect(entities[entity].attributes[1].attributeKeyTypeList).toEqual(['PK', 'UK']);
|
||||
expect(entities[entity].attributes[2].attributeKeyTypeList).toBeUndefined();
|
||||
expect(entities[entity].attributes[0].attributeComment).toBe('comment1');
|
||||
expect(entities[entity].attributes[1].attributeKeyTypeList).toEqual(['PK', 'UK', 'FK']);
|
||||
expect(entities[entity].attributes[2].attributeKeyTypeList).toEqual(['PK', 'UK']);
|
||||
expect(entities[entity].attributes[2].attributeComment).toBe('comment3');
|
||||
expect(entities[entity].attributes[3].attributeKeyTypeList).toBeUndefined();
|
||||
expect(entities[entity].attributes[4].attributeKeyTypeList).toBeUndefined();
|
||||
expect(entities[entity].attributes[4].attributeComment).toBe('comment5');
|
||||
});
|
||||
|
||||
it('should allow an entity with attribute that has a generic type', function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user