@@ -219,9 +219,7 @@ describe('transaction', function() {
219219 } ) ;
220220
221221 it ( 'should provide bookmark on commit' , function ( done ) {
222- //bookmarking is not in 3.0
223- if ( ! server ) {
224- done ( ) ;
222+ if ( neo4jVersionOlderThan31 ( done ) ) {
225223 return ;
226224 }
227225
@@ -232,11 +230,71 @@ describe('transaction', function() {
232230 tx . run ( "CREATE (:TXNode2)" ) ;
233231 tx . commit ( )
234232 . then ( function ( ) {
235- expect ( session . lastBookmark ( ) ) . toBeDefined ( ) ;
233+ expectValidLastBookmark ( session ) ;
236234 done ( ) ;
237235 } ) ;
238236 } ) ;
239237
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+
240298 it ( 'should rollback when very first run fails' , done => {
241299 const tx1 = session . beginTransaction ( ) ;
242300 tx1 . run ( 'RETURN foo' )
@@ -349,6 +407,11 @@ describe('transaction', function() {
349407 expect ( code ) . toBe ( 'Neo.ClientError.Statement.SyntaxError' ) ;
350408 }
351409
410+ function expectValidLastBookmark ( session ) {
411+ expect ( session . lastBookmark ( ) ) . toBeDefined ( ) ;
412+ expect ( session . lastBookmark ( ) ) . not . toBeNull ( ) ;
413+ }
414+
352415 function neo4jVersionOlderThan31 ( done ) {
353416 //lazy way of checking the version number
354417 //if server has been set we know it is at least
0 commit comments