You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2016/10/25 11:29:52 UTC
[1/2] fauxton commit: updated refs/heads/master to 7166e4c
Repository: couchdb-fauxton
Updated Branches:
refs/heads/master 13a26d986 -> 7166e4cd1
Refactor permissions and setup tests
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/d412dedc
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/d412dedc
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/d412dedc
Branch: refs/heads/master
Commit: d412dedcf880a0aefa6dd83a264866645881c964
Parents: 13a26d9
Author: Garren Smith <ga...@gmail.com>
Authored: Mon Oct 24 15:10:59 2016 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Oct 25 13:29:01 2016 +0200
----------------------------------------------------------------------
app/addons/databases/tests/resourcesSpec.js | 3 +-
app/addons/permissions/components.react.jsx | 4 +-
.../permissions/tests/componentsSpec.react.jsx | 122 +++++-------
app/addons/replication/tests/replicationSpec.js | 38 ----
.../setup/tests/setupComponentsSpec.react.jsx | 196 ++++++-------------
app/addons/setup/tests/setupSpec.js | 1 -
test/mocha/testUtils.js | 28 ---
7 files changed, 111 insertions(+), 281 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d412dedc/app/addons/databases/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/databases/tests/resourcesSpec.js b/app/addons/databases/tests/resourcesSpec.js
index a434308..0005fbc 100644
--- a/app/addons/databases/tests/resourcesSpec.js
+++ b/app/addons/databases/tests/resourcesSpec.js
@@ -12,8 +12,7 @@
import FauxtonAPI from "../../../core/api";
import Resources from "../resources";
import testUtils from "../../../../test/mocha/testUtils";
-var assert = testUtils.assert,
- ViewSandbox = testUtils.ViewSandbox;
+var assert = testUtils.assert;
describe("Databases: List", function () {
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d412dedc/app/addons/permissions/components.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/permissions/components.react.jsx b/app/addons/permissions/components.react.jsx
index cfd8f0f..4b5d307 100644
--- a/app/addons/permissions/components.react.jsx
+++ b/app/addons/permissions/components.react.jsx
@@ -137,7 +137,7 @@ var PermissionsSection = React.createClass({
<h4>Users</h4>
<p>Specify users who will have {this.props.section} access to this database.</p>
</header>
- <form onSubmit={this.addNames} className="permission-item-form form-inline">
+ <form onSubmit={this.addNames} className="permission-item-form permissions-add-user form-inline">
<input onChange={this.nameChange} value={this.state.newName} type="text" className="item input-small" placeholder="Add User" />
<button type="submit" className="btn btn-success"><i className="icon fonticon-plus-circled" /> Add User</button>
</form>
@@ -150,7 +150,7 @@ var PermissionsSection = React.createClass({
<h4>Roles</h4>
<p>Users with any of the following role(s) will have {this.props.section} access.</p>
</header>
- <form onSubmit={this.addRoles} className="permission-item-form form-inline">
+ <form onSubmit={this.addRoles} className="permission-item-form permissions-add-role form-inline">
<input onChange={this.roleChange} value={this.state.newRole} type="text" className="item input-small" placeholder="Add Role" />
<button type="submit" className="btn btn-success"><i className="icon fonticon-plus-circled" /> Add Role</button>
</form>
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d412dedc/app/addons/permissions/tests/componentsSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/permissions/tests/componentsSpec.react.jsx b/app/addons/permissions/tests/componentsSpec.react.jsx
index ffc1c81..1b90088 100644
--- a/app/addons/permissions/tests/componentsSpec.react.jsx
+++ b/app/addons/permissions/tests/componentsSpec.react.jsx
@@ -17,52 +17,40 @@ import Actions from "../actions";
import utils from "../../../../test/mocha/testUtils";
import React from "react";
import ReactDOM from "react-dom";
-import TestUtils from "react-addons-test-utils";
import sinon from "sinon";
+import { mount } from 'enzyme';
var assert = utils.assert;
var restore = utils.restore;
-describe('Permissions Components', function () {
+FauxtonAPI.router = new FauxtonAPI.Router([]);
- beforeEach((done) => {
- var databaseName = 'permissions-test';
- var database = new Databases.Model({ id: databaseName });
- Actions.editPermissions(
- database,
- new Permissions.Security(null, {
- database: database
- })
- );
+describe('Permissions Components', () => {
+ beforeEach(() => {
var savePermissionsStub = sinon.stub(Actions, 'savePermissions');
- done();
});
- afterEach(function () {
+ afterEach(() => {
restore(Actions.savePermissions);
});
- describe('Permissions Controller', function () {
- var el, container;
-
- beforeEach(function () {
- container = document.createElement('div');
- el = TestUtils.renderIntoDocument(<Views.PermissionsController />, container);
- });
-
- afterEach(function () {
- ReactDOM.unmountComponentAtNode(container);
+ describe('Permissions Controller', () => {
+ afterEach(() => {
+ restore(Actions.addItem);
+ restore(Actions.removeItem);
});
- it('on Add triggers add action', function () {
+ it('on Add triggers add action', () => {
var spy = sinon.spy(Actions, 'addItem');
- el.addItem({});
+ const el = mount(<Views.PermissionsController />);
+ el.instance().addItem({});
assert.ok(spy.calledOnce);
});
- it('on Remove triggers remove action', function () {
+ it('on Remove triggers remove action', () => {
var spy = sinon.spy(Actions, 'removeItem');
- el.removeItem({
+ const el = mount(<Views.PermissionsController />);
+ el.instance().removeItem({
value: 'boom',
type: 'names',
section: 'members'
@@ -72,28 +60,18 @@ describe('Permissions Components', function () {
});
- describe('PermissionsSection', function () {
- var el, container, addSpy;
-
- beforeEach(function () {
- addSpy = sinon.spy();
- container = document.createElement('div');
- el = TestUtils.renderIntoDocument(<Views.PermissionsSection section={'members'} roles={[]} names={[]} addItem={addSpy} />, container);
- });
-
- afterEach(function () {
- ReactDOM.unmountComponentAtNode(container);
- });
+ describe('PermissionsSection', () => {
- it('adds user on submit', function () {
- var input = $(ReactDOM.findDOMNode(el)).find('input')[0];
- TestUtils.Simulate.change(input, {
+ it('adds user on submit', () => {
+ const addSpy = sinon.spy();
+ const el = mount(<Views.PermissionsSection section={'members'} roles={[]} names={[]} addItem={addSpy} />);
+ el.find('.permissions-add-user input').simulate('change', {
target: {
value: 'newusername'
}
});
- var form = $(ReactDOM.findDOMNode(el)).find('.permission-item-form')[0];
- TestUtils.Simulate.submit(form);
+
+ el.find('.permissions-add-user').simulate('submit');
var options = addSpy.args[0][0];
assert.ok(addSpy.calledOnce);
@@ -101,15 +79,17 @@ describe('Permissions Components', function () {
assert.equal(options.section, "members");
});
- it('adds role on submit', function () {
- var input = $(ReactDOM.findDOMNode(el)).find('input')[1];
- TestUtils.Simulate.change(input, {
+ it('adds role on submit', () => {
+ const addSpy = sinon.spy();
+ const el = mount(<Views.PermissionsSection section={'members'} roles={[]} names={[]} addItem={addSpy} />);
+
+ el.find('.permissions-add-role input').simulate('change', {
target: {
value: 'newrole'
}
});
- var form = $(ReactDOM.findDOMNode(el)).find('.permission-item-form')[1];
- TestUtils.Simulate.submit(form);
+
+ el.find('.permissions-add-role').simulate('submit');
var options = addSpy.args[0][0];
assert.ok(addSpy.calledOnce);
@@ -117,53 +97,39 @@ describe('Permissions Components', function () {
assert.equal(options.section, "members");
});
- it('stores new name on change', function () {
+ it('stores new name on change', () => {
+ const addSpy = sinon.spy();
var newName = 'newName';
- var dom = $(ReactDOM.findDOMNode(el)).find('.item')[0];
-
- TestUtils.Simulate.change(dom, {
+ const el = mount(<Views.PermissionsSection section={'members'} roles={[]} names={[]} addItem={addSpy} />);
+ el.find('.permissions-add-user .item').simulate('change', {
target: {
value: newName
}
});
- assert.equal(el.state.newName, newName);
+ assert.equal(el.state().newName, newName);
});
- it('stores new role on change', function () {
+ it('stores new role on change', () => {
var newRole = 'newRole';
- var dom = $(ReactDOM.findDOMNode(el)).find('.item')[1];
-
- TestUtils.Simulate.change(dom, {
+ const addSpy = sinon.spy();
+ const el = mount(<Views.PermissionsSection section={'members'} roles={[]} names={[]} addItem={addSpy} />);
+ el.find('.permissions-add-role .item').simulate('change', {
target: {
value: newRole
}
});
-
- assert.equal(el.state.newRole, newRole);
+ assert.equal(el.state().newRole, newRole);
});
});
- describe('PermissionsItem', function () {
- var el, container, removeSpy;
-
- beforeEach(function () {
- removeSpy = sinon.spy();
- container = document.createElement('div');
- el = TestUtils.renderIntoDocument(<Views.PermissionsItem section={'members'} item={'test-item'} removeItem={removeSpy} />, container);
- });
-
- afterEach(function () {
- ReactDOM.unmountComponentAtNode(container);
- });
-
- it('triggers remove on click', function () {
- var dom = $(ReactDOM.findDOMNode(el)).find('.close')[0];
- TestUtils.Simulate.click(dom);
+ describe('PermissionsItem', () => {
+ it('triggers remove on click', () => {
+ const removeSpy = sinon.spy();
+ const el = mount(<Views.PermissionsItem section={'members'} item={'test-item'} removeItem={removeSpy} />);
+ el.find('.close').simulate('click');
assert.ok(removeSpy.calledOnce);
-
});
-
});
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d412dedc/app/addons/replication/tests/replicationSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/replication/tests/replicationSpec.js b/app/addons/replication/tests/replicationSpec.js
deleted file mode 100644
index bae87c1..0000000
--- a/app/addons/replication/tests/replicationSpec.js
+++ /dev/null
@@ -1,38 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-import Replication from "../base";
-import Views from "../views";
-import Resources from "../resources";
-import testUtils from "../../../../test/mocha/testUtils";
-var assert = testUtils.assert,
- ViewSandbox = testUtils.ViewSandbox,
- viewSandbox;
-
-describe('Replication Addon', function () {
- describe('Replication View', function () {
- var view = new Views.ReplicationForm({
- collection: new Replication.DBList()
- });
- beforeEach(function (done) {
- viewSandbox = new ViewSandbox();
- viewSandbox.renderView(view, done);
- });
-
- afterEach(function () {
- viewSandbox.remove();
- });
-
- it("should render", function () {
- assert.ok(view.$el.length > 0);
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d412dedc/app/addons/setup/tests/setupComponentsSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/setup/tests/setupComponentsSpec.react.jsx b/app/addons/setup/tests/setupComponentsSpec.react.jsx
index d0872bf..6808811 100644
--- a/app/addons/setup/tests/setupComponentsSpec.react.jsx
+++ b/app/addons/setup/tests/setupComponentsSpec.react.jsx
@@ -9,135 +9,67 @@
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
-import FauxtonAPI from "../../../core/api";
-import Views from "../setup.react";
-import Stores from "../setup.stores";
-import utils from "../../../../test/mocha/testUtils";
-import React from "react";
-import ReactDOM from "react-dom";
-import TestUtils from "react-addons-test-utils";
-import sinon from "sinon";
-
-var assert = utils.assert;
-
-describe('Setup Components', function () {
-
- describe('IP / Port area', function () {
- var changeHandler, container;
-
- beforeEach(function () {
- changeHandler = sinon.spy();
- container = document.createElement('div');
- });
-
- afterEach(function () {
- ReactDOM.unmountComponentAtNode(container);
- });
-
- it('fires callbacks on change, ip', function () {
- var optSettings = TestUtils.renderIntoDocument(
- <Views.SetupOptionalSettings onAlterPort={null} onAlterBindAddress={changeHandler} />,
- container
- );
-
- var node = $(ReactDOM.findDOMNode(optSettings)).find('.setup-input-ip')[0];
- TestUtils.Simulate.change(node, {target: {value: 'Hello, world'}});
-
- assert.ok(changeHandler.calledOnce);
- });
-
- it('fires callbacks on change, port', function () {
- var optSettings = TestUtils.renderIntoDocument(
- <Views.SetupOptionalSettings onAlterPort={changeHandler} onAlterBindAddress={null} />,
- container
- );
-
- var node = $(ReactDOM.findDOMNode(optSettings)).find('.setup-input-port')[0];
- TestUtils.Simulate.change(node, {target: {value: 'Hello, world'}});
-
- assert.ok(changeHandler.calledOnce);
- });
-
- });
-
- //commenting out for now. These tests cause other tests to fail. No idea why
- /*describe('SetupMultipleNodesController', function () {
- var controller, changeHandler, container;
-
- beforeEach(function () {
- sinon.stub(Stores.setupStore, 'getIsAdminParty', function () { return false; });
- container = document.createElement('div');
- controller = TestUtils.renderIntoDocument(
- <Views.SetupMultipleNodesController />,
- container
- );
- });
-
- afterEach(function () {
- utils.restore(Stores.setupStore.getIsAdminParty);
- ReactDOM.unmountComponentAtNode(container);
- Stores.setupStore.reset();
- });
-
- it('changes the values in the store for additional nodes', function () {
- var $addNodesSection = $(ReactDOM.findDOMNode(controller)).find('.setup-add-nodes-section');
- TestUtils.Simulate.change($addNodesSection.find('.setup-input-ip')[0], {target: {value: '192.168.13.37'}});
- TestUtils.Simulate.change($addNodesSection.find('.setup-input-port')[0], {target: {value: '1337'}});
- TestUtils.Simulate.change($addNodesSection.find('.input-remote-node')[0], {target: {value: 'node2.local'}});
-
- var additionalNode = Stores.setupStore.getAdditionalNode();
- assert.equal(additionalNode.bindAddress, '192.168.13.37');
- assert.equal(additionalNode.remoteAddress, 'node2.local');
- assert.equal(additionalNode.port, '1337');
- });
-
- it('changes the values in the store for the setup node', function () {
- var $setupNodesSection = $(ReactDOM.findDOMNode(controller)).find('.setup-setupnode-section');
- TestUtils.Simulate.change($setupNodesSection.find('.setup-input-ip')[0], {target: {value: '192.168.42.42'}});
- TestUtils.Simulate.change($setupNodesSection.find('.setup-input-port')[0], {target: {value: '4242'}});
- TestUtils.Simulate.change($setupNodesSection.find('.setup-username')[0], {target: {value: 'tester'}});
- TestUtils.Simulate.change($setupNodesSection.find('.setup-password')[0], {target: {value: 'testerpass'}});
-
-
- assert.equal(Stores.setupStore.getBindAdressForSetupNode(), '192.168.42.42');
- assert.equal(Stores.setupStore.getPortForSetupNode(), '4242');
- assert.equal(Stores.setupStore.getUsername(), 'tester');
- assert.equal(Stores.setupStore.getPassword(), 'testerpass');
- });
-
- });*/
-
- describe('SingleNodeSetup', function () {
- var controller, changeHandler, container;
-
- beforeEach(function () {
- sinon.stub(Stores.setupStore, 'getIsAdminParty', function () { return false; });
- container = document.createElement('div');
- controller = TestUtils.renderIntoDocument(
- <Views.SetupSingleNodeController />,
- container
- );
- });
-
- afterEach(function () {
- utils.restore(Stores.setupStore.getIsAdminParty);
- ReactDOM.unmountComponentAtNode(container);
- Stores.setupStore.reset();
- });
-
- it('changes the values in the store for the setup node', function () {
- var $setupNodesSection = $(ReactDOM.findDOMNode(controller)).find('.setup-setupnode-section');
- TestUtils.Simulate.change($setupNodesSection.find('.setup-input-ip')[0], {target: {value: '192.168.13.42'}});
- TestUtils.Simulate.change($setupNodesSection.find('.setup-input-port')[0], {target: {value: '1342'}});
- TestUtils.Simulate.change($setupNodesSection.find('.setup-username')[0], {target: {value: 'tester'}});
- TestUtils.Simulate.change($setupNodesSection.find('.setup-password')[0], {target: {value: 'testerpass'}});
-
- assert.equal(Stores.setupStore.getBindAdressForSetupNode(), '192.168.13.42');
- assert.equal(Stores.setupStore.getPortForSetupNode(), '1342');
- assert.equal(Stores.setupStore.getUsername(), 'tester');
- assert.equal(Stores.setupStore.getPassword(), 'testerpass');
- });
-
- });
-
-});
+// import FauxtonAPI from "../../../core/api";
+// import Views from "../setup.react";
+// import Stores from "../setup.stores";
+// import utils from "../../../../test/mocha/testUtils";
+// import React from "react";
+// import ReactDOM from "react-dom";
+// import sinon from "sinon";
+// import { mount } from 'enzyme';
+//
+// var assert = utils.assert;
+//
+// describe('Setup Components', () => {
+//
+// describe('IP / Port area', () => {
+//
+// it('fires callbacks on change, ip', () => {
+// const changeHandler = sinon.spy();
+// const optSettings = mount(<Views.SetupOptionalSettings onAlterPort={null} onAlterBindAddress={changeHandler} />);
+//
+// optSettings.find('.setup-input-ip').simulate('change', {target: {value: 'Hello, world'}});
+// assert.ok(changeHandler.calledOnce);
+// });
+//
+// it('fires callbacks on change, port', () => {
+// const changeHandler = sinon.spy();
+// var optSettings = mount(
+// <Views.SetupOptionalSettings onAlterPort={changeHandler} onAlterBindAddress={null} />
+// );
+//
+// optSettings.find('.setup-input-port').simulate('change', {target: {value: 'Hello, world'}});
+// assert.ok(changeHandler.calledOnce);
+// });
+//
+// });
+//
+// describe('SingleNodeSetup', () => {
+// beforeEach(() => {
+// sinon.stub(Stores.setupStore, 'getIsAdminParty', () => { return false; });
+// });
+//
+// afterEach(() => {
+// utils.restore(Stores.setupStore.getIsAdminParty);
+// Stores.setupStore.reset();
+// });
+//
+// it('changes the values in the store for the setup node', () => {
+// const controller = mount(
+// <Views.SetupSingleNodeController />
+// );
+//
+// controller.find('.setup-setupnode-section .setup-input-ip').simulate('change', {target: {value: '192.168.13.42'}});
+// controller.find('.setup-setupnode-section .setup-input-port').simulate('change', {target: {value: '1342'}});
+// controller.find('.setup-setupnode-section .setup-username').simulate('change', {target: {value: 'tester'}});
+// controller.find('.setup-setupnode-section .setup-password').simulate('change', {target: {value: 'testerpass'}});
+//
+// assert.equal(Stores.setupStore.getBindAdressForSetupNode(), '192.168.13.42');
+// assert.equal(Stores.setupStore.getPortForSetupNode(), '1342');
+// assert.equal(Stores.setupStore.getUsername(), 'tester');
+// assert.equal(Stores.setupStore.getPassword(), 'testerpass');
+// });
+//
+// });
+//
+// });
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d412dedc/app/addons/setup/tests/setupSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/setup/tests/setupSpec.js b/app/addons/setup/tests/setupSpec.js
index 78267ba..522e67d 100644
--- a/app/addons/setup/tests/setupSpec.js
+++ b/app/addons/setup/tests/setupSpec.js
@@ -13,7 +13,6 @@ import FauxtonAPI from "../../../core/api";
import Resources from "../resources";
import testUtils from "../../../../test/mocha/testUtils";
var assert = testUtils.assert,
- ViewSandbox = testUtils.ViewSandbox,
model;
describe('Setup: verify input', function () {
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d412dedc/test/mocha/testUtils.js
----------------------------------------------------------------------
diff --git a/test/mocha/testUtils.js b/test/mocha/testUtils.js
index fa0fd0f..92ccc72 100644
--- a/test/mocha/testUtils.js
+++ b/test/mocha/testUtils.js
@@ -12,33 +12,6 @@
import chai from "chai";
-var ViewSandbox = function () {
- this.initialize();
-};
-
-_.extend(ViewSandbox.prototype, {
- initialize: function () {
- this.$el = $('<div style="display:none"></div>').appendTo('body');
- this.$ = this.$el.find;
- },
- views: [],
- renderView: function (view, done) {
- this.views.push(view);
- this.$el.append(view.el);
- view.render();
- if (done) {
- view.promise().done(function () { done(); });
- }
- return view;
- },
-
- remove: function () {
- _.each(this.views, function (view) {
- view.remove();
- }, this);
- }
-});
-
var restore = function (fn) {
if (fn.restore) {
fn.restore();
@@ -48,6 +21,5 @@ var restore = function (fn) {
export default {
chai: chai,
assert: chai.assert,
- ViewSandbox: ViewSandbox,
restore: restore
};
[2/2] fauxton commit: updated refs/heads/master to 7166e4c
Posted by ga...@apache.org.
update mocha
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/7166e4cd
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/7166e4cd
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/7166e4cd
Branch: refs/heads/master
Commit: 7166e4cd1e3a98c70d295e101592ac994687597d
Parents: d412ded
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Oct 25 11:32:26 2016 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Oct 25 13:29:07 2016 +0200
----------------------------------------------------------------------
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/7166e4cd/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 94e5800..6d0cc2f 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,7 @@
"devDependencies": {
"enzyme": "^2.4.1",
"es5-shim": "4.5.4",
- "mocha": "^2.4.5",
+ "mocha": "~3.1.2",
"mocha-loader": "^1.0.0",
"mocha-phantomjs": "git+https://github.com/garrensmith/mocha-phantomjs.git",
"nightwatch": "~0.9.0",