@@ -219,9 +219,7 @@ describe('transaction', function() {
219
219
} ) ;
220
220
221
221
it ( 'should provide bookmark on commit' , function ( done ) {
222
- //bookmarking is not in 3.0
223
- if ( ! server ) {
224
- done ( ) ;
222
+ if ( neo4jVersionOlderThan31 ( done ) ) {
225
223
return ;
226
224
}
227
225
@@ -232,11 +230,71 @@ describe('transaction', function() {
232
230
tx . run ( "CREATE (:TXNode2)" ) ;
233
231
tx . commit ( )
234
232
. then ( function ( ) {
235
- expect ( session . lastBookmark ( ) ) . toBeDefined ( ) ;
233
+ expectValidLastBookmark ( session ) ;
236
234
done ( ) ;
237
235
} ) ;
238
236
} ) ;
239
237
238
+ it ( 'should have no bookmark when tx is rolled back' , function ( done ) {
239
+ if ( neo4jVersionOlderThan31 ( done ) ) {
240
+ return ;
241
+ }
242
+
243
+ expect ( session . lastBookmark ( ) ) . not . toBeDefined ( ) ;
244
+ const tx1 = session . beginTransaction ( ) ;
245
+
246
+ tx1 . run ( 'CREATE ()' ) . then ( ( ) => {
247
+ tx1 . commit ( ) . then ( ( ) => {
248
+ expectValidLastBookmark ( session ) ;
249
+
250
+ const tx2 = session . beginTransaction ( ) ;
251
+ tx2 . run ( 'CREATE ()' ) . then ( ( ) => {
252
+ tx2 . rollback ( ) . then ( ( ) => {
253
+ expect ( session . lastBookmark ( ) ) . not . toBeDefined ( ) ;
254
+
255
+ const tx3 = session . beginTransaction ( ) ;
256
+ tx3 . run ( 'CREATE ()' ) . then ( ( ) => {
257
+ tx3 . commit ( ) . then ( ( ) => {
258
+ expectValidLastBookmark ( session ) ;
259
+ done ( ) ;
260
+ } ) ;
261
+ } ) ;
262
+ } ) ;
263
+ } ) ;
264
+ } ) ;
265
+ } ) ;
266
+ } ) ;
267
+
268
+ it ( 'should have no bookmark when tx fails' , function ( done ) {
269
+ if ( neo4jVersionOlderThan31 ( done ) ) {
270
+ return ;
271
+ }
272
+
273
+ expect ( session . lastBookmark ( ) ) . not . toBeDefined ( ) ;
274
+ const tx1 = session . beginTransaction ( ) ;
275
+
276
+ tx1 . run ( 'CREATE ()' ) . then ( ( ) => {
277
+ tx1 . commit ( ) . then ( ( ) => {
278
+ expectValidLastBookmark ( session ) ;
279
+
280
+ const tx2 = session . beginTransaction ( ) ;
281
+
282
+ tx2 . run ( 'RETURN' ) . catch ( error => {
283
+ expectSyntaxError ( error ) ;
284
+ expect ( session . lastBookmark ( ) ) . not . toBeDefined ( ) ;
285
+
286
+ const tx3 = session . beginTransaction ( ) ;
287
+ tx3 . run ( 'CREATE ()' ) . then ( ( ) => {
288
+ tx3 . commit ( ) . then ( ( ) => {
289
+ expectValidLastBookmark ( session ) ;
290
+ done ( ) ;
291
+ } ) ;
292
+ } ) ;
293
+ } ) ;
294
+ } ) ;
295
+ } ) ;
296
+ } ) ;
297
+
240
298
it ( 'should rollback when very first run fails' , done => {
241
299
const tx1 = session . beginTransaction ( ) ;
242
300
tx1 . run ( 'RETURN foo' )
@@ -349,6 +407,11 @@ describe('transaction', function() {
349
407
expect ( code ) . toBe ( 'Neo.ClientError.Statement.SyntaxError' ) ;
350
408
}
351
409
410
+ function expectValidLastBookmark ( session ) {
411
+ expect ( session . lastBookmark ( ) ) . toBeDefined ( ) ;
412
+ expect ( session . lastBookmark ( ) ) . not . toBeNull ( ) ;
413
+ }
414
+
352
415
function neo4jVersionOlderThan31 ( done ) {
353
416
//lazy way of checking the version number
354
417
//if server has been set we know it is at least
0 commit comments