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 [email protected] or file a JIRA ticket
with INFRA.
---