couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From deathb...@apache.org
Subject [5/9] fauxton commit: updated refs/heads/secondary-indexes to bcc6dc2
Date Mon, 04 Aug 2014 13:10:45 GMT
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/secondary-indexes
Commit: 4382f43efbf6ed435a3881a3b5323509fb77dc40
Parents: b58f613
Author: Robert Kowalski <rok@kowalski.gd>
Authored: Tue Jul 29 20:04:46 2014 +0200
Committer: Robert Kowalski <rok@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();
+    });
   });
 });


Mime
View raw message