|
16 | 16 | * See the License for the specific language governing permissions and |
17 | 17 | * limitations under the License. |
18 | 18 | */ |
19 | | -var DummyChannel = require('../../lib/v1/internal/ch-dummy.js'); |
20 | | -var connect = require("../../lib/v1/internal/connector.js").connect; |
21 | 19 |
|
22 | | -describe('connector', function() { |
| 20 | +import * as DummyChannel from "../../src/v1/internal/ch-dummy"; |
| 21 | +import {connect} from "../../src/v1/internal/connector"; |
23 | 22 |
|
24 | | - it('should read/write basic messages', function(done) { |
| 23 | +describe('connector', () => { |
| 24 | + |
| 25 | + it('should read/write basic messages', done => { |
25 | 26 | // Given |
26 | | - var conn = connect("bolt://localhost") |
| 27 | + const conn = connect("bolt://localhost"); |
27 | 28 |
|
28 | 29 | // 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(); |
32 | 33 | conn.close(); |
33 | 34 | done(); |
34 | 35 | }, |
35 | | - onError: function(err) { |
36 | | - console.log(err); |
37 | | - } |
| 36 | + onError: console.log |
38 | 37 | }); |
39 | 38 | conn.sync(); |
40 | 39 |
|
41 | 40 | }); |
42 | | - it('should retrieve stream', function(done) { |
| 41 | + |
| 42 | + it('should retrieve stream', done => { |
43 | 43 | // Given |
44 | | - var conn = connect("bolt://localhost") |
| 44 | + const conn = connect("bolt://localhost"); |
45 | 45 |
|
46 | 46 | // 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); |
53 | 53 | }, |
54 | | - onCompleted: function( tail ) { |
55 | | - expect( records[0][0] ).toBe( 1 ); |
| 54 | + onCompleted: () => { |
| 55 | + expect(records[0][0]).toBe(1); |
56 | 56 | conn.close(); |
57 | 57 | done(); |
58 | 58 | } |
59 | 59 | }); |
60 | 60 | conn.sync(); |
61 | 61 | }); |
62 | 62 |
|
63 | | - it('should use DummyChannel to read what gets written', function(done) { |
| 63 | + it('should use DummyChannel to read what gets written', done => { |
64 | 64 | // 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}); |
67 | 67 |
|
68 | 68 | // 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", {}); |
72 | 71 | 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 '); |
74 | 73 | done(); |
75 | 74 | }); |
76 | 75 |
|
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 => { |
78 | 77 | // Given |
79 | | - var conn = connect("bolt://localhost:7474", {encrypted:false}); |
| 78 | + const conn = connect("bolt://localhost:7474", {encrypted: false}); |
80 | 79 |
|
81 | 80 | // 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 => { |
84 | 83 | }, |
85 | | - onError: function(err) { |
| 84 | + onError: err => { |
86 | 85 | //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) { |
88 | 87 | expect(err.message).toBe("Server responded HTTP. Make sure you are not trying to connect to the http endpoint " + |
89 | 88 | "(HTTP defaults to port 7474 whereas BOLT defaults to port 7687)"); |
90 | 89 | } |
|
0 commit comments