New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

couchdb-change-events

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

couchdb-change-events - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

2

package.json
{
"name": "couchdb-change-events",
"version": "1.0.7",
"version": "1.0.8",
"description": "This library will emit changes done in couchdb.",

@@ -5,0 +5,0 @@ "main": "index.js",

[![Build Status](https://travis-ci.org/soukand/couchdb-change-events.svg?branch=master)](https://travis-ci.org/soukand/couchdb-change-events) [![Code Climate](https://codeclimate.com/github/soukand/couchdb-change-events/badges/gpa.svg)](https://codeclimate.com/github/soukand/couchdb-change-events) [![Issue Count](https://codeclimate.com/github/soukand/couchdb-change-events/badges/issue_count.svg)](https://codeclimate.com/github/soukand/couchdb-change-events) [![Test Coverage](https://codeclimate.com/github/soukand/couchdb-change-events/badges/coverage.svg)](https://codeclimate.com/github/soukand/couchdb-change-events/coverage)
The library is still in progress. It works, but it is missing some features and tests.
I see that some of you have already downloaded it and it had a bug in it.
The library is still in progress. It works, but it is missing some features.
I will provide simple example how to use it. Documentation will come soon.
I will provide simple example how to use it. Full documentation will come soon.

@@ -13,18 +12,18 @@ ### Usage

const couchdbEvents = new CouchdbChangeEvents({
host: 'localhost',
db: 'my_database'
host: 'localhost',
db: 'my_database'
});
couchdbEvents.on('data', (data) => {
console.log('data:', data);
console.log('data', data);
});
couchdbEvents.on('couchdb_status', (status) => {
console.log(`couchdb status: ${status}`);
console.log(`couchdb status: ${status}`);
});
couchdbEvents.on('couchdb_error', (error) => {
console.log('error', error);
console.log('error', error);
});
```

@@ -79,2 +79,12 @@ const proxyquire = require('proxyquire').noCallThru(),

it('uses default heartbeat, if empty heartbeat is provided', () => {
changeEvents = new CouchdbChangeEvents({
db: 'my_database',
autoConnect: false,
heartbeat: null
});
should.equal(changeEvents.heartbeat, 2000);
});
it('uses parameter "lastEventId" from provided config', () => {

@@ -351,7 +361,13 @@ changeEvents = new CouchdbChangeEvents({

it('emits received event', () => {
changeEvents.onCouchdbChange('{"seq": 32}');
changeEvents.onCouchdbChange('{"seq": 32}\n{"seq": 33}\n');
should.equal(changeEvents.emit.callCount, 2);
should.deepEqual(changeEvents.emit.firstCall.args, [
'data', { seq: 32 }
]);
should.deepEqual(changeEvents.emit.secondCall.args, [
'data', { seq: 33 }
]);
});

@@ -395,3 +411,3 @@ });

it('sets couchdb status to disconnected, if its not already', () => {
changeEvents.reconnect('');
changeEvents.reconnect();

@@ -405,3 +421,3 @@ should.equal(

it('tries to reconnect in 1 second', () => {
changeEvents.reconnect('');
changeEvents.reconnect();

@@ -415,2 +431,135 @@ should.equal(

});
describe('.setCouchdbStatus()', () => {
let changeEvents;
beforeEach(() => {
changeEvents = new CouchdbChangeEvents({
db: 'my_database',
autoConnect: false
});
changeEvents.emit = sinon.spy();
});
it('sets new status, if status is different', () => {
changeEvents.couchdbStatus = 'disconnected';
changeEvents.setCouchdbStatus('connected');
should.equal(changeEvents.couchdbStatus, 'connected');
});
it('emits couchdb status, if status is different', () => {
changeEvents.couchdbStatus = 'disconnected';
changeEvents.setCouchdbStatus('connected');
should.deepEqual(changeEvents.emit.firstCall.args, [
'couchdb_status', 'connected'
]);
});
it('does not emit couchdb status, if status is the same', () => {
changeEvents.couchdbStatus = 'connected';
changeEvents.setCouchdbStatus('connected');
should.equal(changeEvents.emit.callCount, 0);
});
});
describe('.getRequestOptions()', () => {
it('returns a host in options', () => {
const changeEvents = new CouchdbChangeEvents({
db: 'my_database',
autoConnect: false,
host: '127.0.0.1'
});
should.equal(
changeEvents.getRequestOptions().host,
'127.0.0.1'
);
});
it('returns a port in options', () => {
const changeEvents = new CouchdbChangeEvents({
db: 'my_database',
autoConnect: false,
port: 1234
});
should.equal(
changeEvents.getRequestOptions().port,
1234
);
});
it('returns get method in options', () => {
const changeEvents = new CouchdbChangeEvents({
db: 'my_database',
autoConnect: false
});
should.equal(
changeEvents.getRequestOptions().method,
'get'
);
});
it('returns correct path in options without extra parameters', () => {
const changeEvents = new CouchdbChangeEvents({
db: 'my_database',
autoConnect: false
});
should.equal(
changeEvents.getRequestOptions().path,
`/my_database/_changes?feed=continuous&heartbeat=2000` +
`&include_docs=true`
);
});
it('returns correct path in options with lastEventId', () => {
const changeEvents = new CouchdbChangeEvents({
db: 'my_database',
autoConnect: false,
lastEventId: '32-dsjfa'
});
should.equal(
changeEvents.getRequestOptions().path,
`/my_database/_changes?feed=continuous&heartbeat=2000` +
`&include_docs=true&last-event-id=32-dsjfa`
);
});
it('returns correct path in options, includeDocs is false', () => {
const changeEvents = new CouchdbChangeEvents({
db: 'my_database',
autoConnect: false,
includeDocs: false
});
should.equal(
changeEvents.getRequestOptions().path,
`/my_database/_changes?feed=continuous&heartbeat=2000`
);
});
it('encodes uri components', () => {
const changeEvents = new CouchdbChangeEvents({
db: 'my_database/',
autoConnect: false,
lastEventId: '82-/'
});
should.equal(
changeEvents.getRequestOptions().path,
`/my_database%2F/_changes?feed=continuous&heartbeat=2000` +
`&include_docs=true&last-event-id=82-%2F`
);
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc