You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ro...@apache.org on 2014/08/01 20:14:55 UTC
fauxton commit: updated refs/heads/master to 4382f43
Repository: couchdb-fauxton
Updated Branches:
refs/heads/master b58f613b1 -> 4382f43ef
Add tests for documents/views-changes
Closes COUCHDB-2282
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/4382f43e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/4382f43e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/4382f43e
Branch: refs/heads/master
Commit: 4382f43efbf6ed435a3881a3b5323509fb77dc40
Parents: b58f613
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Tue Jul 29 20:04:46 2014 +0200
Committer: Robert Kowalski <ro...@kowalski.gd>
Committed: Fri Aug 1 18:17:28 2014 +0200
----------------------------------------------------------------------
app/addons/documents/tests/views-changesSpec.js | 43 +++++++++++++++++++-
1 file changed, 41 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/4382f43e/app/addons/documents/tests/views-changesSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/views-changesSpec.js b/app/addons/documents/tests/views-changesSpec.js
index 4d4b2b3..94ca585 100644
--- a/app/addons/documents/tests/views-changesSpec.js
+++ b/app/addons/documents/tests/views-changesSpec.js
@@ -14,16 +14,36 @@ define([
'addons/databases/base',
'testUtils'
], function (Views, Databases, testUtils) {
- var assert = testUtils.assert;
+ var assert = testUtils.assert,
+ ViewSandbox = testUtils.ViewSandbox,
+ viewSandbox;
describe('Documents Changes', function () {
- var filteredView;
+ var model = new Databases.Model({id: 'foo'}),
+ filteredView,
+ view,
+ handlerSpy;
+
+ model.buildChanges();
+
+ handlerSpy = sinon.spy(Views.Changes.prototype, 'toggleJson');
+
beforeEach(function () {
var database = new Databases.Model({id: 'bla'});
database.buildChanges({descending: 'true', limit: '100', include_docs: 'true'} );
filteredView = new Views.Changes({
model: database
});
+
+ view = new Views.Changes({
+ model: model
+ });
+ viewSandbox = new ViewSandbox();
+ viewSandbox.renderView(view);
+ });
+
+ afterEach(function () {
+ viewSandbox.remove();
});
it('filter false in case of deleted documents in the changes feed', function () {
@@ -36,5 +56,24 @@ define([
assert.equal(res.length, 2);
});
+
+ it('the toggle-json button calls a handler', function () {
+ view.$('.js-toggle-json').trigger('click');
+ assert.ok(handlerSpy.calledOnce);
+ });
+
+ it('rerenders on the sync event', function () {
+ var spy = sinon.spy(view, 'afterRender');
+ model.changes.trigger('sync');
+ view.afterRender.restore();
+ assert.ok(spy.calledOnce);
+ });
+
+ it('rerenders on the cachesync event', function () {
+ var spy = sinon.spy(view, 'afterRender');
+ model.changes.trigger('cachesync');
+ assert.ok(spy.calledOnce);
+ view.afterRender.restore();
+ });
});
});