Skip to content

Commit 4227d25

Browse files
committed
Add tests for v1 package import
1 parent 89a8997 commit 4227d25

File tree

6 files changed

+67
-15
lines changed

6 files changed

+67
-15
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ See files under `examples/` on how to use.
8787
This runs the test suite against a fresh download of Neo4j.
8888
Or `npm test` if you already have a running version of a compatible Neo4j server.
8989

90+
For development, you can have the build tool rerun the tests each time you change
91+
the source code:
92+
93+
gulp watch-n-test
94+
9095
### Testing on windows
9196
Running tests on windows requires PhantomJS installed and its bin folder added in windows system variable `Path`.
9297
To run the same test suite, run `.\runTest.ps1` instead in powershell with admin right.

gulpfile.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,13 @@ gulp.task('run-browser-test', function(){
156156
});
157157

158158
gulp.task('watch', function () {
159-
watch('src/**/*.js', batch(function (events, done) {
160-
gulp.start('all', done);
161-
}));
159+
return watch('src/**/*.js', batch(function (events, done) {
160+
gulp.start('all', done);
161+
}));
162+
});
163+
164+
gulp.task('watch-n-test', ['test-nodejs'], function () {
165+
return gulp.watch(['src/**/*.js', "test/**/*.js"], ['test-nodejs'] );
162166
});
163167

164168
var neo4jLinuxUrl = 'http://alpha.neohq.net/dist/neo4j-enterprise-3.0.0-M01-NIGHTLY-unix.tar.gz';
@@ -198,6 +202,7 @@ var runPowershell = function( cmd ) {
198202
child.stdin.end(); //end input
199203
}
200204

205+
/** Set the project version, controls package.json and version.js */
201206
gulp.task('set', function() {
202207
// Get the --version arg from command line
203208
var version = minimist(process.argv.slice(2), { string: 'version' }).version;

src/index.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,7 @@
1717
* limitations under the License.
1818
*/
1919

20-
import {int, isInt} from './v1/integer';
21-
import Driver from './v1/driver';
22-
import VERSION from './version';
23-
import * as v1 from './v1/index.js';
24-
25-
let USER_AGENT = "neo4j-javascript/" + VERSION;
26-
27-
console.log(v1);
20+
import * as v1 from './v1/index';
2821

2922
export default {
3023
v1: v1

src/version.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,11 @@
1717
* limitations under the License.
1818
*/
1919

20+
// DO NOT CHANGE THE VERSION BELOW HERE
21+
// This is set by the build system at release time, using
22+
// gulp set --version <releaseversion>
23+
//
24+
// This is set up this way to keep the version in the code in
25+
// sync with the npm package version, and to allow the build
26+
// system to control version names at packaging time.
2027
export default { VERSION : "0.0.0-dev" };

test/neo4j-driver.test.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Copyright (c) 2002-2015 "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+
describe('neo4j-driver', function() {
21+
it('should expose version 1 of the API as a property', function(done) {
22+
// When
23+
var neo4jDriver = require("../lib");
24+
25+
// Then I can access and use V1 of the API
26+
var driver = neo4jDriver.v1.driver("bolt://localhost");
27+
driver.session().run( "RETURN 1" )
28+
.then( function() { driver.close(); })
29+
.then( done );
30+
});
31+
32+
it('should expose version 1 of the API package', function(done) {
33+
// When
34+
var neo4jV1 = require("../lib/v1");
35+
36+
// Then I can access and use V1 of the API
37+
var driver = neo4jV1.driver("bolt://localhost");
38+
driver.session().run( "RETURN 1" )
39+
.then( function() { driver.close(); })
40+
.then( done );
41+
});
42+
});

test/v1/session.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ describe('session', function() {
135135
var params = {prop: "string"}
136136
// When & Then
137137
var result = driver.session().run( statement, params );
138-
result.then(function( records ) {
138+
result.then(function() {
139139
var sum = result.summarize();
140140
expect(sum.statement.text).toBe( statement );
141141
expect(sum.statement.parameters).toBe( params );
@@ -154,7 +154,7 @@ describe('session', function() {
154154
var params = {prop: "string"}
155155
// When & Then
156156
var result = driver.session().run( statement, params );
157-
result.then(function( records ) {
157+
result.then(function() {
158158
var sum = result.summarize();
159159
expect(sum.hasPlan()).toBe(true);
160160
expect(sum.hasProfile()).toBe(false);
@@ -174,7 +174,7 @@ describe('session', function() {
174174
var params = {prop: "string"}
175175
// When & Then
176176
var result = driver.session().run( statement, params );
177-
result.then(function( records ) {
177+
result.then(function() {
178178
var sum = result.summarize();
179179
expect(sum.hasPlan()).toBe(true); //When there's a profile, there's a plan
180180
expect(sum.hasProfile()).toBe(true);
@@ -195,7 +195,7 @@ describe('session', function() {
195195
var statement = "EXPLAIN MATCH (n), (m) RETURN n, m";
196196
// When & Then
197197
var result = driver.session().run( statement );
198-
result.then(function( records ) {
198+
result.then(function() {
199199
var sum = result.summarize();
200200
expect(sum.notifications.length).toBeGreaterThan(0);
201201
expect(sum.notifications[0].code).toBe("Neo.ClientNotification.Statement.CartesianProduct");

0 commit comments

Comments
 (0)