@@ -18,8 +18,6 @@ exports.get = function (test, testCommon) {
1818 const { testFresh, testClose } = testFactory ( test , testCommon )
1919
2020 testFresh ( 'get() changed entry from snapshot' , async function ( t , db ) {
21- t . plan ( 3 )
22-
2321 await db . put ( 'abc' , 'before' )
2422 const snapshot = db . snapshot ( )
2523 await db . put ( 'abc' , 'after' )
@@ -28,12 +26,16 @@ exports.get = function (test, testCommon) {
2826 t . is ( await db . get ( 'abc' , { snapshot } ) , 'before' )
2927 t . is ( await db . get ( 'other' , { snapshot } ) , undefined )
3028
29+ if ( testCommon . supports . getSync ) {
30+ t . is ( db . getSync ( 'abc' ) , 'after' )
31+ t . is ( db . getSync ( 'abc' , { snapshot } ) , 'before' )
32+ t . is ( db . getSync ( 'other' , { snapshot } ) , undefined )
33+ }
34+
3135 return snapshot . close ( )
3236 } )
3337
3438 testFresh ( 'get() deleted entry from snapshot' , async function ( t , db ) {
35- t . plan ( 3 )
36-
3739 await db . put ( 'abc' , 'before' )
3840 const snapshot = db . snapshot ( )
3941 await db . del ( 'abc' )
@@ -42,27 +44,34 @@ exports.get = function (test, testCommon) {
4244 t . is ( await db . get ( 'abc' , { snapshot } ) , 'before' )
4345 t . is ( await db . get ( 'other' , { snapshot } ) , undefined )
4446
47+ if ( testCommon . supports . getSync ) {
48+ t . is ( db . getSync ( 'abc' ) , undefined )
49+ t . is ( db . getSync ( 'abc' , { snapshot } ) , 'before' )
50+ t . is ( db . getSync ( 'other' , { snapshot } ) , undefined )
51+ }
52+
4553 return snapshot . close ( )
4654 } )
4755
4856 testFresh ( 'get() non-existent entry from snapshot' , async function ( t , db ) {
49- t . plan ( 2 )
50-
5157 const snapshot = db . snapshot ( )
5258 await db . put ( 'abc' , 'after' )
5359
5460 t . is ( await db . get ( 'abc' ) , 'after' )
5561 t . is ( await db . get ( 'abc' , { snapshot } ) , undefined )
5662
63+ if ( testCommon . supports . getSync ) {
64+ t . is ( db . getSync ( 'abc' ) , 'after' )
65+ t . is ( db . getSync ( 'abc' , { snapshot } ) , undefined )
66+ }
67+
5768 return snapshot . close ( )
5869 } )
5970
6071 testFresh ( 'get() entries from multiple snapshots' , async function ( t , db ) {
6172 const snapshots = [ ]
6273 const iterations = 100
6374
64- t . plan ( iterations )
65-
6675 for ( let i = 0 ; i < iterations ; i ++ ) {
6776 await db . put ( 'number' , i . toString ( ) )
6877 snapshots . push ( db . snapshot ( ) )
@@ -73,6 +82,10 @@ exports.get = function (test, testCommon) {
7382 const value = i . toString ( )
7483
7584 t . is ( await db . get ( 'number' , { snapshot } ) , value )
85+
86+ if ( testCommon . supports . getSync ) {
87+ t . is ( db . getSync ( 'number' , { snapshot } ) , value )
88+ }
7689 }
7790
7891 return Promise . all ( snapshots . map ( x => x . close ( ) ) )
@@ -90,12 +103,22 @@ exports.get = function (test, testCommon) {
90103 // Closing one snapshot should not affect the other
91104 t . is ( await db . get ( 'abc' , { snapshot : snapshot2 } ) , 'before' )
92105
106+ if ( testCommon . supports . getSync ) {
107+ t . is ( db . getSync ( 'abc' , { snapshot : snapshot2 } ) , 'before' )
108+ }
109+
93110 return snapshot2 . close ( )
94111 } )
95112
96113 testClose ( 'get()' , async function ( db , snapshot ) {
97114 return db . get ( 'xyz' , { snapshot } )
98115 } )
116+
117+ if ( testCommon . supports . getSync ) {
118+ testClose ( 'getSync()' , async function ( db , snapshot ) {
119+ return db . getSync ( 'xyz' , { snapshot } )
120+ } )
121+ }
99122}
100123
101124exports . getMany = function ( test , testCommon ) {
0 commit comments