Skip to content

Commit 7928552

Browse files
committed
Test error and graph types TS declarations
1 parent 18997b3 commit 7928552

File tree

4 files changed

+88
-1
lines changed

4 files changed

+88
-1
lines changed

test/types/v1/error.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright (c) 2002-2017 "Neo Technology,","
3+
* Network Engine for Objects in Lund AB [http://neotechnology.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
import {Neo4jError, newError, PROTOCOL_ERROR, SERVICE_UNAVAILABLE, SESSION_EXPIRED} from "../../../types/v1/error";
21+
22+
const serviceUnavailable: string = SERVICE_UNAVAILABLE;
23+
const sessionExpired: string = SESSION_EXPIRED;
24+
const protocolError: string = PROTOCOL_ERROR;
25+
26+
const error1: Neo4jError = new Neo4jError("Message");
27+
const error2: Neo4jError = new Neo4jError("Message", "Code");
28+
29+
const error3: Neo4jError = newError("Message");
30+
const error4: Neo4jError = newError("Message", "Code");

test/types/v1/graph-types.test.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* Copyright (c) 2002-2017 "Neo Technology,","
3+
* Network Engine for Objects in Lund AB [http://neotechnology.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
import {Node, Path, PathSegment, Relationship, UnboundRelationship} from "../../../types/v1/graph-types";
21+
import Integer, {int} from "../../../types/v1/integer";
22+
23+
const node1: Node = new Node(int(1), ["Person", "Employee"], {name: "Alice"});
24+
const node1String: string = node1.toString();
25+
const node1Id: Integer = node1.identity;
26+
const node1Labels: string[] = node1.labels;
27+
const node1Props: object = node1.properties;
28+
29+
const rel1: Relationship = new Relationship(int(1), int(2), int(3), "KNOWS", {since: 12345});
30+
const rel1String: string = rel1.toString();
31+
const rel1Id: Integer = rel1.identity;
32+
const rel1Start: Integer = rel1.start;
33+
const rel1End: Integer = rel1.end;
34+
const rel1Type: string = rel1.type;
35+
const rel1Props: object = rel1.properties;
36+
37+
const rel2: UnboundRelationship = new UnboundRelationship(int(1), "KNOWS", {since: 12345});
38+
const rel2String: string = rel2.toString();
39+
const rel3: Relationship = rel2.bind(int(1), int(2));
40+
const rel2Id: Integer = rel2.identity;
41+
const rel2Type: string = rel2.type;
42+
const rel2Props: object = rel2.properties;
43+
44+
const pathSegment1: PathSegment = new PathSegment(node1, rel1, node1);
45+
const pathSegment1Start: Node = pathSegment1.start;
46+
const pathSegment1Rel: Relationship = pathSegment1.rel;
47+
const pathSegment1End: Node = pathSegment1.end;
48+
49+
const path1: Path = new Path(node1, node1, [pathSegment1]);
50+
const path1Start: Node = path1.start;
51+
const path1End: Node = path1.end;
52+
const path1Segments: PathSegment[] = path1.segments;
53+
const path1Length: number = path1.length;

types/v1/error.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ declare class Neo4jError extends Error {
2727
code: string;
2828
message: string;
2929

30-
constructor(message: any, code: string);
30+
constructor(message: any, code?: string);
3131
}
3232

3333
export {

types/v1/graph-types.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
import Integer from "./integer";
2121

2222
declare class Node {
23+
identity: Integer;
24+
labels: string[];
25+
properties: object;
26+
2327
constructor(identity: Integer,
2428
labels: string[],
2529
properties: object)

0 commit comments

Comments
 (0)