Skip to content

Commit 61fde2c

Browse files
committed
Test index TS declarations
1 parent 3b512a3 commit 61fde2c

File tree

3 files changed

+113
-3
lines changed

3 files changed

+113
-3
lines changed

test/types/index.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 neo4j from "../../types/index";
21+
import {Driver} from "../../types/v1/driver";
22+
import Integer from "../../types/v1/integer";
23+
import {Neo4jError} from "../../types/v1/error";
24+
25+
const driver1: Driver = neo4j.driver("bolt+routing://localhost");
26+
const driver2: Driver = neo4j.driver("bolt://localhost:7687", neo4j.auth.basic("neo4j", "password"));
27+
28+
const readSession = driver1.session(neo4j.session.READ);
29+
const writeSession = driver1.session(neo4j.session.WRITE);
30+
31+
const int1: Integer = neo4j.int(42);
32+
const int2: Integer = neo4j.int("42");
33+
const int3: Integer = neo4j.int(neo4j.int(42));
34+
const int4: Integer = neo4j.int({low: 1, high: 1});
35+
36+
const isInt1: boolean = neo4j.isInt({});
37+
const isInt2: boolean = neo4j.isInt(neo4j.int("42"));
38+
39+
const serviceUnavailable: string = neo4j.error.SERVICE_UNAVAILABLE;
40+
const sessionExpired: string = neo4j.error.SESSION_EXPIRED;
41+
const protocolError: string = neo4j.error.PROTOCOL_ERROR;
42+
43+
const error1: Neo4jError = new neo4j.Neo4jError("Error message");
44+
const error2: Neo4jError = new neo4j.Neo4jError("Error message", "Error code");

test/types/v1/index.test.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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 v1, {auth, AuthToken, Config, driver, error, session} from "../../../types/v1/index";
21+
22+
import Driver from "../../../types/v1/driver";
23+
24+
const dummy: any = null;
25+
26+
const config: Config = dummy;
27+
28+
const basicAuthToken1: AuthToken = auth.basic("neo4j", "password");
29+
const basicAuthToken2: AuthToken = auth.basic("neo4j", "password", "realm");
30+
31+
const kerberosAuthToken1: AuthToken = auth.kerberos("base64EncodedTicket");
32+
33+
const customAuthToken1: AuthToken = auth.custom("neo4j", "password", "realm", "scheme");
34+
const customAuthToken2: AuthToken = auth.custom("neo4j", "password", "realm", "scheme", {"key": "value"});
35+
36+
const basicAuthToken3: AuthToken = v1.auth.basic("neo4j", "password");
37+
const basicAuthToken4: AuthToken = v1.auth.basic("neo4j", "password", "realm");
38+
39+
const kerberosAuthToken2: AuthToken = v1.auth.kerberos("base64EncodedTicket");
40+
41+
const customAuthToken3: AuthToken = v1.auth.custom("neo4j", "password", "realm", "scheme");
42+
const customAuthToken4: AuthToken = v1.auth.custom("neo4j", "password", "realm", "scheme", {"key": "value"});
43+
44+
const driver1: Driver = driver("bolt://localhost:7687");
45+
const driver2: Driver = driver("bolt://localhost:7687", basicAuthToken1);
46+
const driver3: Driver = driver("bolt://localhost:7687", basicAuthToken1, config);
47+
48+
const driver4: Driver = v1.driver("bolt://localhost:7687");
49+
const driver5: Driver = v1.driver("bolt://localhost:7687", basicAuthToken1);
50+
const driver6: Driver = v1.driver("bolt://localhost:7687", basicAuthToken1, config);
51+
52+
const readMode1: string = session.READ;
53+
const writeMode1: string = session.WRITE;
54+
55+
const readMode2: string = v1.session.READ;
56+
const writeMode2: string = v1.session.WRITE;
57+
58+
const serviceUnavailable1: string = error.SERVICE_UNAVAILABLE;
59+
const sessionExpired1: string = error.SESSION_EXPIRED;
60+
const protocolError1: string = error.PROTOCOL_ERROR;
61+
62+
const serviceUnavailable2: string = v1.error.SERVICE_UNAVAILABLE;
63+
const sessionExpired2: string = v1.error.SESSION_EXPIRED;
64+
const protocolError2: string = v1.error.PROTOCOL_ERROR;
65+

types/v1/index.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import Record from "./record";
2626
import Session from "./session";
2727
import {AuthToken, Config, Driver, READ, WRITE} from "./driver";
2828
import Transaction from "./transaction";
29+
import {Parameters} from "./statement-runner";
2930

3031
declare const auth: {
3132
basic: (username: string,
@@ -38,15 +39,15 @@ declare const auth: {
3839
credentials: string,
3940
realm: string,
4041
scheme: string,
41-
parameters?: { [key: string]: string }) => AuthToken,
42+
parameters?: Parameters) => AuthToken,
4243
};
4344

4445
declare function driver(url: string,
45-
authToken: AuthToken,
46+
authToken?: AuthToken,
4647
config?: Config): Driver;
4748

4849
declare const types: {
49-
Node: Node;
50+
Node: typeof Node;
5051
Relationship: typeof Relationship;
5152
UnboundRelationship: typeof UnboundRelationship;
5253
PathSegment: typeof PathSegment;

0 commit comments

Comments
 (0)