2.0.1 • Published 5 years ago

unexpected-couchdb v2.0.1

Weekly downloads
12
License
BSD-3-Clause
Repository
github
Last release
5 years ago

unexpected-couchdb

This unexpected plugin enables unit testing requests against a mock couchdb server.

It leverages unexpected-mitm and the mock-couch library integrating them into a neat assertion. Teh structure of the database is specified declaratively and appropriate responses generated automatically.

Example

The following example uses unexpected-http to assert the generated response is valid.

var expect = require('unexpected').clone();

expect.installPlugin(require('unexpected-couchdb'));
expect.installPlugin(require('unexpected-http'));

describe('documentation', function () {
    it('should return the contents of myDatabase including the documents', function () {
        return expect('GET /myDatabase/_all_docs?include_docs=true', 'with couchdb mocked out', {
            myDatabase: {
                docs: [
                    {
                        _id: 'myDocument',
                        foo: 'bar',
                        baz: 1
                    }
                ]
            }
        }, 'to yield response', {
            statusCode: 200,
            body: {
                total_rows: 1,
                rows: [
                    {
                        id: 'myDocument',
                        doc: {
                            _id: 'myDocument',
                            foo: 'bar',
                            baz: 1
                        }
                    }
                ]
            }
        });
    });
});

License

Licensed under a standard 3-clause BSD license -- see the LICENSE file for details.

2.0.1

5 years ago

2.0.0

5 years ago

1.0.0

6 years ago

0.10.1

9 years ago

0.1.2

9 years ago

0.10.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago