Skip to content

Commit

Permalink
chore: Revert changes to existing tests, add new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed Mar 24, 2024
1 parent 4feb818 commit 234a2cc
Show file tree
Hide file tree
Showing 3 changed files with 262 additions and 24 deletions.
1 change: 1 addition & 0 deletions .cspell/contributors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Ashish Jain
cpettitt
Dong Cai
jgreywolf
Nikolay Rozhkov
Peng Xiao
subhash-halder
Expand Down
142 changes: 130 additions & 12 deletions cypress/integration/rendering/classDiagram-v2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ describe('Class diagram V2', () => {
`
classDiagram-v2
class Class01~T~
Class01-T : size()
Class01-T : int chimp
Class01-T : int gorilla
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
Class08 <--> C2: Cool label
class Class10~T~ {
&lt;&lt;service&gt;&gt;
Expand All @@ -221,9 +221,9 @@ describe('Class diagram V2', () => {
classDiagram-v2
Class01~T~ <|-- AveryLongClass : Cool
Class03~T~ *-- Class04~T~
Class01-T : size()
Class01-T : int chimp
Class01-T : int gorilla
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
Class08 <--> C2: Cool label
class Class10~T~ {
&lt;&lt;service&gt;&gt;
Expand All @@ -241,9 +241,9 @@ describe('Class diagram V2', () => {
classDiagram-v2
Class01~T~ <|-- AveryLongClass : Cool
Class03~T~ *-- Class04~T~
Class01-T : size()
Class01-T : int chimp
Class01-T : int gorilla
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
Class08 <--> C2: Cool label
class Class10~T~ {
&lt;&lt;service&gt;&gt;
Expand All @@ -262,9 +262,9 @@ describe('Class diagram V2', () => {
classDiagram-v2
Class01~T~ <|-- AveryLongClass : Cool
Class03~T~ *-- Class04~T~
Class01-T : size()
Class01-T : int chimp
Class01-T : int gorilla
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
Class08 <--> C2: Cool label
class Class10~T~ {
&lt;&lt;service&gt;&gt;
Expand Down Expand Up @@ -581,4 +581,122 @@ class C13["With Città foreign language"]
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
});

describe('when adding generic types', () => {
it('should add properties when type is mentioned in classID', () => {
imgSnapshotTest(
`
classDiagram-v2
class Class01~T~
Class01-T : size()
Class01-T : int chimp
Class01-T : int gorilla
`
);
});

it('should fallback to matching class name when type is not mentioned in property', () => {
imgSnapshotTest(
`
classDiagram-v2
class Class01~T~
Class01-T : size()
Class01-T : int chimp
Class01 : int gorilla
`
);
});

it('should fallback to the first matching class name when type is not mentioned in property', () => {
imgSnapshotTest(
`
classDiagram-v2
class Class01~T~
class Class01~X~
Class01-T : int inClassT
Class01-X : int inClassX
Class01 : int alsoInClassT
`
);
});

it('should detect generic classes correctly when using different classIDs', () => {
imgSnapshotTest(
`
classDiagram-v2
class Class01~T~
Class01-T : size()
Class01-T : int chimp
Class01 : int gorillaInClassT
class Class01~X~
Class01-X : size()
Class01-X : int chimp
Class01-X : int gorilla
`
);
});

it('should render with Generic class and relations', () => {
imgSnapshotTest(
`
classDiagram-v2
Class01~T~ <|-- AveryLongClass : Cool
Class03~T~ *-- Class04~T~
Class01-T : size()
Class01-T : int chimp
Class01-T : int gorilla
Class08 <--> C2: Cool label
class Class10~T~ {
&lt;&lt;service&gt;&gt;
int id
test()
}
`
);
});

it('should render with clickable link when type is not mentioned', () => {
imgSnapshotTest(
`
classDiagram-v2
Class01~T~ <|-- AveryLongClass : Cool
Class01-T : size()
link Class01 "google.com" "A Tooltip"
`
);
});

it('should render with clickable callback when type is not mentioned', () => {
imgSnapshotTest(
`
classDiagram-v2
Class01~T~ <|-- AveryLongClass : Cool
Class01-T : size()
callback Class01 "functionCall" "A Tooltip"
`
);
});

it('should render with clickable link when type is mentioned', () => {
imgSnapshotTest(
`
classDiagram-v2
Class01~T~ <|-- AveryLongClass : Cool
Class01-T : size()
link Class01-T "google.com" "A Tooltip"
`
);
});

it('should render with clickable callback when type is mentioned', () => {
imgSnapshotTest(
`
classDiagram-v2
Class01~T~ <|-- AveryLongClass : Cool
Class01-T : size()
callback Class01-T "functionCall" "A Tooltip"
`
);
});
});
});
143 changes: 131 additions & 12 deletions cypress/integration/rendering/classDiagram.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ describe('Class diagram', () => {
`
classDiagram
class Class01~T~
Class01-T : size()
Class01-T : int chimp
Class01~T~ : int gorilla
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
Class08 <--> C2: Cool label
class Class10~T~ {
&lt;&lt;service&gt;&gt;
Expand All @@ -162,9 +162,9 @@ describe('Class diagram', () => {
classDiagram
Class01~T~ <|-- AveryLongClass : Cool
Class03~T~ *-- Class04~T~
Class01-T : size()
Class01-T : int chimp
Class01-T : int gorilla
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
Class08 <--> C2: Cool label
class Class10~T~ {
&lt;&lt;service&gt;&gt;
Expand All @@ -183,9 +183,9 @@ describe('Class diagram', () => {
classDiagram
Class01~T~ <|-- AveryLongClass : Cool
Class03~T~ *-- Class04~T~
Class01-T : size()
Class01-T : int chimp
Class01-T : int gorilla
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
Class08 <--> C2: Cool label
class Class10~T~ {
&lt;&lt;service&gt;&gt;
Expand All @@ -205,9 +205,9 @@ describe('Class diagram', () => {
classDiagram
Class01~T~ <|-- AveryLongClass : Cool
Class03~T~ *-- Class04~T~
Class01-T : size()
Class01-T : int chimp
Class01-T : int gorilla
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
Class08 <--> C2: Cool label
class Class10~T~ {
&lt;&lt;service&gt;&gt;
Expand Down Expand Up @@ -513,4 +513,123 @@ describe('Class diagram', () => {
cy.get('a').should('have.attr', 'target', '_blank').should('have.attr', 'rel', 'noopener');
});
});

describe('when adding generic types', () => {
it('should add properties when type is mentioned in classID', () => {
imgSnapshotTest(
`
classDiagram
class Class01~T~
Class01-T : size()
Class01-T : int chimp
Class01-T : int gorilla
`
);
});

it('should fallback to matching class name when type is not mentioned in property', () => {
imgSnapshotTest(
`
classDiagram
class Class01~T~
Class01-T : size()
Class01-T : int chimp
Class01 : int gorilla
`
);
});

it('should fallback to the first matching class name when type is not mentioned in property', () => {
imgSnapshotTest(
`
classDiagram
class Class01~T~
class Class01~X~
Class01-T : int inClassT
Class01-X : int inClassX
Class01 : int alsoInClassT
`
);
});

it('should detect generic classes correctly when using different classIDs', () => {
imgSnapshotTest(
`
classDiagram
class Class01~T~
Class01-T : size()
Class01-T : int chimp
Class01 : int gorillaInClassT
class Class01~X~
Class01-X : size()
Class01-X : int chimp
Class01-X : int gorilla
`
);
});

it('should render with Generic class and relations', () => {
imgSnapshotTest(
`
classDiagram
Class01~T~ <|-- AveryLongClass : Cool
Class03~T~ *-- Class04~T~
Class01-T : size()
Class01-T : int chimp
Class01-T : int gorilla
Class08 <--> C2: Cool label
class Class10~T~ {
&lt;&lt;service&gt;&gt;
int id
test()
}
`
);
});

// TODO: @jgreywolf These tests should ideally be unit tests, as links cannot be verified visually.
it('should render with clickable link when type is not mentioned', () => {
imgSnapshotTest(
`
classDiagram
Class01~T~ <|-- AveryLongClass : Cool
Class01-T : size()
link Class01 "google.com" "A Tooltip"
`
);
});

it('should render with clickable callback when type is not mentioned', () => {
imgSnapshotTest(
`
classDiagram
Class01~T~ <|-- AveryLongClass : Cool
Class01-T : size()
callback Class01 "functionCall" "A Tooltip"
`
);
});

it('should render with clickable link when type is mentioned', () => {
imgSnapshotTest(
`
classDiagram
Class01~T~ <|-- AveryLongClass : Cool
Class01-T : size()
link Class01-T "google.com" "A Tooltip"
`
);
});

it('should render with clickable callback when type is mentioned', () => {
imgSnapshotTest(
`
classDiagram
Class01~T~ <|-- AveryLongClass : Cool
Class01-T : size()
callback Class01-T "functionCall" "A Tooltip"
`
);
});
});
});

0 comments on commit 234a2cc

Please sign in to comment.