-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdel.spec.js
46 lines (32 loc) · 1.03 KB
/
del.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*eslint-env es6*/
const debug = require('debug')('got-couch')
const CONFIG = require('./config/_index.js')
const { initCouchDb, initTest } = require('./_test-base.js')
const DB_NAME = 'couch-del-test'
const couchdb = initCouchDb(CONFIG)
const test = initTest(couchdb, DB_NAME)
test('::del should delete a document with a given identifier from ' +
' the database.', t =>
couchdb.then((connection) => {
connection.insert(DB_NAME, { foo: 'bar2', baz: 'buzz2' })
.then((result) => connection.get(DB_NAME, result.body.id))
.then((result) => connection.del(
DB_NAME, result.body._id, result.body._rev
))
.then(() => connection.query(DB_NAME, {
selector: { foo: 'bar2', baz: 'buzz2' }
}, {}))
.then((result) => {
const expected_count = 0
t.is(result.body.docs.length, expected_count, 'list count is not 0')
})
.catch((err) => {
t.fail(err)
})
})
.catch((err) => {
debug("DELETE: %o", err)
t.fail(err)
throw err
})
)