Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
test(events): add active notifications spec
Browse files Browse the repository at this point in the history
  • Loading branch information
tlvince committed Dec 30, 2015
1 parent e34cd26 commit bfd09b8
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/event-emitters.js
Expand Up @@ -89,6 +89,45 @@ describe('Angular-wrapped PouchDB event emitters', function() {
.then(null, null, notify)
.catch(shouldNotBeCalled);
});

it('should notify on active events', function(done) {
var doc = {
_id: 'active'
};

var spies = {
notify: angular.noop
};

spyOn(spies, 'notify');

function replicate() {
return db.replicate.to('replicate-active').$promise;
}

function hasActiveNotification() {
function flatten(prev, current) {
return prev.concat(current);
}

function hasActive(args) {
return args.hasOwnProperty('active');
}

var spyArgs = spies.notify.calls.allArgs()
.reduce(flatten, []);

expect(spyArgs.some(hasActive)).toBe(true);
done();
}

replicate()
.then(db.put.bind(db, doc))
.then(replicate.bind(db))
.then(null, null, spies.notify)
.then(hasActiveNotification)
.catch(shouldNotBeCalled);
});
});

describe('sync', function() {
Expand Down

0 comments on commit bfd09b8

Please sign in to comment.