1 | module.exports.close = function (leveldown, test, testCommon) {
|
2 | test('test close()', function (t) {
|
3 | var db = leveldown(testCommon.location())
|
4 |
|
5 | db.open(function (err) {
|
6 | t.error(err)
|
7 | t.doesNotThrow(
|
8 | db.close.bind(db, 'foo')
|
9 | , 'non-callback close()'
|
10 | )
|
11 |
|
12 | db.close(function (err) {
|
13 | t.error(err)
|
14 | t.end()
|
15 | })
|
16 | })
|
17 | })
|
18 | test('test database close event', function (t) {
|
19 | var db = leveldown(testCommon.location())
|
20 | db.once("closed", function(){
|
21 | t.notOk(db.isOpen())
|
22 | t.notOk(db.opened)
|
23 | t.end()
|
24 | })
|
25 | db.open(function (err) {
|
26 | t.error(err)
|
27 | t.ok(db.isOpen())
|
28 | t.ok(db.opened)
|
29 | db.close(function () {
|
30 | t.notOk(db.isOpen())
|
31 | t.notOk(db.opened)
|
32 | })
|
33 | })
|
34 | })
|
35 | }
|