Skip to content

Commit 18997b3

Browse files
committed
Add simple test for transaction TS definition
This commit adds a first simple test for transaction class TypeScript definitions. Actual test code is not executed, it is just compiled using the TypeScript compiler to verify correctness of types. Also added npm script to run TS definition tests `test-types`. More tests will be added in subsequent commits.
1 parent 0837e5e commit 18997b3

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"stop-neo4j": "gulp stop-neo4j",
1717
"run-stress-tests": "gulp run-stress-tests",
1818
"run-tck": "gulp run-tck",
19+
"test-types": "tsc -p ./test/types/tsconfig.json",
1920
"docs": "esdoc -c esdoc.json",
2021
"versionRelease": "gulp set --version $VERSION && npm version $VERSION --no-git-tag-version"
2122
},
@@ -62,6 +63,7 @@
6263
"semver": "^5.3.0",
6364
"through2": "~2.0.0",
6465
"tmp": "0.0.31",
66+
"typescript": "^2.3.4",
6567
"vinyl-buffer": "^1.0.0",
6668
"vinyl-source-stream": "^1.1.0"
6769
},

test/types/tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"module": "es6",
4+
"target": "es6",
5+
"noImplicitAny": true,
6+
"noImplicitReturns": true,
7+
"strictNullChecks": true,
8+
"outDir": "../../build/test/types"
9+
},
10+
"include": [
11+
"v1/*.test.ts",
12+
"../../types/**/*"
13+
]
14+
}

test/types/v1/transaction.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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 Transaction from "../../../types/v1/transaction";
21+
22+
const dummy: any = null;
23+
24+
const tx: Transaction = dummy;
25+
26+
const isOpen: boolean = tx.isOpen();
27+
console.log(isOpen);
28+
29+
const runResult1 = tx.run("RETURN 1");
30+
runResult1.then(result => {
31+
result.records.forEach(record => {
32+
console.log(record);
33+
});
34+
});
35+
36+
tx.commit().catch(error => {
37+
console.log(error);
38+
});
39+
40+
tx.rollback().catch(error => {
41+
console.log(error);
42+
});

0 commit comments

Comments
 (0)