@@ -10,7 +10,6 @@ module.exports = function (test, testCommon) {
1010 test ( 'deferred open(): put() and get() on new database' , function ( t ) {
1111 // 1) open database without callback, opens in next tick
1212 const db = testCommon . factory ( )
13- t . ok ( typeof db === 'object' && db !== null )
1413
1514 parallel ( [
1615 // 2) insert 3 values with put(), these should be deferred until the database is actually open
@@ -34,15 +33,29 @@ module.exports = function (test, testCommon) {
3433 } )
3534 } )
3635
37- // we should still be in a state of limbo down here, not opened or closed, but 'new'
38- t . is ( db . isOpen ( ) , false )
39- t . is ( db . isClosed ( ) , false )
36+ t . is ( db . status , 'opening' )
37+ } )
38+
39+ test ( 'deferred open(): put() and get() on reopened database' , async function ( t ) {
40+ const db = testCommon . factory ( )
41+
42+ await db . close ( )
43+ t . is ( db . status , 'closed' )
44+
45+ db . open ( ( ) => { } )
46+ t . is ( db . status , 'opening' )
47+
48+ await db . put ( 'beep' , 'boop' )
49+
50+ t . is ( db . status , 'open' )
51+ t . is ( await db . get ( 'beep' , { asBuffer : false } ) , 'boop' )
52+
53+ await db . close ( )
4054 } )
4155
4256 test ( 'deferred open(): batch() on new database' , function ( t ) {
4357 // 1) open database without callback, opens in next tick
4458 const db = testCommon . factory ( )
45- t . ok ( typeof db === 'object' && db !== null )
4659
4760 // 2) insert 3 values with batch(), these should be deferred until the database is actually open
4861 db . batch ( [
@@ -66,15 +79,12 @@ module.exports = function (test, testCommon) {
6679 } )
6780 } )
6881
69- // we should still be in a state of limbo down here, not opened or closed, but 'new'
70- t . is ( db . isOpen ( ) , false )
71- t . is ( db . isClosed ( ) , false )
82+ t . is ( db . status , 'opening' )
7283 } )
7384
7485 test ( 'deferred open(): chained batch() on new database' , function ( t ) {
7586 // 1) open database without callback, opens in next tick
7687 const db = testCommon . factory ( )
77- t . ok ( typeof db === 'object' && db !== null )
7888
7989 // 2) insert 3 values with batch(), these should be deferred until the database is actually open
8090 db . batch ( )
@@ -98,9 +108,7 @@ module.exports = function (test, testCommon) {
98108 } )
99109 } )
100110
101- // we should still be in a state of limbo down here, not opened or closed, but 'new'
102- t . is ( db . isOpen ( ) , false )
103- t . is ( db . isClosed ( ) , false )
111+ t . is ( db . status , 'opening' )
104112 } )
105113
106114 testCommon . streams && test ( 'deferred open(): test deferred ReadStream' , function ( t ) {
0 commit comments