8000 GitHub - dominicbarnes/nock-couchdb: A nock helper library for mocking a CouchDB server · GitHub
[go: up one dir, main page]

Skip to content

About

A nock helper library for mocking a CouchDB server

Resources

Stars

1 star 8000

Watchers

1 watching

Forks

Latest commit

 

History

37 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nock-couchdb

A nock helper library for mocking a CouchDB server

NOTE: this library is under heavy development right now, and is missing a lot of features, but feel free to monitor the issues/milestones for progress updates.

Install

$ npm install nock-couchdb

Usage

Most calls in this API use nock to add an interceptor for a given HTTP request reflected by the server/database/document meta.

var assert = require('assert');
var couchdb = require('nock-couchdb');
var supertest = require('supertest');

var url = 'http://localhost:5984/';
var server = couchdb.server(url);
var request = supertest(url);

describe('...', function () {
  it('...', function (done) {
    server
      .database('db')
      .document('doc')
      .get({ hello: 'world' }); // adds a nock interceptor
      
    request
      .get('doc/db')
      .expect(200)
      .expect(function (res) {
        assert.equal(res.body.hello, 'world');
      })
      .end(done);
  });
});

Chainable API

couchdb.server(href)

The top-level interface, which reflects a CouchDB server. The specified href points to the CouchDB root. (default: http://localhost:5984/)

server.database(name)

Part of the chainable interface, but reflects a specific database within the parent server.

database.document(id)

Part of the chainable interface, but reflects a specific document within the parent database/server.

Mock API

server.info([data])

Parameter Type Description
data Object Customizes the response body

Sets up a mock for the server API root.

database.info([data])

Parameter Type Description
data Object Customizes the response body

Sets up a mock for the database API root.

document.get([data])

Parameter Type Description
data Object Customizes the response body

Sets up a mock for retrieving the document.

About

A nock helper library for mocking a CouchDB server

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

0