Skip to content

Commit caf7f93

Browse files
1pxoneArtemiy Vereshchinskiy
authored and
Artemiy Vereshchinskiy
committed
adds optional generic parameter to Node and Relationship
1 parent bd972b6 commit caf7f93

File tree

1 file changed

+44
-53
lines changed

1 file changed

+44
-53
lines changed

test/types/graph-types.test.ts

+44-53
Original file line numberDiff line numberDiff line change
@@ -32,98 +32,89 @@ import {
3232
isUnboundRelationship
3333
} from 'neo4j-driver-core'
3434

35-
type NodeProperties = { name: string }
36-
type RelationshipProperties = { since: number }
37-
38-
const node1: Node<Integer, NodeProperties> = new Node(
39-
int(1),
40-
['Person', 'Employee'],
41-
{ name: 'Alice' }
42-
)
35+
const node1: Node = new Node(int(1), ['Person', 'Employee'], { name: 'Alice' })
4336
const node1String: string = node1.toString()
4437
const node1Id: Integer = node1.identity
4538
const node1Labels: string[] = node1.labels
46-
const node1Props: NodeProperties = node1.properties
47-
const node1PropertyName: string = node1.properties.name
39+
const node1Props: object = node1.properties
4840
const isNode1: boolean = node1 instanceof Node
4941
const isNode1B: boolean = isNode(node1)
5042

51-
const node2: Node<number, NodeProperties> = new Node(
52-
2,
53-
['Person', 'Employee'],
54-
{
55-
name: 'Alice'
56-
}
57-
)
43+
const node2: Node<number> = new Node(2, ['Person', 'Employee'], {
44+
name: 'Alice'
45+
})
5846
const node2Id: number = node2.identity
59-
const node2Props: NodeProperties = node2.properties
60-
const node2PropertyName: string = node2.properties.name
6147

62-
const rel1: Relationship<Integer, RelationshipProperties> = new Relationship(
63-
int(1),
64-
int(2),
65-
int(3),
66-
'KNOWS',
67-
{
68-
since: 12345
69-
}
70-
)
48+
type NodeProps = { name: string }
49+
const node3: Node<number, NodeProps> = new Node(2, ['Person', 'Employee'], {
50+
name: 'Alice'
51+
})
52+
const node3Props: NodeProps = node3.properties
53+
const node3PropertyName: string = node3.properties.name
54+
55+
const rel1: Relationship = new Relationship(int(1), int(2), int(3), 'KNOWS', {
56+
since: 12345
57+
})
7158
const rel1String: string = rel1.toString()
7259
const rel1Id: Integer = rel1.identity
7360
const rel1Start: Integer = rel1.start
7461
const rel1End: Integer = rel1.end
7562
const rel1Type: string = rel1.type
76-
const rel1Props: RelationshipProperties = rel1.properties
77-
const rel1PropertySince: number = rel1.properties.since
63+
const rel1Props: object = rel1.properties
7864
const isRel1: boolean = rel1 instanceof Relationship
7965
const isRel1B: boolean = isRelationship(rel1)
8066

81-
const rel2: UnboundRelationship<
82-
Integer,
83-
RelationshipProperties
84-
> = new UnboundRelationship(int(1), 'KNOWS', {
67+
const rel2: UnboundRelationship = new UnboundRelationship(int(1), 'KNOWS', {
8568
since: 12345
8669
})
8770
const rel2String: string = rel2.toString()
8871
const rel3: Relationship = rel2.bind(int(1), int(2))
8972
const rel2Id: Integer = rel2.identity
9073
const rel2Type: string = rel2.type
91-
const rel2Props: RelationshipProperties = rel2.properties
92-
const rel2PropertySince: number = rel2.properties.since
74+
const rel2Props: object = rel2.properties
9375
const isRel2: boolean = rel2 instanceof UnboundRelationship
9476
const isRel2B: boolean = isUnboundRelationship(rel2)
9577

96-
const rel4: Relationship<number, RelationshipProperties> = new Relationship(
97-
2,
98-
3,
99-
4,
100-
'KNOWS',
101-
{
102-
since: 12345
103-
}
104-
)
78+
const rel4: Relationship<number> = new Relationship(2, 3, 4, 'KNOWS', {
79+
since: 12345
80+
})
10581
const rel4Id: number = rel4.identity
10682
const rel4Start: number = rel4.start
10783
const rel4End: number = rel4.end
10884
const isRel4: boolean = rel4 instanceof Relationship
109-
const rel4Props: RelationshipProperties = rel4.properties
110-
const rel4PropertySince: number = rel4.properties.since
11185

112-
const rel5: UnboundRelationship<
113-
number,
114-
RelationshipProperties
115-
> = new UnboundRelationship(5, 'KNOWS', {
86+
const rel5: UnboundRelationship<number> = new UnboundRelationship(5, 'KNOWS', {
11687
since: 12345
11788
})
11889
const rel5Id: number = rel5.identity
119-
const rel5Props: RelationshipProperties = rel5.properties
120-
const rel5PropertySince: number = rel5.properties.since
12190
const rel6 = rel5.bind(24, 42)
12291
const rel6Id: number = rel6.identity
12392
const rel6Start: number = rel6.start
12493
const rel6End: number = rel6.end
12594
const isRel6: boolean = rel6 instanceof UnboundRelationship
12695

96+
type RelationshipProps = { since: number }
97+
const rel7: Relationship<number, RelationshipProps> = new Relationship(
98+
2,
99+
3,
100+
4,
101+
'KNOWS',
102+
{
103+
since: 12345
104+
}
105+
)
106+
const rel7Props: RelationshipProps = rel7.properties
107+
const rel7PropertySince: number = rel7.properties.since
108+
109+
const rel8: UnboundRelationship<
110+
number,
111+
RelationshipProps
112+
> = new UnboundRelationship(5, 'KNOWS', {
113+
since: 12345
114+
})
115+
const rel8Props: RelationshipProps = rel8.properties
116+
const rel8PropertySince: number = rel8.properties.since
117+
127118
const pathSegment1: PathSegment = new PathSegment(node1, rel1, node1)
128119
const pathSegment1Start: Node = pathSegment1.start
129120
const pathSegment1Rel: Relationship = pathSegment1.relationship

0 commit comments

Comments
 (0)