mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-12 20:09:46 +02:00
Initial checkin
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
import { parser } from './parser/classDiagram';
|
||||
import classDb from './classDb';
|
||||
|
||||
describe('class diagram, ', function() {
|
||||
describe('when parsing an info graph it', function() {
|
||||
beforeEach(function() {
|
||||
describe('class diagram, ', function () {
|
||||
describe('when parsing an info graph it', function () {
|
||||
beforeEach(function () {
|
||||
parser.yy = classDb;
|
||||
});
|
||||
|
||||
it('should handle relation definitions', function() {
|
||||
it('should handle relation definitions', function () {
|
||||
const str =
|
||||
'classDiagram\n' +
|
||||
'Class01 <|-- Class02\n' +
|
||||
@@ -19,7 +19,7 @@ describe('class diagram, ', function() {
|
||||
|
||||
parser.parse(str);
|
||||
});
|
||||
it('should handle relation definition of different types and directions', function() {
|
||||
it('should handle relation definition of different types and directions', function () {
|
||||
const str =
|
||||
'classDiagram\n' +
|
||||
'Class11 <|.. Class12\n' +
|
||||
@@ -31,7 +31,7 @@ describe('class diagram, ', function() {
|
||||
parser.parse(str);
|
||||
});
|
||||
|
||||
it('should handle cardinality and labels', function() {
|
||||
it('should handle cardinality and labels', function () {
|
||||
const str =
|
||||
'classDiagram\n' +
|
||||
'Class01 "1" *-- "many" Class02 : contains\n' +
|
||||
@@ -66,7 +66,7 @@ describe('class diagram, ', function() {
|
||||
parser.parse(str);
|
||||
});
|
||||
|
||||
it('should handle method statements', function() {
|
||||
it('should handle method statements', function () {
|
||||
const str =
|
||||
'classDiagram\n' +
|
||||
'Object <|-- ArrayList\n' +
|
||||
@@ -76,7 +76,7 @@ describe('class diagram, ', function() {
|
||||
|
||||
parser.parse(str);
|
||||
});
|
||||
it('should handle parsing of method statements grouped by brackets', function() {
|
||||
it('should handle parsing of method statements grouped by brackets', function () {
|
||||
const str =
|
||||
'classDiagram\n' +
|
||||
'class Dummy_Class {\n' +
|
||||
@@ -92,7 +92,7 @@ describe('class diagram, ', function() {
|
||||
parser.parse(str);
|
||||
});
|
||||
|
||||
it('should handle parsing of separators', function() {
|
||||
it('should handle parsing of separators', function () {
|
||||
const str =
|
||||
'classDiagram\n' +
|
||||
'class Foo1 {\n' +
|
||||
@@ -126,12 +126,12 @@ describe('class diagram, ', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('when fetching data from an classDiagram graph it', function() {
|
||||
beforeEach(function() {
|
||||
describe('when fetching data from an classDiagram graph it', function () {
|
||||
beforeEach(function () {
|
||||
parser.yy = classDb;
|
||||
parser.yy.clear();
|
||||
});
|
||||
it('should handle relation definitions EXTENSION', function() {
|
||||
it('should handle relation definitions EXTENSION', function () {
|
||||
const str = 'classDiagram\n' + 'Class01 <|-- Class02';
|
||||
|
||||
parser.parse(str);
|
||||
@@ -144,7 +144,7 @@ describe('class diagram, ', function() {
|
||||
expect(relations[0].relation.type2).toBe('none');
|
||||
expect(relations[0].relation.lineType).toBe(classDb.lineType.LINE);
|
||||
});
|
||||
it('should handle relation definitions AGGREGATION and dotted line', function() {
|
||||
it('should handle relation definitions AGGREGATION and dotted line', function () {
|
||||
const str = 'classDiagram\n' + 'Class01 o.. Class02';
|
||||
|
||||
parser.parse(str);
|
||||
@@ -157,7 +157,7 @@ describe('class diagram, ', function() {
|
||||
expect(relations[0].relation.type2).toBe('none');
|
||||
expect(relations[0].relation.lineType).toBe(classDb.lineType.DOTTED_LINE);
|
||||
});
|
||||
it('should handle relation definitions COMPOSITION on both sides', function() {
|
||||
it('should handle relation definitions COMPOSITION on both sides', function () {
|
||||
const str = 'classDiagram\n' + 'Class01 *--* Class02';
|
||||
|
||||
parser.parse(str);
|
||||
@@ -170,7 +170,7 @@ describe('class diagram, ', function() {
|
||||
expect(relations[0].relation.type2).toBe(classDb.relationType.COMPOSITION);
|
||||
expect(relations[0].relation.lineType).toBe(classDb.lineType.LINE);
|
||||
});
|
||||
it('should handle relation definitions no types', function() {
|
||||
it('should handle relation definitions no types', function () {
|
||||
const str = 'classDiagram\n' + 'Class01 -- Class02';
|
||||
|
||||
parser.parse(str);
|
||||
@@ -183,7 +183,7 @@ describe('class diagram, ', function() {
|
||||
expect(relations[0].relation.type2).toBe('none');
|
||||
expect(relations[0].relation.lineType).toBe(classDb.lineType.LINE);
|
||||
});
|
||||
it('should handle relation definitions with type only on right side', function() {
|
||||
it('should handle relation definitions with type only on right side', function () {
|
||||
const str = 'classDiagram\n' + 'Class01 --|> Class02';
|
||||
|
||||
parser.parse(str);
|
||||
@@ -197,7 +197,7 @@ describe('class diagram, ', function() {
|
||||
expect(relations[0].relation.lineType).toBe(classDb.lineType.LINE);
|
||||
});
|
||||
|
||||
it('should handle multiple classes and relation definitions', function() {
|
||||
it('should handle multiple classes and relation definitions', function () {
|
||||
const str =
|
||||
'classDiagram\n' +
|
||||
'Class01 <|-- Class02\n' +
|
||||
@@ -223,7 +223,7 @@ describe('class diagram, ', function() {
|
||||
expect(relations[3].relation.lineType).toBe(classDb.lineType.DOTTED_LINE);
|
||||
});
|
||||
|
||||
it('should handle class annotations', function() {
|
||||
it('should handle class annotations', function () {
|
||||
const str = 'classDiagram\n' + 'class Class1\n' + '<<interface>> Class1';
|
||||
parser.parse(str);
|
||||
|
||||
@@ -234,7 +234,7 @@ describe('class diagram, ', function() {
|
||||
expect(testClass.annotations[0]).toBe('interface');
|
||||
});
|
||||
|
||||
it('should handle class annotations with members and methods', function() {
|
||||
it('should handle class annotations with members and methods', function () {
|
||||
const str =
|
||||
'classDiagram\n' +
|
||||
'class Class1\n' +
|
||||
@@ -250,7 +250,7 @@ describe('class diagram, ', function() {
|
||||
expect(testClass.annotations[0]).toBe('interface');
|
||||
});
|
||||
|
||||
it('should handle class annotations in brackets', function() {
|
||||
it('should handle class annotations in brackets', function () {
|
||||
const str = 'classDiagram\n' + 'class Class1 {\n' + '<<interface>>\n' + '}';
|
||||
parser.parse(str);
|
||||
|
||||
@@ -261,7 +261,7 @@ describe('class diagram, ', function() {
|
||||
expect(testClass.annotations[0]).toBe('interface');
|
||||
});
|
||||
|
||||
it('should handle class annotations in brackets with members and methods', function() {
|
||||
it('should handle class annotations in brackets with members and methods', function () {
|
||||
const str =
|
||||
'classDiagram\n' +
|
||||
'class Class1 {\n' +
|
||||
@@ -278,7 +278,7 @@ describe('class diagram, ', function() {
|
||||
expect(testClass.annotations[0]).toBe('interface');
|
||||
});
|
||||
|
||||
it('should add bracket members in right order', function() {
|
||||
it('should add bracket members in right order', function () {
|
||||
const str =
|
||||
'classDiagram\n' +
|
||||
'class Class1 {\n' +
|
||||
@@ -297,5 +297,100 @@ describe('class diagram, ', function() {
|
||||
expect(testClass.methods[0]).toBe('test()');
|
||||
expect(testClass.methods[1]).toBe('foo()');
|
||||
});
|
||||
|
||||
it('should handle a comment', function () {
|
||||
const str =
|
||||
'classDiagram\n' +
|
||||
'%% Comment \n' +
|
||||
'class Class1 {\n' +
|
||||
'int : test\n' +
|
||||
'string : foo\n' +
|
||||
'test()\n' +
|
||||
'foo()\n' +
|
||||
'}';
|
||||
|
||||
parser.parse(str);
|
||||
});
|
||||
|
||||
// it('should handle comments at the start', function () {
|
||||
// const str =
|
||||
// '%% Comment\n' +
|
||||
// 'class Class1 {\n' +
|
||||
// 'int : test\n' +
|
||||
// 'string : foo\n' +
|
||||
// 'test()\n' +
|
||||
// 'foo()\n' +
|
||||
// '}';
|
||||
// parser.parse(str);
|
||||
// });
|
||||
|
||||
// it('should handle comments at the end', function () {
|
||||
// const str =
|
||||
// 'classDiagram\n' +
|
||||
// 'class Class1 {\n' +
|
||||
// 'int : test\n' +
|
||||
// 'string : foo\n' +
|
||||
// 'test()\n' +
|
||||
// 'foo()\n' +
|
||||
// '\n}' +
|
||||
// '%% Comment\n';
|
||||
|
||||
// parser.parse(str);
|
||||
// });
|
||||
|
||||
// it('should handle comments at the end no trailing newline', function () {
|
||||
// const str =
|
||||
// 'class Class1 {\n' +
|
||||
// 'int : test\n' +
|
||||
// 'string : foo\n' +
|
||||
// 'test()\n' +
|
||||
// 'foo()\n' +
|
||||
// '}\n' +
|
||||
// '%% Comment';
|
||||
|
||||
// parser.parse(str);
|
||||
// });
|
||||
|
||||
// it('should handle comments at the end many trailing newlines', function () {
|
||||
// const str =
|
||||
// 'classDiagram\n' +
|
||||
// '%% Comment\n\n\n\n\n' +
|
||||
// 'class Class1 {\n' +
|
||||
// 'int : test\n' +
|
||||
// 'string : foo\n' +
|
||||
// 'test()\n' +
|
||||
// 'foo()\n' +
|
||||
// '}';
|
||||
|
||||
// parser.parse(str);
|
||||
// });
|
||||
|
||||
// it('should handle a comment with blank rows in-between', function () {
|
||||
// const str =
|
||||
// 'classDiagram\n\n\n' +
|
||||
// '%% Comment\n\n' +
|
||||
// 'class Class1 {\n' +
|
||||
// 'int : test\n' +
|
||||
// 'string : foo\n' +
|
||||
// 'test()\n' +
|
||||
// 'foo()\n' +
|
||||
// '}';
|
||||
|
||||
// parser.parse(str);
|
||||
// });
|
||||
|
||||
// it('should handle a comment with mermaid class diagram code in them', function () {
|
||||
// const str =
|
||||
// 'classDiagram\n' +
|
||||
// '%% Comment Class01 <|-- Class02\n' +
|
||||
// 'class Class1 {\n' +
|
||||
// 'int : test\n' +
|
||||
// 'string : foo\n' +
|
||||
// 'test()\n' +
|
||||
// 'foo()\n' +
|
||||
// '}';
|
||||
|
||||
// parser.parse(str);
|
||||
//});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user