2019-09-11 18:53:05 +02:00
|
|
|
/* eslint-env jest */
|
2019-09-18 18:25:06 +02:00
|
|
|
import { imgSnapshotTest } from '../../helpers/util';
|
2019-09-11 18:53:05 +02:00
|
|
|
|
2019-10-04 23:58:06 +02:00
|
|
|
describe('Class diagram', () => {
|
2019-11-26 11:18:32 -08:00
|
|
|
it('1: should render a simple class diagram', () => {
|
2019-09-18 18:25:06 +02:00
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
2019-09-11 18:53:05 +02:00
|
|
|
classDiagram
|
|
|
|
Class01 <|-- AveryLongClass : Cool
|
2019-10-05 00:46:56 +02:00
|
|
|
<<interface>> Class01
|
2019-09-11 18:53:05 +02:00
|
|
|
Class03 *-- Class04
|
|
|
|
Class05 o-- Class06
|
|
|
|
Class07 .. Class08
|
|
|
|
Class09 --> C2 : Where am i?
|
|
|
|
Class09 --* C3
|
|
|
|
Class09 --|> Class07
|
2020-01-02 19:57:11 +01:00
|
|
|
Class12 <|.. Class08
|
|
|
|
Class11 ..>Class12
|
2019-09-11 18:53:05 +02:00
|
|
|
Class07 : equals()
|
|
|
|
Class07 : Object[] elementData
|
|
|
|
Class01 : size()
|
|
|
|
Class01 : int chimp
|
|
|
|
Class01 : int gorilla
|
2019-11-19 12:18:41 -08:00
|
|
|
Class01 : -int privateChimp
|
|
|
|
Class01 : +int publicGorilla
|
|
|
|
Class01 : #int protectedMarmoset
|
2019-09-11 18:53:05 +02:00
|
|
|
Class08 <--> C2: Cool label
|
2019-10-05 00:05:47 +02:00
|
|
|
class Class10 {
|
2019-10-05 00:46:56 +02:00
|
|
|
<<service>>
|
2019-10-04 23:58:06 +02:00
|
|
|
int id
|
|
|
|
test()
|
|
|
|
}
|
2019-09-11 18:53:05 +02:00
|
|
|
`,
|
2020-01-02 19:57:11 +01:00
|
|
|
{logLevel : 1}
|
2019-09-18 18:25:06 +02:00
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
2019-11-26 11:18:32 -08:00
|
|
|
|
|
|
|
it('2: should render a simple class diagrams with cardinality', () => {
|
2019-10-08 21:46:03 +02:00
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
classDiagram
|
|
|
|
Class01 "1" <|--|> "*" AveryLongClass : Cool
|
|
|
|
<<interface>> Class01
|
|
|
|
Class03 "1" *-- "*" Class04
|
|
|
|
Class05 "1" o-- "many" Class06
|
|
|
|
Class07 "1" .. "*" Class08
|
|
|
|
Class09 "1" --> "*" C2 : Where am i?
|
|
|
|
Class09 "*" --* "*" C3
|
|
|
|
Class09 "1" --|> "1" Class07
|
|
|
|
Class07 : equals()
|
|
|
|
Class07 : Object[] elementData
|
|
|
|
Class01 : size()
|
|
|
|
Class01 : int chimp
|
|
|
|
Class01 : int gorilla
|
|
|
|
Class08 "1" <--> "*" C2: Cool label
|
|
|
|
class Class10 {
|
|
|
|
<<service>>
|
|
|
|
int id
|
|
|
|
test()
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
2019-11-21 11:17:53 -08:00
|
|
|
|
|
|
|
it('should render a simple class diagram with different visibilities', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
classDiagram
|
|
|
|
Class01 <|-- AveryLongClass : Cool
|
|
|
|
<<interface>> Class01
|
2020-06-08 19:21:33 -07:00
|
|
|
Class01 : -privateMethod()
|
|
|
|
Class01 : +publicMethod()
|
|
|
|
Class01 : #protectedMethod()
|
2019-11-21 11:17:53 -08:00
|
|
|
Class01 : -int privateChimp
|
|
|
|
Class01 : +int publicGorilla
|
|
|
|
Class01 : #int protectedMarmoset
|
|
|
|
`,
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
|
|
|
|
2019-11-05 17:45:04 +09:00
|
|
|
it('should render multiple class diagrams', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
[
|
|
|
|
`
|
|
|
|
classDiagram
|
|
|
|
Class01 "1" <|--|> "*" AveryLongClass : Cool
|
|
|
|
<<interface>> Class01
|
|
|
|
Class03 "1" *-- "*" Class04
|
|
|
|
Class05 "1" o-- "many" Class06
|
|
|
|
Class07 "1" .. "*" Class08
|
|
|
|
Class09 "1" --> "*" C2 : Where am i?
|
|
|
|
Class09 "*" --* "*" C3
|
|
|
|
Class09 "1" --|> "1" Class07
|
|
|
|
Class07 : equals()
|
|
|
|
Class07 : Object[] elementData
|
|
|
|
Class01 : size()
|
|
|
|
Class01 : int chimp
|
|
|
|
Class01 : int gorilla
|
|
|
|
Class08 "1" <--> "*" C2: Cool label
|
|
|
|
class Class10 {
|
|
|
|
<<service>>
|
|
|
|
int id
|
|
|
|
test()
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
`
|
|
|
|
classDiagram
|
|
|
|
Class01 "1" <|--|> "*" AveryLongClass : Cool
|
|
|
|
<<interface>> Class01
|
|
|
|
Class03 "1" *-- "*" Class04
|
|
|
|
Class05 "1" o-- "many" Class06
|
|
|
|
Class07 "1" .. "*" Class08
|
|
|
|
Class09 "1" --> "*" C2 : Where am i?
|
|
|
|
Class09 "*" --* "*" C3
|
|
|
|
Class09 "1" --|> "1" Class07
|
|
|
|
Class07 : equals()
|
|
|
|
Class07 : Object[] elementData
|
|
|
|
Class01 : size()
|
|
|
|
Class01 : int chimp
|
|
|
|
Class01 : int gorilla
|
|
|
|
Class08 "1" <--> "*" C2: Cool label
|
|
|
|
class Class10 {
|
|
|
|
<<service>>
|
|
|
|
int id
|
|
|
|
test()
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
],
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
2019-11-26 11:18:32 -08:00
|
|
|
|
|
|
|
it('4: should render a simple class diagram with comments', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
classDiagram
|
|
|
|
%% this is a comment
|
|
|
|
Class01 <|-- AveryLongClass : Cool
|
|
|
|
<<interface>> Class01
|
|
|
|
Class03 *-- Class04
|
|
|
|
Class05 o-- Class06
|
|
|
|
Class07 .. Class08
|
|
|
|
Class09 --> C2 : Where am i?
|
|
|
|
Class09 --* C3
|
|
|
|
Class09 --|> Class07
|
|
|
|
Class07 : equals()
|
|
|
|
Class07 : Object[] elementData
|
|
|
|
Class01 : size()
|
|
|
|
Class01 : int chimp
|
|
|
|
Class01 : int gorilla
|
|
|
|
Class08 <--> C2: Cool label
|
|
|
|
class Class10 {
|
|
|
|
<<service>>
|
|
|
|
int id
|
|
|
|
test()
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
2019-12-09 17:41:26 -08:00
|
|
|
|
|
|
|
it('5: should render a simple class diagram with abstract method', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
classDiagram
|
|
|
|
Class01 <|-- AveryLongClass : Cool
|
2019-12-09 18:13:06 -08:00
|
|
|
Class01 : someMethod()*
|
2019-12-09 17:41:26 -08:00
|
|
|
`,
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('6: should render a simple class diagram with static method', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
classDiagram
|
|
|
|
Class01 <|-- AveryLongClass : Cool
|
2019-12-09 18:13:06 -08:00
|
|
|
Class01 : someMethod()$
|
2019-12-09 17:41:26 -08:00
|
|
|
`,
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
2019-12-11 10:31:27 -08:00
|
|
|
|
2019-12-11 10:34:51 -08:00
|
|
|
it('7: should render a simple class diagram with Generic class', () => {
|
2019-12-05 12:55:46 -08:00
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
classDiagram
|
|
|
|
class Class01~T~
|
|
|
|
Class01 : size()
|
|
|
|
Class01 : int chimp
|
|
|
|
Class01 : int gorilla
|
|
|
|
Class08 <--> C2: Cool label
|
|
|
|
class Class10~T~ {
|
|
|
|
<<service>>
|
|
|
|
int id
|
|
|
|
test()
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
|
|
|
|
2019-12-11 10:34:51 -08:00
|
|
|
it('8: should render a simple class diagram with Generic class and relations', () => {
|
2019-12-05 12:55:46 -08:00
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
classDiagram
|
|
|
|
Class01~T~ <|-- AveryLongClass : Cool
|
|
|
|
Class03~T~ *-- Class04~T~
|
|
|
|
Class01 : size()
|
|
|
|
Class01 : int chimp
|
|
|
|
Class01 : int gorilla
|
|
|
|
Class08 <--> C2: Cool label
|
|
|
|
class Class10~T~ {
|
|
|
|
<<service>>
|
|
|
|
int id
|
|
|
|
test()
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
2019-12-30 17:24:19 -08:00
|
|
|
|
|
|
|
it('9: should render a simple class diagram with clickable link', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
classDiagram
|
|
|
|
Class01~T~ <|-- AveryLongClass : Cool
|
|
|
|
Class03~T~ *-- Class04~T~
|
|
|
|
Class01 : size()
|
|
|
|
Class01 : int chimp
|
|
|
|
Class01 : int gorilla
|
|
|
|
Class08 <--> C2: Cool label
|
|
|
|
class Class10~T~ {
|
|
|
|
<<service>>
|
|
|
|
int id
|
|
|
|
test()
|
|
|
|
}
|
|
|
|
link class01 "google.com" "A Tooltip"
|
|
|
|
`,
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('10: should render a simple class diagram with clickable callback', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
classDiagram
|
|
|
|
Class01~T~ <|-- AveryLongClass : Cool
|
|
|
|
Class03~T~ *-- Class04~T~
|
|
|
|
Class01 : size()
|
|
|
|
Class01 : int chimp
|
|
|
|
Class01 : int gorilla
|
|
|
|
Class08 <--> C2: Cool label
|
|
|
|
class Class10~T~ {
|
|
|
|
<<service>>
|
|
|
|
int id
|
|
|
|
test()
|
|
|
|
}
|
|
|
|
callback class01 "functionCall" "A Tooltip"
|
|
|
|
`,
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
2020-01-06 16:21:11 -08:00
|
|
|
|
|
|
|
it('11: should render a simple class diagram with return type on method', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
classDiagram
|
|
|
|
class Class10~T~ {
|
|
|
|
int[] id
|
|
|
|
test(int[] ids) bool
|
|
|
|
testArray() bool[]
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
2020-01-13 16:04:26 -08:00
|
|
|
|
|
|
|
it('12: should render a simple class diagram with generic types', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
classDiagram
|
|
|
|
class Class10~T~ {
|
|
|
|
int[] id
|
|
|
|
List~int~ ids
|
|
|
|
test(List~int~ ids) List~bool~
|
|
|
|
testArray() bool[]
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
cy.get('svg');
|
|
|
|
});
|
2019-09-18 18:25:06 +02:00
|
|
|
});
|