Merge pull request #725 from orbitdb/fix/catch-unhandled-error-in-test

Catch unhandled error in test
This commit is contained in:
shamb0t 2019-11-14 12:34:17 +00:00 committed by GitHub
commit fda5ea9cb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,9 +122,18 @@ Object.keys(testAPIs).forEach(API => {
it('closes database while loading', async () => {
db = await orbitdb1.eventlog(address)
db.load() // don't wait for load to finish
await db.close()
assert.equal(db._cache.store, null)
await new Promise(async (resolve, reject) => {
// don't wait for load to finish
db.load().catch(e => {
if (e.toString() !== 'ReadError: Database is not open') {
reject(e)
} else {
assert.equal(db._cache.store, null)
resolve()
}
})
await db.close()
})
})
it('load, add one, close - several times', async () => {