-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX #714 checkAdapter does not cleanup test databases
- Loading branch information
Showing
3 changed files
with
83 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,60 @@ | ||
import assert from 'assert'; | ||
import config from './config'; | ||
import RxDB from '../../dist/lib/index'; | ||
import PouchDB from '../../dist/lib/pouch-db'; | ||
import { | ||
POUCHDB_LOCATION | ||
} from '../../dist/lib/plugins/adapter-check.js'; | ||
import { | ||
adapterObject | ||
} from '../../dist/lib/util'; | ||
|
||
import memdown from 'memdown'; | ||
if (!config.platform.isNode()) | ||
RxDB.plugin(require('pouchdb-adapter-idb')); | ||
|
||
config.parallel('adapter-check.test.js', () => { | ||
it('should be true on memory', async () => { | ||
const ok = await RxDB.checkAdapter('memory'); | ||
assert.ok(ok); | ||
describe('outcome', () => { | ||
it('should be true on memory', async () => { | ||
const ok = await RxDB.checkAdapter('memory'); | ||
assert.ok(ok); | ||
|
||
const ok2 = await RxDB.checkAdapter('memory'); | ||
assert.ok(ok2); | ||
const ok2 = await RxDB.checkAdapter('memory'); | ||
assert.ok(ok2); | ||
}); | ||
it('should be false on invalid string', async () => { | ||
const ok = await RxDB.checkAdapter('foobar'); | ||
assert.equal(ok, false); | ||
}); | ||
it('should be true on memdown (leveldb-adapter)', async () => { | ||
const ok = await RxDB.checkAdapter(memdown); | ||
assert.ok(ok); | ||
}); | ||
it('localstorage should be true on browser', async () => { | ||
const should = config.platform.isNode() ? false : true; | ||
const ok = await RxDB.checkAdapter('idb'); | ||
assert.equal(should, ok); | ||
}); | ||
}); | ||
it('should be false on invalid string', async () => { | ||
const ok = await RxDB.checkAdapter('foobar'); | ||
assert.equal(ok, false); | ||
}); | ||
it('should be true on memdown (leveldb-adapter)', async () => { | ||
const ok = await RxDB.checkAdapter(memdown); | ||
assert.ok(ok); | ||
}); | ||
it('localstorage should be true on browser', async () => { | ||
const should = config.platform.isNode() ? false : true; | ||
const ok = await RxDB.checkAdapter('idb'); | ||
assert.equal(should, ok); | ||
describe('ISSUES', () => { | ||
it('#715 Cleanup checkAdapter test databases after use', async () => { | ||
const ok = await RxDB.checkAdapter(memdown); | ||
assert.ok(ok); | ||
|
||
// ensure the test-document is removed | ||
const pouch = new PouchDB( | ||
POUCHDB_LOCATION, | ||
adapterObject(memdown), { | ||
auto_compaction: false, // no compaction because this only stores local documents | ||
revs_limit: 1 | ||
} | ||
); | ||
|
||
const found = await pouch.find({ | ||
selector: {} | ||
}); | ||
|
||
assert.equal(found.docs.length, 0); | ||
}); | ||
}); | ||
}); |