Skip to content

Commit 2600668

Browse files
committed
Fix couple bookmark tests
Which assumed that auto-commit transactions do not produce bookmarks.
1 parent df351e5 commit 2600668

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

test/v1/session.test.js

+11-16
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,9 @@ describe('session', () => {
583583
return;
584584
}
585585

586-
const bookmarkBefore = session.lastBookmark();
586+
// new session without initial bookmark
587+
session = driver.session();
588+
expect(session.lastBookmark()).toBeNull();
587589

588590
const tx = session.beginTransaction();
589591
tx.run('RETURN 42 as answer').then(result => {
@@ -592,11 +594,7 @@ describe('session', () => {
592594
expect(records[0].get('answer').toNumber()).toEqual(42);
593595

594596
tx.commit().then(() => {
595-
const bookmarkAfter = session.lastBookmark();
596-
expect(bookmarkAfter).toBeDefined();
597-
expect(bookmarkAfter).not.toBeNull();
598-
expect(bookmarkAfter).not.toEqual(bookmarkBefore);
599-
597+
verifyBookmark(session.lastBookmark());
600598
done();
601599
});
602600
});
@@ -631,12 +629,10 @@ describe('session', () => {
631629
tx.run('CREATE ()').then(() => {
632630
tx.commit().then(() => {
633631
const bookmarkBefore = session.lastBookmark();
634-
expect(bookmarkBefore).toBeDefined();
635-
expect(bookmarkBefore).not.toBeNull();
632+
verifyBookmark(bookmarkBefore);
636633

637634
session.run('CREATE ()').then(() => {
638-
const bookmarkAfter = session.lastBookmark();
639-
expect(bookmarkAfter).toEqual(bookmarkBefore);
635+
verifyBookmark(session.lastBookmark());
640636
done();
641637
});
642638
});
@@ -648,17 +644,16 @@ describe('session', () => {
648644
return;
649645
}
650646

651-
const bookmarkBefore = session.lastBookmark();
647+
// new session without initial bookmark
648+
session = driver.session();
649+
expect(session.lastBookmark()).toBeNull();
650+
652651
const resultPromise = session.readTransaction(tx => tx.run('RETURN 42 AS answer'));
653652

654653
resultPromise.then(result => {
655654
expect(result.records.length).toEqual(1);
656655
expect(result.records[0].get('answer').toNumber()).toEqual(42);
657-
658-
const bookmarkAfter = session.lastBookmark();
659-
verifyBookmark(bookmarkAfter);
660-
expect(bookmarkAfter).not.toEqual(bookmarkBefore);
661-
656+
verifyBookmark(session.lastBookmark());
662657
done();
663658
});
664659
});

test/v1/transaction.test.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,11 @@ describe('transaction', () => {
233233
return;
234234
}
235235

236-
const tx = session.beginTransaction();
236+
// new session without initial bookmark
237+
session = driver.session();
237238
expect(session.lastBookmark()).toBeNull();
239+
240+
const tx = session.beginTransaction();
238241
tx.run("CREATE (:TXNode1)").then(() => {
239242
tx.run("CREATE (:TXNode2)").then(() => {
240243
tx.commit().then(() => {
@@ -250,9 +253,11 @@ describe('transaction', () => {
250253
return;
251254
}
252255

256+
// new session without initial bookmark
257+
session = driver.session();
253258
expect(session.lastBookmark()).toBeNull();
254-
const tx1 = session.beginTransaction();
255259

260+
const tx1 = session.beginTransaction();
256261
tx1.run('CREATE ()').then(() => {
257262
tx1.commit().then(() => {
258263
expectValidLastBookmark(session);
@@ -283,7 +288,10 @@ describe('transaction', () => {
283288
return;
284289
}
285290

291+
// new session without initial bookmark
292+
session = driver.session();
286293
expect(session.lastBookmark()).toBeNull();
294+
287295
const tx1 = session.beginTransaction();
288296

289297
tx1.run('CREATE ()').then(() => {

0 commit comments

Comments
 (0)