File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
packages/database/test/exp Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -267,19 +267,29 @@ describe('Database@exp Tests', () => {
267
267
defaultApp = undefined ;
268
268
} ) ;
269
269
270
- it ( 'waits until the database is online to resolve the get request ' , async ( ) => {
270
+ it ( 'blocks get requests until the database is online' , async ( ) => {
271
271
const db = getDatabase ( defaultApp ) ;
272
- const r = ref ( db , 'foo2 ' ) ;
272
+ const r = ref ( db , 'foo3 ' ) ;
273
273
const initial = {
274
274
test : 1
275
275
} ;
276
276
await set ( r , initial ) ;
277
277
goOffline ( db ) ;
278
- const getValue = promiseWithTimeout ( get ( r ) ) ;
279
- expect ( getValue ) . to . be . rejectedWith ( 'timeout!' ) ;
278
+ const pendingGet = get ( r ) ;
279
+ let resolvedData : any = null ;
280
+ pendingGet . then (
281
+ data => {
282
+ resolvedData = data ;
283
+ } ,
284
+ ( ) => {
285
+ resolvedData = new Error ( 'rejected' ) ;
286
+ }
287
+ ) ;
288
+ await waitFor ( 2000 ) ;
289
+ expect ( resolvedData ) . to . equal ( null ) ;
280
290
goOnline ( db ) ;
281
- const deferredTimeout2 = await promiseWithTimeout ( get ( r ) ) ;
282
- expect ( deferredTimeout2 . val ( ) ) . to . deep . equal ( initial ) ;
291
+ await waitFor ( 2000 ) ;
292
+ expect ( resolvedData . val ( ) ) . to . deep . equal ( initial ) ;
283
293
} ) ;
284
294
285
295
it ( 'Can listen to transaction changes' , async ( ) => {
You can’t perform that action at this time.
0 commit comments