diff --git a/packages/neo4j-driver/package-lock.json b/packages/neo4j-driver/package-lock.json index c22c9852a..041cf53f0 100644 --- a/packages/neo4j-driver/package-lock.json +++ b/packages/neo4j-driver/package-lock.json @@ -36,16 +36,14 @@ "gulp-uglify": "^3.0.2", "gulp-watch": "^5.0.1", "jasmine-spec-reporter": "^7.0.0", - "karma": "^6.4.1", - "karma-chrome-launcher": "^3.1.1", - "karma-edge-launcher": "^0.4.2", + "karma": "^6.4.2", + "karma-chrome-launcher": "^3.2.0", "karma-firefox-launcher": "^2.1.2", - "karma-ie-launcher": "^1.0.0", - "karma-jasmine": "^4.0.2", + "karma-jasmine": "^5.1.0", "karma-source-map-support": "^1.4.0", "karma-spec-reporter": "^0.0.36", - "karma-typescript": "^5.5.3", - "karma-typescript-es6-transform": "^5.5.3", + "karma-typescript": "^5.5.4", + "karma-typescript-es6-transform": "^5.5.4", "lolex": "^6.0.0", "minimist": "^1.2.8", "rollup": "^2.77.4-1", @@ -5064,12 +5062,6 @@ "safer-buffer": "^2.1.0" } }, - "node_modules/edge-launcher": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/edge-launcher/-/edge-launcher-1.2.2.tgz", - "integrity": "sha1-60Cq+9Bnpup27/+rBke81VCbN7I=", - "dev": true - }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -8925,9 +8917,9 @@ "dev": true }, "node_modules/karma": { - "version": "6.4.1", - "resolved": "https://registry.npmjs.org/karma/-/karma-6.4.1.tgz", - "integrity": "sha512-Cj57NKOskK7wtFWSlMvZf459iX+kpYIPXmkNUzP2WAFcA7nhr/ALn5R7sw3w+1udFDcpMx/tuB8d5amgm3ijaA==", + "version": "6.4.2", + "resolved": "https://registry.npmjs.org/karma/-/karma-6.4.2.tgz", + "integrity": "sha512-C6SU/53LB31BEgRg+omznBEMY4SjHU3ricV6zBcAe1EeILKkeScr+fZXtaI5WyDbkVowJxxAI6h73NcFPmXolQ==", "dev": true, "dependencies": { "@colors/colors": "1.5.0", @@ -8963,9 +8955,9 @@ } }, "node_modules/karma-chrome-launcher": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-3.1.1.tgz", - "integrity": "sha512-hsIglcq1vtboGPAN+DGCISCFOxW+ZVnIqhDQcCMqqCp+4dmJ0Qpq5QAjkbA0X2L9Mi6OBkHi2Srrbmm7pUKkzQ==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-3.2.0.tgz", + "integrity": "sha512-rE9RkUPI7I9mAxByQWkGJFXfFD6lE4gC5nPuZdobf/QdTEJI6EU4yIay/cfU/xV4ZxlM5JiTv7zWYgA64NpS5Q==", "dev": true, "dependencies": { "which": "^1.2.1" @@ -8983,21 +8975,6 @@ "which": "bin/which" } }, - "node_modules/karma-edge-launcher": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/karma-edge-launcher/-/karma-edge-launcher-0.4.2.tgz", - "integrity": "sha512-YAJZb1fmRcxNhMIWYsjLuxwODBjh2cSHgTW/jkVmdpGguJjLbs9ZgIK/tEJsMQcBLUkO+yO4LBbqYxqgGW2HIw==", - "dev": true, - "dependencies": { - "edge-launcher": "1.2.2" - }, - "engines": { - "node": ">=4" - }, - "peerDependencies": { - "karma": ">=0.9" - } - }, "node_modules/karma-firefox-launcher": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-2.1.2.tgz", @@ -9008,33 +8985,27 @@ "which": "^2.0.1" } }, - "node_modules/karma-ie-launcher": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/karma-ie-launcher/-/karma-ie-launcher-1.0.0.tgz", - "integrity": "sha1-SXmGhCxJAZA0bNifVJTKmDDG1Zw=", - "dev": true, - "dependencies": { - "lodash": "^4.6.1" - }, - "peerDependencies": { - "karma": ">=0.9" - } - }, "node_modules/karma-jasmine": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/karma-jasmine/-/karma-jasmine-4.0.2.tgz", - "integrity": "sha512-ggi84RMNQffSDmWSyyt4zxzh2CQGwsxvYYsprgyR1j8ikzIduEdOlcLvXjZGwXG/0j41KUXOWsUCBfbEHPWP9g==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/karma-jasmine/-/karma-jasmine-5.1.0.tgz", + "integrity": "sha512-i/zQLFrfEpRyQoJF9fsCdTMOF5c2dK7C7OmsuKg2D0YSsuZSfQDiLuaiktbuio6F2wiCsZSnSnieIQ0ant/uzQ==", "dev": true, "dependencies": { - "jasmine-core": "^3.6.0" + "jasmine-core": "^4.1.0" }, "engines": { - "node": ">= 10" + "node": ">=12" }, "peerDependencies": { - "karma": "*" + "karma": "^6.0.0" } }, + "node_modules/karma-jasmine/node_modules/jasmine-core": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-4.6.0.tgz", + "integrity": "sha512-O236+gd0ZXS8YAjFx8xKaJ94/erqUliEkJTDedyE7iHvv4ZVqi+q+8acJxu05/WJDKm512EUNn809In37nWlAQ==", + "dev": true + }, "node_modules/karma-source-map-support": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/karma-source-map-support/-/karma-source-map-support-1.4.0.tgz", @@ -9057,9 +9028,9 @@ } }, "node_modules/karma-typescript": { - "version": "5.5.3", - "resolved": "https://registry.npmjs.org/karma-typescript/-/karma-typescript-5.5.3.tgz", - "integrity": "sha512-l1FHurolXEBIzRa9ExpNtjzysAhsi/vLpTazpwLHWWK86mknvVpqor6pRZ5Nid7jvOPrTBqAq0JRuLgiCdRkFw==", + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/karma-typescript/-/karma-typescript-5.5.4.tgz", + "integrity": "sha512-D7nQ96xu/UekuqCmiPimnCuOFqp8+BxiND6MU6IJVN37E7DgXzr7SUeTzwuTHtKSYpgxKv4iOTUteYTxpeZL9A==", "dev": true, "dependencies": { "acorn": "^8.1.0", @@ -9108,13 +9079,13 @@ }, "peerDependencies": { "karma": "1 || 2 || 3 || 4 || 5 || 6", - "typescript": "1 || 2 || 3 || 4" + "typescript": "1 || 2 || 3 || 4 || 5" } }, "node_modules/karma-typescript-es6-transform": { - "version": "5.5.3", - "resolved": "https://registry.npmjs.org/karma-typescript-es6-transform/-/karma-typescript-es6-transform-5.5.3.tgz", - "integrity": "sha512-vB1Cv8z9yxyR2KQuvks5soNKASyS2RPApdMsB3Ad55RqFJeag9G+xyGIwxOdyCHtgOwa4yn1rngMwaN7WBQTbQ==", + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/karma-typescript-es6-transform/-/karma-typescript-es6-transform-5.5.4.tgz", + "integrity": "sha512-SKUNU4cAxNgmJnF/zCAzMRnBaciQjFumSDrsf1j8TTJvAtwAk/tLM+hru88Dr4Q4SmFUFa+PzIK8NJmykQ2F7Q==", "dev": true, "dependencies": { "@babel/core": "^7.11.1", @@ -18423,12 +18394,6 @@ "safer-buffer": "^2.1.0" } }, - "edge-launcher": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/edge-launcher/-/edge-launcher-1.2.2.tgz", - "integrity": "sha1-60Cq+9Bnpup27/+rBke81VCbN7I=", - "dev": true - }, "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -21528,9 +21493,9 @@ "dev": true }, "karma": { - "version": "6.4.1", - "resolved": "https://registry.npmjs.org/karma/-/karma-6.4.1.tgz", - "integrity": "sha512-Cj57NKOskK7wtFWSlMvZf459iX+kpYIPXmkNUzP2WAFcA7nhr/ALn5R7sw3w+1udFDcpMx/tuB8d5amgm3ijaA==", + "version": "6.4.2", + "resolved": "https://registry.npmjs.org/karma/-/karma-6.4.2.tgz", + "integrity": "sha512-C6SU/53LB31BEgRg+omznBEMY4SjHU3ricV6zBcAe1EeILKkeScr+fZXtaI5WyDbkVowJxxAI6h73NcFPmXolQ==", "dev": true, "requires": { "@colors/colors": "1.5.0", @@ -21734,9 +21699,9 @@ } }, "karma-chrome-launcher": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-3.1.1.tgz", - "integrity": "sha512-hsIglcq1vtboGPAN+DGCISCFOxW+ZVnIqhDQcCMqqCp+4dmJ0Qpq5QAjkbA0X2L9Mi6OBkHi2Srrbmm7pUKkzQ==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-3.2.0.tgz", + "integrity": "sha512-rE9RkUPI7I9mAxByQWkGJFXfFD6lE4gC5nPuZdobf/QdTEJI6EU4yIay/cfU/xV4ZxlM5JiTv7zWYgA64NpS5Q==", "dev": true, "requires": { "which": "^1.2.1" @@ -21753,15 +21718,6 @@ } } }, - "karma-edge-launcher": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/karma-edge-launcher/-/karma-edge-launcher-0.4.2.tgz", - "integrity": "sha512-YAJZb1fmRcxNhMIWYsjLuxwODBjh2cSHgTW/jkVmdpGguJjLbs9ZgIK/tEJsMQcBLUkO+yO4LBbqYxqgGW2HIw==", - "dev": true, - "requires": { - "edge-launcher": "1.2.2" - } - }, "karma-firefox-launcher": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-2.1.2.tgz", @@ -21772,22 +21728,21 @@ "which": "^2.0.1" } }, - "karma-ie-launcher": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/karma-ie-launcher/-/karma-ie-launcher-1.0.0.tgz", - "integrity": "sha1-SXmGhCxJAZA0bNifVJTKmDDG1Zw=", - "dev": true, - "requires": { - "lodash": "^4.6.1" - } - }, "karma-jasmine": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/karma-jasmine/-/karma-jasmine-4.0.2.tgz", - "integrity": "sha512-ggi84RMNQffSDmWSyyt4zxzh2CQGwsxvYYsprgyR1j8ikzIduEdOlcLvXjZGwXG/0j41KUXOWsUCBfbEHPWP9g==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/karma-jasmine/-/karma-jasmine-5.1.0.tgz", + "integrity": "sha512-i/zQLFrfEpRyQoJF9fsCdTMOF5c2dK7C7OmsuKg2D0YSsuZSfQDiLuaiktbuio6F2wiCsZSnSnieIQ0ant/uzQ==", "dev": true, "requires": { - "jasmine-core": "^3.6.0" + "jasmine-core": "^4.1.0" + }, + "dependencies": { + "jasmine-core": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-4.6.0.tgz", + "integrity": "sha512-O236+gd0ZXS8YAjFx8xKaJ94/erqUliEkJTDedyE7iHvv4ZVqi+q+8acJxu05/WJDKm512EUNn809In37nWlAQ==", + "dev": true + } } }, "karma-source-map-support": { @@ -21809,9 +21764,9 @@ } }, "karma-typescript": { - "version": "5.5.3", - "resolved": "https://registry.npmjs.org/karma-typescript/-/karma-typescript-5.5.3.tgz", - "integrity": "sha512-l1FHurolXEBIzRa9ExpNtjzysAhsi/vLpTazpwLHWWK86mknvVpqor6pRZ5Nid7jvOPrTBqAq0JRuLgiCdRkFw==", + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/karma-typescript/-/karma-typescript-5.5.4.tgz", + "integrity": "sha512-D7nQ96xu/UekuqCmiPimnCuOFqp8+BxiND6MU6IJVN37E7DgXzr7SUeTzwuTHtKSYpgxKv4iOTUteYTxpeZL9A==", "dev": true, "requires": { "acorn": "^8.1.0", @@ -21930,9 +21885,9 @@ } }, "karma-typescript-es6-transform": { - "version": "5.5.3", - "resolved": "https://registry.npmjs.org/karma-typescript-es6-transform/-/karma-typescript-es6-transform-5.5.3.tgz", - "integrity": "sha512-vB1Cv8z9yxyR2KQuvks5soNKASyS2RPApdMsB3Ad55RqFJeag9G+xyGIwxOdyCHtgOwa4yn1rngMwaN7WBQTbQ==", + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/karma-typescript-es6-transform/-/karma-typescript-es6-transform-5.5.4.tgz", + "integrity": "sha512-SKUNU4cAxNgmJnF/zCAzMRnBaciQjFumSDrsf1j8TTJvAtwAk/tLM+hru88Dr4Q4SmFUFa+PzIK8NJmykQ2F7Q==", "dev": true, "requires": { "@babel/core": "^7.11.1", diff --git a/packages/neo4j-driver/package.json b/packages/neo4j-driver/package.json index e9253e5e0..f98d4ca4c 100644 --- a/packages/neo4j-driver/package.json +++ b/packages/neo4j-driver/package.json @@ -58,16 +58,14 @@ "gulp-uglify": "^3.0.2", "gulp-watch": "^5.0.1", "jasmine-spec-reporter": "^7.0.0", - "karma": "^6.4.1", - "karma-chrome-launcher": "^3.1.1", - "karma-edge-launcher": "^0.4.2", + "karma": "^6.4.2", + "karma-chrome-launcher": "^3.2.0", "karma-firefox-launcher": "^2.1.2", - "karma-ie-launcher": "^1.0.0", - "karma-jasmine": "^4.0.2", + "karma-jasmine": "^5.1.0", "karma-source-map-support": "^1.4.0", "karma-spec-reporter": "^0.0.36", - "karma-typescript": "^5.5.3", - "karma-typescript-es6-transform": "^5.5.3", + "karma-typescript": "^5.5.4", + "karma-typescript-es6-transform": "^5.5.4", "lolex": "^6.0.0", "minimist": "^1.2.8", "rollup": "^2.77.4-1", diff --git a/packages/neo4j-driver/test/bolt-v3.test.js b/packages/neo4j-driver/test/bolt-v3.test.js index eaeb372be..e10a8de81 100644 --- a/packages/neo4j-driver/test/bolt-v3.test.js +++ b/packages/neo4j-driver/test/bolt-v3.test.js @@ -65,7 +65,7 @@ describe('#integration Bolt V3 API', () => { const result = await session.run( 'CALL dbms.listTransactions()', {}, - { metadata: metadata } + { metadata } ) const receivedMetadatas = result.records.map(r => r.get('metaData')) expect(receivedMetadatas).toContain(metadata) @@ -184,7 +184,7 @@ describe('#integration Bolt V3 API', () => { c: [1, 2, 3] } - const tx = session.beginTransaction({ metadata: metadata }) + const tx = session.beginTransaction({ metadata }) // call listTransactions procedure that should list itself with the specified metadata const result = await tx.run('CALL dbms.listTransactions()') @@ -218,7 +218,8 @@ describe('#integration Bolt V3 API', () => { if ( e.code !== 'Neo.ClientError.Transaction.TransactionTimedOut' && e.code !== 'Neo.TransientError.Transaction.LockClientStopped' && - e.code !== 'Neo.ClientError.Transaction.LockClientStopped' + e.code !== 'Neo.ClientError.Transaction.LockClientStopped' && + e.code !== 'Neo.ClientError.Transaction.TransactionTimedOutClientConfiguration' ) { fail('Expected transaction timeout error but got: ' + e.code) } @@ -461,8 +462,8 @@ describe('#integration Bolt V3 API', () => { const txFunctionWithMetadata = work => read - ? session.readTransaction(work, { metadata: metadata }) - : session.writeTransaction(work, { metadata: metadata }) + ? session.readTransaction(work, { metadata }) + : session.writeTransaction(work, { metadata }) const result = await txFunctionWithMetadata(tx => tx.run('CALL dbms.listTransactions()') diff --git a/packages/neo4j-driver/test/internal/connection-channel.test.js b/packages/neo4j-driver/test/internal/connection-channel.test.js index a2ab6c046..5576fa60a 100644 --- a/packages/neo4j-driver/test/internal/connection-channel.test.js +++ b/packages/neo4j-driver/test/internal/connection-channel.test.js @@ -96,58 +96,55 @@ describe('#integration ChannelConnection', () => { .catch(done.fail.bind(done)) }) - it('should retrieve stream', async done => { - connection = await createConnection(`bolt://${sharedNeo4j.hostnameWithBoltPort}`) - - const records = [] - const pullAllObserver = { - onNext: record => { - records.push(record) - }, - onCompleted: () => { - expect(records[0].get(0)).toBe(1) - done() - }, - onError: done.fail.bind(done) - } + it('should retrieve stream', done => { + createConnection(`bolt://${sharedNeo4j.hostnameWithBoltPort}`).then(conn => { + connection = conn + const records = [] + const pullAllObserver = { + onNext: record => { + records.push(record) + }, + onCompleted: () => { + expect(records[0].get(0)).toBe(1) + done() + }, + onError: done.fail.bind(done) + } - connection - .connect('mydriver/0.0.0', BOLT_AGENT, basicAuthToken()) - .then(() => { - connection - .protocol() - .run( - 'RETURN 1.0', - {}, - { - bookmarks: Bookmarks.empty(), - txConfig: TxConfig.empty(), - mode: WRITE - } - ) - .subscribe(pullAllObserver) - }) - .catch(done.fail.bind(done)) + connection + .connect('mydriver/0.0.0', BOLT_AGENT, basicAuthToken()) + .then(() => { + connection + .protocol() + .run( + 'RETURN 1.0', + {}, + { + bookmarks: Bookmarks.empty(), + txConfig: TxConfig.empty(), + mode: WRITE + } + ) + .subscribe(pullAllObserver) + }) + .catch(done.fail.bind(done)) + }) }) - it('should provide error message when connecting to http-port', async done => { - await createConnection(`bolt://${sharedNeo4j.hostnameWithHttpPort}`, { + it('should provide error message when connecting to http-port', async () => { + const asyncMatchers = expectAsync(createConnection(`bolt://${sharedNeo4j.hostnameWithHttpPort}`, { encrypted: false - }, null, new Logger('error', () => {})) - .then(done.fail.bind(done)) - .catch(error => { - expect(error).toBeDefined() - expect(error).not.toBeNull() - - if (testUtils.isServer()) { - // only node gets the pretty error message - expect(error.message).toBe( - 'Server responded HTTP. Make sure you are not trying to connect to the http endpoint ' + - '(HTTP defaults to port 7474 whereas BOLT defaults to port 7687)' - ) - } - done() - }) + }, null, new Logger('error', () => {}))) + + if (testUtils.isServer()) { + // only node gets the pretty error message + await asyncMatchers.toBeRejectedWith(newError( + 'Server responded HTTP. Make sure you are not trying to connect to the http endpoint ' + + '(HTTP defaults to port 7474 whereas BOLT defaults to port 7687)' + )) + } else { + await asyncMatchers.toBeRejected() + } }) it('should convert failure messages to errors', done => { @@ -181,64 +178,56 @@ describe('#integration ChannelConnection', () => { channel.onmessage(packedHandshakeMessage()) }) - it('should notify when connection initialization completes', async done => { + it('should notify when connection initialization completes', async () => { connection = await createConnection(`bolt://${sharedNeo4j.hostnameWithBoltPort}`) - - connection - .connect('mydriver/0.0.0', BOLT_AGENT, basicAuthToken()) - .then(initializedConnection => { - expect(initializedConnection).toBe(connection) - done() - }) - .catch(done.fail.bind(done)) + const connectedConnection = await connection.connect('mydriver/0.0.0', BOLT_AGENT, basicAuthToken()) + expect(connectedConnection).toBe(connection) }) - it('should notify when connection initialization fails', async done => { + it('should notify when connection initialization fails', async () => { connection = await createConnection(`bolt://${sharedNeo4j.hostnameWithBoltPort}`) // wrong port + let failed = false - connection - .connect('mydriver/0.0.0', BOLT_AGENT, basicWrongAuthToken()) - .then(() => done.fail('Should not initialize')) - .catch(error => { - expect(error).toBeDefined() - done() - }) - }) - - it('should have server version after connection initialization completed', async done => { - connection = await createConnection(`bolt://${sharedNeo4j.hostnameWithBoltPort}`) - connection - .connect('mydriver/0.0.0', BOLT_AGENT, basicAuthToken()) - .then(initializedConnection => { - expect(initializedConnection).toBe(connection) - const serverVersion = ServerVersion.fromString(connection.version) - expect(serverVersion).toBeDefined() - done() - }) - .catch(done.fail.bind(done)) + try { + await connection.connect('mydriver/0.0.0', BOLT_AGENT, basicWrongAuthToken()) + } catch (error) { + failed = true + expect(error).toBeDefined() + } + expect(failed).toBe(true) }) - it('should fail all new observers after failure to connect', async done => { + it('should have server version after connection initialization completed', async () => { connection = await createConnection(`bolt://${sharedNeo4j.hostnameWithBoltPort}`) + const initializedConnection = await connection.connect('mydriver/0.0.0', BOLT_AGENT, basicAuthToken()) - connection - .connect('mydriver/0.0.0', BOLT_AGENT, basicWrongAuthToken()) - .then(() => done.fail('Should not connect')) - .catch(initialError => { - expect(initialError).toBeDefined() - expect(initialError).not.toBeNull() - - expect(connection.isOpen()).toBeFalsy() + expect(initializedConnection).toBe(connection) + const serverVersion = ServerVersion.fromString(connection.version) + expect(serverVersion).toBeDefined() + }) - const streamObserver = new ResultStreamObserver() - streamObserver.subscribe({ - onError: error => { - expect(error).toEqual(initialError) - done() - } + it('should fail all new observers after failure to connect', done => { + createConnection(`bolt://${sharedNeo4j.hostnameWithBoltPort}`).then(conn => { + connection = conn + connection + .connect('mydriver/0.0.0', BOLT_AGENT, basicWrongAuthToken()) + .then(() => done.fail('Should not connect')) + .catch(initialError => { + expect(initialError).toBeDefined() + expect(initialError).not.toBeNull() + + expect(connection.isOpen()).toBeFalsy() + + const streamObserver = new ResultStreamObserver() + streamObserver.subscribe({ + onError: error => { + expect(error).toEqual(initialError) + done() + } + }) + connection._queueObserver(streamObserver) }) - connection._queueObserver(streamObserver) - }) + }) }) it('should respect connection timeout', async () => { @@ -278,31 +267,32 @@ describe('#integration ChannelConnection', () => { testQueueingOfObserversWithBrokenConnection(resetAction, done) }) - it('should reset and flush when SUCCESS received', async done => { - connection = await createConnection(`bolt://${sharedNeo4j.hostnameWithBoltPort}`) + it('should reset and flush when SUCCESS received', done => { + createConnection(`bolt://${sharedNeo4j.hostnameWithBoltPort}`).then(conn => { + connection = conn + connection + .connect('my-driver/1.2.3', BOLT_AGENT, basicAuthToken()) + .then(() => { + connection + .resetAndFlush() + .then(() => { + expect(connection.isOpen()).toBeTruthy() + done() + }) + .catch(error => done.fail(error)) - connection - .connect('my-driver/1.2.3', BOLT_AGENT, basicAuthToken()) - .then(() => { - connection - .resetAndFlush() - .then(() => { - expect(connection.isOpen()).toBeTruthy() - done() + // write a SUCCESS message for RESET before the actual response is received + connection.protocol()._responseHandler.handleResponse(SUCCESS_MESSAGE) + // enqueue a dummy observer to handle the real SUCCESS message + connection.protocol()._responseHandler._queueObserver({ + onCompleted: () => {} }) - .catch(error => done.fail(error)) - - // write a SUCCESS message for RESET before the actual response is received - connection.protocol()._responseHandler.handleResponse(SUCCESS_MESSAGE) - // enqueue a dummy observer to handle the real SUCCESS message - connection.protocol()._responseHandler._queueObserver({ - onCompleted: () => {} }) - }) - .catch(done.fail.bind(done)) + .catch(done.fail.bind(done)) + }) }) - it('should fail to reset and flush when FAILURE received', async done => { + it('should fail to reset and flush when FAILURE received', done => { createConnection(`bolt://${sharedNeo4j.hostnameWithBoltPort}`) .then(connection => { connection.connect('my-driver/1.2.3', BOLT_AGENT, basicAuthToken()).then(() => { @@ -329,16 +319,26 @@ describe('#integration ChannelConnection', () => { .catch(done.fail.bind(done)) }) - it('should fail to reset and flush when RECORD received', async done => { - connection = await createConnection(`bolt://${sharedNeo4j.hostnameWithBoltPort}`) + it('should fail to reset and flush when RECORD received', (done) => { + createConnection(`bolt://${sharedNeo4j.hostnameWithBoltPort}`) + .then(conn => { + connection = conn + connection.connect('my-driver/1.2.3', BOLT_AGENT, basicAuthToken()) + .then(connection => { + const resetRequest = connection.resetAndFlush() + + // write a RECORD message for RESET before the actual response is received + connection.protocol()._responseHandler.handleResponse(RECORD_MESSAGE) + // enqueue a dummy observer to handle the real SUCCESS message + connection.protocol()._responseHandler._queueObserver({ + onCompleted: () => {} + }) - connection - .connect('my-driver/1.2.3', BOLT_AGENT, basicAuthToken()) - .then(() => { - connection - .resetAndFlush() - .then(() => done.fail('Should fail')) + return resetRequest + }) + .then(done.fail.bind(done)) .catch(error => { + expect(error).toBeInstanceOf(Error) expect(error.message).toEqual( 'Received RECORD when resetting: received record is: {"value":"Hello"}' ) @@ -346,18 +346,10 @@ describe('#integration ChannelConnection', () => { expect(connection.isOpen()).toBeFalsy() done() }) - - // write a RECORD message for RESET before the actual response is received - connection.protocol()._responseHandler.handleResponse(RECORD_MESSAGE) - // enqueue a dummy observer to handle the real SUCCESS message - connection.protocol()._responseHandler._queueObserver({ - onCompleted: () => {} - }) }) - .catch(done.fail.bind(done)) }) - it('should acknowledge failure with RESET when SUCCESS received', async done => { + it('should acknowledge failure with RESET when SUCCESS received', done => { createConnection(`bolt://${sharedNeo4j.hostnameWithBoltPort}`) .then(connection => { connection @@ -470,7 +462,7 @@ describe('#integration ChannelConnection', () => { const channel = new DummyChannel() const chunker = new Chunker(channel) const packer = new Packer(chunker) - packer.packStruct(0x7f, [packer.packable({ code: code, message: message })]) + packer.packStruct(0x7f, [packer.packable({ code, message })]) chunker.messageBoundary() chunker.flush() const data = channel.toBuffer() @@ -507,7 +499,7 @@ describe('#integration ChannelConnection', () => { const boltUri = 'bolt://10.0.0.0' // use non-routable IP address which never responds connection = await createConnection( boltUri, - { encrypted: encrypted, connectionTimeout: 1000 }, + { encrypted, connectionTimeout: 1000 }, 'TestErrorCode' ) } catch (error) { diff --git a/packages/neo4j-driver/test/summary.test.js b/packages/neo4j-driver/test/summary.test.js index 0eb0dfb50..3526d93d0 100644 --- a/packages/neo4j-driver/test/summary.test.js +++ b/packages/neo4j-driver/test/summary.test.js @@ -21,17 +21,17 @@ import neo4j from '../src' import sharedNeo4j from './internal/shared-neo4j' describe('#integration result summary', () => { - describe('default driver', () => { + describe('default driver', async () => { let driver, session - beforeEach(done => { + beforeEach(async () => { driver = neo4j.driver( `bolt://${sharedNeo4j.hostnameWithBoltPort}`, sharedNeo4j.authToken ) session = driver.session() - session.run('MATCH (n) DETACH DELETE n').then(done) + await session.run('MATCH (n) DETACH DELETE n') }) afterEach(() => { @@ -62,7 +62,7 @@ describe('#integration result summary', () => { describe('driver with lossless integers disabled', () => { let driver, session - beforeEach(done => { + beforeEach(async () => { driver = neo4j.driver( `bolt://${sharedNeo4j.hostnameWithBoltPort}`, sharedNeo4j.authToken, @@ -72,7 +72,7 @@ describe('#integration result summary', () => { ) session = driver.session() - session.run('MATCH (n) DETACH DELETE n').then(done) + await session.run('MATCH (n) DETACH DELETE n') }) afterEach(() => { diff --git a/packages/neo4j-driver/test/transaction.test.js b/packages/neo4j-driver/test/transaction.test.js index 5846a3ba9..cc1e84c04 100644 --- a/packages/neo4j-driver/test/transaction.test.js +++ b/packages/neo4j-driver/test/transaction.test.js @@ -441,7 +441,7 @@ describe('#integration transaction', () => { expect(result).toBeUndefined() }, 60000) - it('should reset transaction', async done => { + it('should reset transaction', async () => { const session = driver.session({ defaultAccessMode: READ }) const tx = session.beginTransaction() await tx.run('RETURN 1') @@ -454,7 +454,6 @@ describe('#integration transaction', () => { 'You cannot run more transactions on a closed session.' ) await closePromise - done() } }, 60000) @@ -469,7 +468,7 @@ describe('#integration transaction', () => { function testConnectionTimeout (encrypted, done) { const boltUri = 'bolt://10.0.0.0' // use non-routable IP address which never responds - const config = { encrypted: encrypted, connectionTimeout: 1000 } + const config = { encrypted, connectionTimeout: 1000 } const localDriver = neo4j.driver(boltUri, sharedNeo4j.authToken, config) const session = localDriver.session()