@@ -27,26 +27,27 @@ var _console = console;
2727* DO NOT add tests to this file that are not for that exact purpose.
2828* DO NOT modify these tests without ensuring they remain consistent with the equivalent examples in other drivers
2929*/
30- xdescribe ( 'examples' , function ( ) {
30+ describe ( 'examples' , function ( ) {
3131
32- var driver , session , out , console ;
32+ var driverGlobal , sessionGlobal , out , console ;
3333
3434 beforeEach ( function ( done ) {
3535 var neo4j = neo4jv1 ;
3636 // 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" ) ) ;
3838 //end::construct-driver[]
39- session = driver . session ( ) ;
39+ sessionGlobal = driverGlobal . session ( ) ;
4040
4141 // Override console.log, to assert on stdout output
4242 out = [ ] ;
4343 console = { log : function ( msg ) { out . push ( msg ) ; } } ;
4444
45- session . run ( "MATCH (n) DETACH DELETE n" ) . then ( done ) ;
45+ sessionGlobal . run ( "MATCH (n) DETACH DELETE n" ) . then ( done ) ;
4646 } ) ;
4747
4848 afterEach ( function ( ) {
49- driver . close ( ) ;
49+ sessionGlobal . close ( ) ;
50+ driverGlobal . close ( ) ;
5051 } ) ;
5152
5253 it ( 'should document a minimal import and usage example' , function ( done ) {
@@ -65,31 +66,39 @@ xdescribe('examples', function() {
6566 . run ( "MATCH (p:Person) WHERE p.name = 'Neo' RETURN p.age" )
6667 . then ( function ( result ) {
6768 console . log ( "Neo is " + result . records [ 0 ] . get ( "p.age" ) . toInt ( ) + " years old." ) ;
68-
6969 session . close ( ) ;
7070 driver . close ( ) ;
71- done ( ) ;
7271 } ) ;
7372 // tag::minimal-example[]
73+ setTimeout ( function ( ) {
74+ expect ( out [ 0 ] ) . toBe ( "Neo is 23 years old." ) ;
75+ done ( ) ;
76+ } , 500 ) ;
7477 } ) ;
7578
7679 it ( 'should be able to configure session pool size' , function ( done ) {
7780 var neo4j = neo4jv1 ;
7881 // 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 } ) ;
8083 //end::configuration[]
8184
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 ( ) ;
8791 driver . close ( ) ;
88- done ( ) ;
8992 } ) ;
93+
94+ setTimeout ( function ( ) {
95+ expect ( out [ 0 ] ) . toBe ( 1 ) ;
96+ done ( ) ;
97+ } , 500 ) ;
9098 } ) ;
9199
92100 it ( 'should document a statement' , function ( done ) {
101+ var session = sessionGlobal ;
93102 var resultPromise =
94103 // tag::statement[]
95104 session
@@ -108,6 +117,7 @@ xdescribe('examples', function() {
108117 } ) ;
109118
110119 it ( 'should document a statement without parameters' , function ( done ) {
120+ var session = sessionGlobal ;
111121 var resultPromise =
112122 // tag::statement-without-parameters[]
113123 session
@@ -127,6 +137,7 @@ xdescribe('examples', function() {
127137 } ) ;
128138
129139 it ( 'should be able to iterate results' , function ( done ) {
140+ var session = sessionGlobal ;
130141 // tag::retain-result-query[]
131142 session
132143 . run ( "MATCH (p:Person { name: {name} }) RETURN p.age" , { name : "The One" } )
@@ -148,6 +159,8 @@ xdescribe('examples', function() {
148159 } ) ;
149160
150161 it ( 'should be able to do nested queries' , function ( done ) {
162+ var session = sessionGlobal ;
163+
151164 session . run ( "CREATE (:Person {name:'The One'})" ) . then ( function ( ) {
152165 // tag::result-cursor[]
153166 session
@@ -173,6 +186,8 @@ xdescribe('examples', function() {
173186 } ) ;
174187
175188 it ( 'should be able to retain for later processing' , function ( done ) {
189+ var session = sessionGlobal ;
190+
176191 session . run ( "CREATE (:Person {name:'The One', age: 23})" ) . then ( function ( ) {
177192 // tag::retain-result-process[]
178193 session
@@ -197,6 +212,8 @@ xdescribe('examples', function() {
197212
198213
199214 it ( 'should be able to profile' , function ( done ) {
215+ var session = sessionGlobal ;
216+
200217 session . run ( "CREATE (:Person {name:'The One', age: 23})" ) . then ( function ( ) {
201218 // tag::retain-result-process[]
202219 session
@@ -215,6 +232,8 @@ xdescribe('examples', function() {
215232 } ) ;
216233
217234 it ( 'should be able to see notifications' , function ( done ) {
235+ var session = sessionGlobal ;
236+
218237 // tag::retain-result-process[]
219238 session
220239 . run ( "EXPLAIN MATCH (a), (b) RETURN a,b" )
@@ -233,6 +252,8 @@ xdescribe('examples', function() {
233252 } ) ;
234253
235254 it ( 'should document committing a transaction' , function ( ) {
255+ var session = sessionGlobal ;
256+
236257 // tag::transaction-commit[]
237258 var tx = session . beginTransaction ( ) ;
238259 tx . run ( "CREATE (p:Person { name: 'The One' })" ) ;
@@ -241,6 +262,8 @@ xdescribe('examples', function() {
241262 } ) ;
242263
243264 it ( 'should document rolling back a transaction' , function ( ) {
265+ var session = sessionGlobal ;
266+
244267 // tag::transaction-rollback[]
245268 var tx = session . beginTransaction ( ) ;
246269 tx . run ( "CREATE (p:Person { name: 'The One' })" ) ;
@@ -249,6 +272,8 @@ xdescribe('examples', function() {
249272 } ) ;
250273
251274 it ( 'should document how to require encryption' , function ( ) {
275+ var session = sessionGlobal ;
276+
252277 var neo4j = neo4jv1 ;
253278 // tag::tls-require-encryption[]
254279 var driver = neo4j . driver ( "bolt://localhost" , neo4j . auth . basic ( "neo4j" , "neo4j" ) , {
0 commit comments