Skip to content

Commit 2f3bf31

Browse files
committed
Addressed comment
1 parent 062dd6e commit 2f3bf31

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

packages/database/test/exp/integration.test.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,19 +267,29 @@ describe('Database@exp Tests', () => {
267267
defaultApp = undefined;
268268
});
269269

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 () => {
271271
const db = getDatabase(defaultApp);
272-
const r = ref(db, 'foo2');
272+
const r = ref(db, 'foo3');
273273
const initial = {
274274
test: 1
275275
};
276276
await set(r, initial);
277277
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);
280290
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);
283293
});
284294

285295
it('Can listen to transaction changes', async () => {

0 commit comments

Comments
 (0)