Skip to content

Commit a454f26

Browse files
committed
Move connector tests to ES6
1 parent aff3b1d commit a454f26

File tree

1 file changed

+33
-34
lines changed

1 file changed

+33
-34
lines changed

test/internal/connector.test.js

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,75 +16,74 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*/
19-
var DummyChannel = require('../../lib/v1/internal/ch-dummy.js');
20-
var connect = require("../../lib/v1/internal/connector.js").connect;
2119

22-
describe('connector', function() {
20+
import * as DummyChannel from "../../src/v1/internal/ch-dummy";
21+
import {connect} from "../../src/v1/internal/connector";
2322

24-
it('should read/write basic messages', function(done) {
23+
describe('connector', () => {
24+
25+
it('should read/write basic messages', done => {
2526
// Given
26-
var conn = connect("bolt://localhost")
27+
const conn = connect("bolt://localhost");
2728

2829
// When
29-
conn.initialize( "mydriver/0.0.0", {scheme: "basic", principal: "neo4j", credentials: "neo4j"}, {
30-
onCompleted: function( msg ) {
31-
expect( msg ).not.toBeNull();
30+
conn.initialize("mydriver/0.0.0", {scheme: "basic", principal: "neo4j", credentials: "neo4j"}, {
31+
onCompleted: msg => {
32+
expect(msg).not.toBeNull();
3233
conn.close();
3334
done();
3435
},
35-
onError: function(err) {
36-
console.log(err);
37-
}
36+
onError: console.log
3837
});
3938
conn.sync();
4039

4140
});
42-
it('should retrieve stream', function(done) {
41+
42+
it('should retrieve stream', done => {
4343
// Given
44-
var conn = connect("bolt://localhost")
44+
const conn = connect("bolt://localhost");
4545

4646
// When
47-
var records = [];
48-
conn.initialize( "mydriver/0.0.0", {scheme: "basic", principal: "neo4j", credentials: "neo4j"} );
49-
conn.run( "RETURN 1.0", {} );
50-
conn.pullAll( {
51-
onNext: function( record ) {
52-
records.push( record );
47+
const records = [];
48+
conn.initialize("mydriver/0.0.0", {scheme: "basic", principal: "neo4j", credentials: "neo4j"});
49+
conn.run("RETURN 1.0", {});
50+
conn.pullAll({
51+
onNext: record => {
52+
records.push(record);
5353
},
54-
onCompleted: function( tail ) {
55-
expect( records[0][0] ).toBe( 1 );
54+
onCompleted: () => {
55+
expect(records[0][0]).toBe(1);
5656
conn.close();
5757
done();
5858
}
5959
});
6060
conn.sync();
6161
});
6262

63-
it('should use DummyChannel to read what gets written', function(done) {
63+
it('should use DummyChannel to read what gets written', done => {
6464
// Given
65-
var observer = DummyChannel.observer;
66-
var conn = connect("bolt://localhost", {channel:DummyChannel.channel});
65+
const observer = DummyChannel.observer;
66+
const conn = connect("bolt://localhost", {channel: DummyChannel.channel});
6767

6868
// When
69-
var records = [];
70-
conn.initialize( "mydriver/0.0.0", {scheme: "basic", principal: "neo4j", credentials: "neo4j"} );
71-
conn.run( "RETURN 1", {} );
69+
conn.initialize("mydriver/0.0.0", {scheme: "basic", principal: "neo4j", credentials: "neo4j"});
70+
conn.run("RETURN 1", {});
7271
conn.sync();
73-
expect( observer.instance.toHex() ).toBe( '60 60 b0 17 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 41 b2 01 8e 6d 79 64 72 69 76 65 72 2f 30 2e 30 2e 30 a3 86 73 63 68 65 6d 65 85 62 61 73 69 63 89 70 72 69 6e 63 69 70 61 6c 85 6e 65 6f 34 6a 8b 63 72 65 64 65 6e 74 69 61 6c 73 85 6e 65 6f 34 6a 00 00 00 0c b2 10 88 52 45 54 55 52 4e 20 31 a0 00 00 ' );
72+
expect(observer.instance.toHex()).toBe('60 60 b0 17 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 41 b2 01 8e 6d 79 64 72 69 76 65 72 2f 30 2e 30 2e 30 a3 86 73 63 68 65 6d 65 85 62 61 73 69 63 89 70 72 69 6e 63 69 70 61 6c 85 6e 65 6f 34 6a 8b 63 72 65 64 65 6e 74 69 61 6c 73 85 6e 65 6f 34 6a 00 00 00 0c b2 10 88 52 45 54 55 52 4e 20 31 a0 00 00 ');
7473
done();
7574
});
7675

77-
it('should provide error message when connecting to http-port', function(done) {
76+
it('should provide error message when connecting to http-port', done => {
7877
// Given
79-
var conn = connect("bolt://localhost:7474", {encrypted:false});
78+
const conn = connect("bolt://localhost:7474", {encrypted: false});
8079

8180
// When
82-
conn.initialize( "mydriver/0.0.0", {scheme: "basic", principal: "neo4j", credentials: "neo4j"}, {
83-
onCompleted: function( msg ) {
81+
conn.initialize("mydriver/0.0.0", {scheme: "basic", principal: "neo4j", credentials: "neo4j"}, {
82+
onCompleted: msg => {
8483
},
85-
onError: function(err) {
84+
onError: err => {
8685
//only node gets the pretty error message
87-
if( require('../../lib/v1/internal/ch-node.js').available ) {
86+
if (require('../../lib/v1/internal/ch-node.js').available) {
8887
expect(err.message).toBe("Server responded HTTP. Make sure you are not trying to connect to the http endpoint " +
8988
"(HTTP defaults to port 7474 whereas BOLT defaults to port 7687)");
9089
}

0 commit comments

Comments
 (0)