@@ -27,26 +27,27 @@ var _console = console;
27
27
* DO NOT add tests to this file that are not for that exact purpose.
28
28
* DO NOT modify these tests without ensuring they remain consistent with the equivalent examples in other drivers
29
29
*/
30
- xdescribe ( 'examples' , function ( ) {
30
+ describe ( 'examples' , function ( ) {
31
31
32
- var driver , session , out , console ;
32
+ var driverGlobal , sessionGlobal , out , console ;
33
33
34
34
beforeEach ( function ( done ) {
35
35
var neo4j = neo4jv1 ;
36
36
// tag::construct-driver[]
37
- driver = neo4j . driver ( "bolt://localhost" , neo4jv1 . auth . basic ( "neo4j" , "neo4j" ) ) ;
37
+ driverGlobal = neo4j . driver ( "bolt://localhost" , neo4jv1 . auth . basic ( "neo4j" , "neo4j" ) ) ;
38
38
//end::construct-driver[]
39
- session = driver . session ( ) ;
39
+ sessionGlobal = driverGlobal . session ( ) ;
40
40
41
41
// Override console.log, to assert on stdout output
42
42
out = [ ] ;
43
43
console = { log : function ( msg ) { out . push ( msg ) ; } } ;
44
44
45
- session . run ( "MATCH (n) DETACH DELETE n" ) . then ( done ) ;
45
+ sessionGlobal . run ( "MATCH (n) DETACH DELETE n" ) . then ( done ) ;
46
46
} ) ;
47
47
48
48
afterEach ( function ( ) {
49
- driver . close ( ) ;
49
+ sessionGlobal . close ( ) ;
50
+ driverGlobal . close ( ) ;
50
51
} ) ;
51
52
52
53
it ( 'should document a minimal import and usage example' , function ( done ) {
@@ -65,31 +66,39 @@ xdescribe('examples', function() {
65
66
. run ( "MATCH (p:Person) WHERE p.name = 'Neo' RETURN p.age" )
66
67
. then ( function ( result ) {
67
68
console . log ( "Neo is " + result . records [ 0 ] . get ( "p.age" ) . toInt ( ) + " years old." ) ;
68
-
69
69
session . close ( ) ;
70
70
driver . close ( ) ;
71
- done ( ) ;
72
71
} ) ;
73
72
// tag::minimal-example[]
73
+ setTimeout ( function ( ) {
74
+ expect ( out [ 0 ] ) . toBe ( "Neo is 23 years old." ) ;
75
+ done ( ) ;
76
+ } , 500 ) ;
74
77
} ) ;
75
78
76
79
it ( 'should be able to configure session pool size' , function ( done ) {
77
80
var neo4j = neo4jv1 ;
78
81
// tag::configuration[]
79
- driver = neo4j . driver ( "bolt://localhost" , neo4jv1 . auth . basic ( "neo4j" , "neo4j" ) , { connectionPoolSize : 10 } ) ;
82
+ var driver = neo4j . driver ( "bolt://localhost" , neo4jv1 . auth . basic ( "neo4j" , "neo4j" ) , { connectionPoolSize : 50 } ) ;
80
83
//end::configuration[]
81
84
82
- session . run ( "CREATE (neo:Person {name:'Neo', age:23})" ) ;
83
- session
84
- . run ( "MATCH (p:Person) WHERE p.name = 'Neo' RETURN p.age" )
85
- . then ( function ( result ) {
86
- session . close ( ) ;
85
+ var s = driver . session ( ) ;
86
+ s . run ( "CREATE (p:Person { name: {name} })" , { name : "The One" } )
87
+ . then ( function ( result ) {
88
+ var theOnesCreated = result . summary . updateStatistics . nodesCreated ( ) ;
89
+ console . log ( theOnesCreated ) ;
90
+ s . close ( ) ;
87
91
driver . close ( ) ;
88
- done ( ) ;
89
92
} ) ;
93
+
94
+ setTimeout ( function ( ) {
95
+ expect ( out [ 0 ] ) . toBe ( 1 ) ;
96
+ done ( ) ;
97
+ } , 500 ) ;
90
98
} ) ;
91
99
92
100
it ( 'should document a statement' , function ( done ) {
101
+ var session = sessionGlobal ;
93
102
var resultPromise =
94
103
// tag::statement[]
95
104
session
@@ -108,6 +117,7 @@ xdescribe('examples', function() {
108
117
} ) ;
109
118
110
119
it ( 'should document a statement without parameters' , function ( done ) {
120
+ var session = sessionGlobal ;
111
121
var resultPromise =
112
122
// tag::statement-without-parameters[]
113
123
session
@@ -127,6 +137,7 @@ xdescribe('examples', function() {
127
137
} ) ;
128
138
129
139
it ( 'should be able to iterate results' , function ( done ) {
140
+ var session = sessionGlobal ;
130
141
// tag::retain-result-query[]
131
142
session
132
143
. run ( "MATCH (p:Person { name: {name} }) RETURN p.age" , { name : "The One" } )
@@ -148,6 +159,8 @@ xdescribe('examples', function() {
148
159
} ) ;
149
160
150
161
it ( 'should be able to do nested queries' , function ( done ) {
162
+ var session = sessionGlobal ;
163
+
151
164
session . run ( "CREATE (:Person {name:'The One'})" ) . then ( function ( ) {
152
165
// tag::result-cursor[]
153
166
session
@@ -173,6 +186,8 @@ xdescribe('examples', function() {
173
186
} ) ;
174
187
175
188
it ( 'should be able to retain for later processing' , function ( done ) {
189
+ var session = sessionGlobal ;
190
+
176
191
session . run ( "CREATE (:Person {name:'The One', age: 23})" ) . then ( function ( ) {
177
192
// tag::retain-result-process[]
178
193
session
@@ -197,6 +212,8 @@ xdescribe('examples', function() {
197
212
198
213
199
214
it ( 'should be able to profile' , function ( done ) {
215
+ var session = sessionGlobal ;
216
+
200
217
session . run ( "CREATE (:Person {name:'The One', age: 23})" ) . then ( function ( ) {
201
218
// tag::retain-result-process[]
202
219
session
@@ -215,6 +232,8 @@ xdescribe('examples', function() {
215
232
} ) ;
216
233
217
234
it ( 'should be able to see notifications' , function ( done ) {
235
+ var session = sessionGlobal ;
236
+
218
237
// tag::retain-result-process[]
219
238
session
220
239
. run ( "EXPLAIN MATCH (a), (b) RETURN a,b" )
@@ -233,6 +252,8 @@ xdescribe('examples', function() {
233
252
} ) ;
234
253
235
254
it ( 'should document committing a transaction' , function ( ) {
255
+ var session = sessionGlobal ;
256
+
236
257
// tag::transaction-commit[]
237
258
var tx = session . beginTransaction ( ) ;
238
259
tx . run ( "CREATE (p:Person { name: 'The One' })" ) ;
@@ -241,6 +262,8 @@ xdescribe('examples', function() {
241
262
} ) ;
242
263
243
264
it ( 'should document rolling back a transaction' , function ( ) {
265
+ var session = sessionGlobal ;
266
+
244
267
// tag::transaction-rollback[]
245
268
var tx = session . beginTransaction ( ) ;
246
269
tx . run ( "CREATE (p:Person { name: 'The One' })" ) ;
@@ -249,6 +272,8 @@ xdescribe('examples', function() {
249
272
} ) ;
250
273
251
274
it ( 'should document how to require encryption' , function ( ) {
275
+ var session = sessionGlobal ;
276
+
252
277
var neo4j = neo4jv1 ;
253
278
// tag::tls-require-encryption[]
254
279
var driver = neo4j . driver ( "bolt://localhost" , neo4j . auth . basic ( "neo4j" , "neo4j" ) , {
0 commit comments