couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From benkeen <...@git.apache.org>
Subject [GitHub] couchdb-fauxton pull request: Update full page document editor
Date Thu, 25 Dec 2014 02:56:05 GMT
Github user benkeen commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/204#discussion_r22266516
  
    --- Diff: app/addons/documents/views-doceditor.js ---
    @@ -207,184 +205,95 @@ function (app, FauxtonAPI, Components, Documents, Databases, prettify)
{
           'click button.delete': 'destroy',
           'click button.duplicate': 'duplicate',
           'click button.upload': 'upload',
    -      'click button.js-back': 'goback',
    -      'click button.string-edit': 'stringEditing'
    +      'click a.js-back': 'onClickGoBack'
         },
     
         disableLoader: true,
     
         initialize: function (options) {
           this.database = options.database;
    -      _.bindAll(this);
    -    },
     
    -    goback: function () {
    -      var lastPages = FauxtonAPI.router.lastPages;
    +      // to allow dependency injection
    +      this.components = _.extend({
    --- End diff --
    
    Yeah I added this because @robertkowalski mentioned how our code isn't very testable.

    
    The idea here is to allow this View to be tested in isolation (not that, I confess, the
text exists). It uses `extend` to lays down the default components, but if someone wanted
to test this View, they could pass it test components that just stubbed out the functionality
of `Components.ConfirmationModal`, `Views.UploadModal` and `Views.DuplicateDocModal`. This
would be done like so: 
    
    `var whatever = Views.CodeEditor({ confirmModal: TestConfirmModal, uploadModal: TestUploadModal
... });` 
    
    Basically this just provides more control to the person testing it and not have to worry
about those extra components doing extra things that made testing hard.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message