Huge News!Announcing our $40M Series B led by Abstract Ventures.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.5 to 1.0.6

2

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

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

@@ -82,3 +82,4 @@ const proxyquire = require('proxyquire').noCallThru(),

db: 'my_database',
lastEventId: '127-eb534549c61b48f28c753ea95c64f02b'
lastEventId: '127-eb534549c61b48f28c753ea95c64f02b',
autoConnect: false
});

@@ -187,3 +188,4 @@

changeEvents = new CouchdbChangeEvents({
db: 'my_database'
db: 'my_database',
autoConnect: false
});

@@ -309,2 +311,104 @@

});
describe('.onCouchdbChange()', () => {
let changeEvents;
beforeEach(() => {
changeEvents = new CouchdbChangeEvents({
db: 'my_database',
autoConnect: false
});
changeEvents.lastHeartBeat = null;
changeEvents.setCouchdbStatus = sinon.spy();
changeEvents.emit = sinon.spy();
});
it('sets couchdb status to connected, if its not already', () => {
changeEvents.onCouchdbChange('');
should.equal(
changeEvents.setCouchdbStatus.firstCall.args[0],
'connected'
);
});
it('updates last heartbeat time', () => {
changeEvents.onCouchdbChange('');
const timeDelta = new Date().getTime() - changeEvents.lastHeartBeat;
should.equal(timeDelta < 15, true);
should.equal(timeDelta >= 0, true);
});
it('updates lastEventId, if real change is received', () => {
changeEvents.onCouchdbChange('{"seq": 32}');
should.equal(changeEvents.lastEventId, 32);
});
it('emits received event', () => {
changeEvents.onCouchdbChange('{"seq": 32}');
should.deepEqual(changeEvents.emit.firstCall.args, [
'data', { seq: 32 }
]);
});
});
describe('.emitError()', () => {
let changeEvents;
beforeEach(() => {
changeEvents = new CouchdbChangeEvents({
db: 'my_database',
autoConnect: false
});
changeEvents.emit = sinon.spy();
});
it('emits error', () => {
changeEvents.emitError('couch-error');
should.deepEqual(changeEvents.emit.firstCall.args, [
'couchdb_error', 'couch-error'
]);
});
});
describe('.reconnect()', () => {
let changeEvents;
beforeEach(() => {
changeEvents = new CouchdbChangeEvents({
db: 'my_database',
autoConnect: false
});
global.setTimeout.reset();
changeEvents.setCouchdbStatus = sinon.spy();
});
it('sets couchdb status to disconnected, if its not already', () => {
changeEvents.reconnect('');
should.equal(
changeEvents.setCouchdbStatus.firstCall.args[0],
'disconnected'
);
});
it('tries to reconnect in 1 second', () => {
changeEvents.reconnect('');
should.equal(
global.setTimeout.firstCall.args[0].name, 'bound connect'
);
should.equal(global.setTimeout.firstCall.args[1], 1000);
});
});
});
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