-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathget.spec.js
41 lines (29 loc) · 966 Bytes
/
get.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
/*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-get-test'
const couchdb = initCouchDb(CONFIG)
const test = initTest(couchdb, DB_NAME)
test('::create should store a document in the database with your ' +
'provided identifier and then ::get should be able to retrieve your ' +
'document by that identifier', t =>
couchdb.then((connection) => {
connection.create(DB_NAME, 'my-foo', { boo: 'Casper', moo: 'Elsie' })
.then((res) => t.is(res.body.id, 'my-foo'))
.then(() => connection.get(DB_NAME, 'my-foo'))
.then((res) => res.body)
.then((doc) => {
t.is(doc.boo, 'Casper')
t.is(doc.moo, 'Elsie')
})
.catch((err) => {
t.fail(err)
})
})
.catch((err) => {
debug("GET: %o", err)
t.fail(err)
throw err
})
)