couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From benk...@apache.org
Subject fauxton commit: updated refs/heads/master to 574af6a
Date Mon, 01 Feb 2016 16:22:16 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master 9284dcd99 -> 574af6a8b


Fix for Beautify function within CodeEditorPanel component

Beautify wasn't working within the CodeEditorPanel component
because it didn't explicitly update the CodeEditor subcomponent.
This also reduces the size of the beautify button to make it more
appropriate.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/574af6a8
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/574af6a8
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/574af6a8

Branch: refs/heads/master
Commit: 574af6a8b490e6f132652f7071c1fe164c3410aa
Parents: 9284dcd
Author: Ben Keen <ben.keen@gmail.com>
Authored: Sun Jan 31 13:03:32 2016 -0800
Committer: Ben Keen <ben.keen@gmail.com>
Committed: Mon Feb 1 08:21:32 2016 -0800

----------------------------------------------------------------------
 .../components/react-components.react.jsx       |  3 ++-
 .../components/tests/beautifySpec.react.jsx     |  2 +-
 .../tests/codeEditorPanelSpec.react.jsx         | 21 ++++++++++++++++++++
 3 files changed, 24 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/574af6a8/app/addons/components/react-components.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/components/react-components.react.jsx b/app/addons/components/react-components.react.jsx
index 105bbae..a471637 100644
--- a/app/addons/components/react-components.react.jsx
+++ b/app/addons/components/react-components.react.jsx
@@ -351,6 +351,7 @@ function (app, FauxtonAPI, React, Stores, FauxtonComponents, ace, beautifyHelper
 
     beautify: function (code) {
       this.setState({ code: code });
+      this.getEditor().setValue(code);
     },
 
     update: function () {
@@ -963,7 +964,7 @@ function (app, FauxtonAPI, React, Stores, FauxtonComponents, ace, beautifyHelper
       return (
         <button
           onClick={this.beautify}
-          className="beautify beautify_map btn btn-primary beautify-tooltip"
+          className="beautify beautify_map btn btn-primary btn-small beautify-tooltip"
           type="button"
           data-toggle="tooltip"
           title="Reformat your minified code to make edits to it."

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/574af6a8/app/addons/components/tests/beautifySpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/components/tests/beautifySpec.react.jsx b/app/addons/components/tests/beautifySpec.react.jsx
index c7eefdf..92260cb 100644
--- a/app/addons/components/tests/beautifySpec.react.jsx
+++ b/app/addons/components/tests/beautifySpec.react.jsx
@@ -21,7 +21,7 @@ define([
   var TestUtils = React.addons.TestUtils;
 
   describe('Beautify', function () {
-    var container, beautifyEl, reduceStub;
+    var container, beautifyEl;
 
     beforeEach(function () {
       container = document.createElement('div');

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/574af6a8/app/addons/components/tests/codeEditorPanelSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/components/tests/codeEditorPanelSpec.react.jsx b/app/addons/components/tests/codeEditorPanelSpec.react.jsx
index b0bbcce..a2a1dcd 100644
--- a/app/addons/components/tests/codeEditorPanelSpec.react.jsx
+++ b/app/addons/components/tests/codeEditorPanelSpec.react.jsx
@@ -18,6 +18,7 @@ define([
 
   var assert = utils.assert;
   var TestUtils = React.addons.TestUtils;
+  var codeNoNewlines = 'function (doc) {emit(doc._id, 1);}';
   var code = 'function (doc) {\n  emit(doc._id, 1);\n}';
 
   describe('CodeEditorPanel', function () {
@@ -61,6 +62,26 @@ define([
       });
     });
 
+    describe('Beautify', function () {
+      it('confirm clicking beautify actually works within context of component', function
() {
+        var container = document.createElement('div');
+        var codeEditorEl = TestUtils.renderIntoDocument(
+          <ReactComponents.CodeEditorPanel
+            defaultCode={codeNoNewlines}
+          />,
+          container
+        );
+
+        // confirm there are no newlines in the code at this point
+        assert.equal(codeEditorEl.getValue().match(/\n/g), null);
+
+        TestUtils.Simulate.click($(React.findDOMNode(codeEditorEl)).find('.beautify')[0]);
+
+        // now confirm newlines are found
+        assert.equal(codeEditorEl.getValue().match(/\n/g).length, 2);
+      });
+    });
+
   });
 
 });


Mime
View raw message