Skip to content
This repository was archived by the owner on Mar 17, 2024. It is now read-only.

Commit 1560d04

Browse files
authored
Merge pull request #325 from ts-graphviz/upgrade-ts-graphviz-0-16
Upgrade to ts-graphviz@^0.16.0
2 parents 0f77406 + 48c184d commit 1560d04

File tree

10 files changed

+19
-44
lines changed

10 files changed

+19
-44
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"prop-types": "^15.7.2",
4444
"react-dom": "^17.0.2",
4545
"react-reconciler": "^0.26.2",
46-
"ts-graphviz": "^0.15.1"
46+
"ts-graphviz": "^0.16.0"
4747
},
4848
"devDependencies": {
4949
"@testing-library/jest-dom": "^5.12.0",

src/__tests__/__snapshots__/render-to-dot.spec.tsx.snap

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22

33
exports[`renderToDot render edge 1`] = `
44
digraph {
5-
"a";
6-
"b";
75
"a" -> "b";
86
}
97
`;
108

119
exports[`renderToDot render subgraph 1`] = `
1210
digraph {
1311
subgraph {
14-
"a";
15-
"b";
1612
"a" -> "b";
1713
}
1814
}

src/__tests__/__snapshots__/render.test.tsx.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
exports[`renderToDot render to container subgraph test 1`] = `
44
digraph {
55
subgraph "test" {
6-
"a";
7-
"b";
86
"a" -> "b";
97
}
108
}

src/__tests__/render-to-dot.spec.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// tslint:disable: jsx-no-multiline-js
22
import React from 'react';
33
import 'jest-graphviz';
4+
import { EdgeTargetLikeTuple } from 'ts-graphviz';
45
import { Edge } from '../components/Edge';
56
import { Subgraph } from '../components/Subgraph';
67
import { Digraph } from '../components/Digraph';
@@ -19,26 +20,20 @@ describe('renderToDot', () => {
1920
});
2021

2122
it('render edge', () => {
22-
const nodes = ['a', 'b'];
23+
const nodes: EdgeTargetLikeTuple = ['a', 'b'];
2324
const dot = renderToDot(
2425
<Digraph>
25-
{nodes.map((id) => (
26-
<Node id={id} key={id} />
27-
))}
2826
<Edge targets={nodes} />
2927
</Digraph>,
3028
);
3129
expect(dot).toBeValidDotAndMatchSnapshot();
3230
});
3331

3432
it('render subgraph', () => {
35-
const nodes = ['a', 'b'];
33+
const nodes: EdgeTargetLikeTuple = ['a', 'b'];
3634
const dot = renderToDot(
3735
<Digraph>
3836
<Subgraph>
39-
{nodes.map((id) => (
40-
<Node id={id} key={id} />
41-
))}
4237
<Edge targets={nodes} />
4338
</Subgraph>
4439
</Digraph>,

src/__tests__/render.test.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable jest/expect-expect */
22
import React from 'react';
33
import 'jest-graphviz';
4-
import { digraph, toDot } from 'ts-graphviz';
4+
import { digraph, EdgeTargetLikeTuple, toDot } from 'ts-graphviz';
55
import { Edge } from '../components/Edge';
66
import { Node } from '../components/Node';
77
import { renderExpectToThrow } from '../components/__tests__/utils/renderExpectToThrow';
@@ -24,17 +24,9 @@ describe('renderToDot', () => {
2424
});
2525

2626
it('render to container subgraph test', () => {
27-
const nodes = ['a', 'b'];
27+
const nodes: EdgeTargetLikeTuple = ['a', 'b'];
2828
const G = digraph();
29-
const subgraph = render(
30-
<>
31-
{nodes.map((id) => (
32-
<Node id={id} key={id} />
33-
))}
34-
<Edge targets={nodes} />
35-
</>,
36-
G.subgraph('test'),
37-
);
29+
const subgraph = render(<Edge targets={nodes} />, G.subgraph('test'));
3830
expect(G.subgraph('test')).toEqual(subgraph);
3931
expect(toDot(G)).toBeValidDotAndMatchSnapshot();
4032
});

src/components/Edge.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export const Edge: VFC<EdgeProps> = ({ targets, label, ...options }) => {
1717
Edge.displayName = 'Edge';
1818

1919
Edge.propTypes = {
20+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
21+
// @ts-ignore
2022
targets: PropTypes.array.isRequired,
2123
comment: PropTypes.string,
2224
label: PropTypes.oneOfType([PropTypes.element, PropTypes.string]),

src/hooks/__tests__/use-edge.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Edge } from 'ts-graphviz';
1+
import { Edge, EdgeTargetLikeTuple } from 'ts-graphviz';
22
import { renderHook } from '@testing-library/react-hooks';
33
import { useEdge } from '../use-edge';
44
import { digraph, graph } from './utils/wrapper';
@@ -34,7 +34,7 @@ describe('useEdge', () => {
3434
});
3535

3636
test('throw error if the target is less than 2', () => {
37-
const { result } = renderHook(() => useEdge(['a']), {
37+
const { result } = renderHook(() => useEdge(['a'] as any as EdgeTargetLikeTuple), {
3838
wrapper: graph(),
3939
});
4040
expect(result.error).toStrictEqual(Error(EdgeTargetLengthErrorMessage));

src/hooks/use-edge.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect, useMemo } from 'react';
2-
import { EdgeTargetLike, EdgeTargetsLike, IEdge } from 'ts-graphviz';
2+
import { EdgeTargetLikeTuple, IEdge } from 'ts-graphviz';
33
import { useCurrentCluster } from './use-current-cluster';
44
import { EdgeTargetLengthErrorMessage } from '../errors';
55
import { useHasComment } from './use-comment';
@@ -10,7 +10,7 @@ import { EdgeOptions } from '../types';
1010
* `useEdge` is a hook that creates an instance of Edge
1111
* according to the object given by props.
1212
*/
13-
export function useEdge(targets: (EdgeTargetLike | EdgeTargetsLike)[], props: EdgeOptions = {}): IEdge {
13+
export function useEdge(targets: EdgeTargetLikeTuple, props: EdgeOptions = {}): IEdge {
1414
const { comment, ...attributes } = props;
1515
const cluster = useCurrentCluster();
1616
if (targets.length < 2) {

src/types.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import {
44
NodeAttributes,
55
ClusterSubgraphAttributes,
66
RootClusterAttributes,
7-
EdgeTargetLike,
8-
EdgeTargetsLike,
97
IHasComment,
108
attribute,
9+
EdgeTargetLikeTuple,
1110
} from 'ts-graphviz';
1211

1312
/** Common attribute values of objects under cluster */
@@ -52,7 +51,7 @@ export interface RootClusterProps extends Omit<RootClusterOptions, typeof attrib
5251
/** Props for Edge component */
5352
export interface EdgeProps extends Omit<EdgeOptions, typeof attribute.label> {
5453
/** Edge targets */
55-
targets: (EdgeTargetLike | EdgeTargetsLike)[];
54+
targets: EdgeTargetLikeTuple;
5655
/** Edge label */
5756
label?: ReactElement | string;
5857
}

yarn.lock

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5064,12 +5064,10 @@ tr46@^2.0.2:
50645064
dependencies:
50655065
punycode "^2.1.1"
50665066

5067-
ts-graphviz@^0.15.1:
5068-
version "0.15.1"
5069-
resolved "https://registry.yarnpkg.com/ts-graphviz/-/ts-graphviz-0.15.1.tgz#4136c1f6674913f30c08d58a3220b0949a2402e1"
5070-
integrity sha512-H1JfAL3eRTM7QHIjWU7nCwWYyOyLEVtkD9AZyV2K70icA4hXiu7tJuz5GW+bDR/y8/SyztEYKv385anh4fZ2yw==
5071-
dependencies:
5072-
tslib "^2.2.0"
5067+
ts-graphviz@^0.16.0:
5068+
version "0.16.0"
5069+
resolved "https://registry.yarnpkg.com/ts-graphviz/-/ts-graphviz-0.16.0.tgz#7a6e6b5434854bc90ab861e70d5af0d6d20729a7"
5070+
integrity sha512-3fTPO+G6bSQNvMh/XQQzyiahVLMMj9kqYO99ivUraNJ3Wp05HZOOVtRhi6w9hq7+laP1MKHjLBtGWqTeb1fcpg==
50735071

50745072
ts-jest@^26.5.6:
50755073
version "26.5.6"
@@ -5119,11 +5117,6 @@ tslib@^1.8.1:
51195117
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
51205118
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
51215119

5122-
tslib@^2.2.0:
5123-
version "2.2.0"
5124-
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.2.0.tgz#fb2c475977e35e241311ede2693cee1ec6698f5c"
5125-
integrity sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==
5126-
51275120
tsutils@^3.17.1:
51285121
version "3.21.0"
51295122
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"

0 commit comments

Comments
 (0)