[GitHub] garrensmith commented on a change in pull request #938: Refactor CORS tests to run with Jest and Enzyme

2017-08-01 Thread git
garrensmith commented on a change in pull request #938: Refactor CORS tests to 
run with Jest and Enzyme
URL: https://github.com/apache/couchdb-fauxton/pull/938#discussion_r130549071
 
 

 ##
 File path: app/addons/cors/components.js
 ##
 @@ -334,6 +334,7 @@ var CORSController = React.createClass({
 
 

[GitHub] garrensmith commented on a change in pull request #938: Refactor CORS tests to run with Jest and Enzyme

2017-07-31 Thread git
garrensmith commented on a change in pull request #938: Refactor CORS tests to 
run with Jest and Enzyme
URL: https://github.com/apache/couchdb-fauxton/pull/938#discussion_r130362139
 
 

 ##
 File path: app/addons/cors/__tests__/resources.test.js
 ##
 @@ -13,32 +13,32 @@ import testUtils from "../../../../test/mocha/testUtils";
 import CORS from "../resources";
 var assert = testUtils.assert;
 
-describe('Cors Config Model', function () {
+describe('Cors Config Model', () => {
   var cors;
 
 Review comment:
   `const`
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] garrensmith commented on a change in pull request #938: Refactor CORS tests to run with Jest and Enzyme

2017-07-31 Thread git
garrensmith commented on a change in pull request #938: Refactor CORS tests to 
run with Jest and Enzyme
URL: https://github.com/apache/couchdb-fauxton/pull/938#discussion_r130362652
 
 

 ##
 File path: app/addons/cors/components.js
 ##
 @@ -334,6 +334,7 @@ var CORSController = React.createClass({
 
 

[GitHub] garrensmith commented on a change in pull request #938: Refactor CORS tests to run with Jest and Enzyme

2017-07-31 Thread git
garrensmith commented on a change in pull request #938: Refactor CORS tests to 
run with Jest and Enzyme
URL: https://github.com/apache/couchdb-fauxton/pull/938#discussion_r130361585
 
 

 ##
 File path: app/addons/cors/__tests__/components.test.js
 ##
 @@ -0,0 +1,215 @@
+// 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 FauxtonAPI from "../../../core/api";
+import Views from "../components";
+import Actions from "../actions";
+import Resources from "../resources";
+import Stores from "../stores";
+import utils from "../../../../test/mocha/testUtils";
+import React from "react";
+import ReactDOM from "react-dom";
+import sinon from "sinon";
+import { shallow, mount } from 'enzyme';
+
+FauxtonAPI.router = new FauxtonAPI.Router([]);
+var assert = utils.assert;
+var corsStore = Stores.corsStore;
+
+describe('CORS Components', () => {
+
+  describe('CorsController', () => {
+
+beforeEach(() => {
+  corsStore._origins = ['http://hello.com'];
+  corsStore._node = 'node2@127.0.0.1';
+  corsStore._isEnabled = true;
+  corsStore._configChanged = true;
+});
+
+afterEach(() => {
+  utils.restore(window.confirm);
+});
+
+it('confirms user change from restricted origin to disabled cors', () => {
+  var spy = sinon.stub(window, 'confirm');
+  spy.returns(false);
+
+  const wrapper = shallow();
+  wrapper.find('#bt-enable-disable-cors').simulate('click');
+  assert.ok(spy.calledOnce);
+});
+
+it('does not confirm user change to disable cors when restricted origins 
are empty', () => {
+  let spy = sinon.stub(window, 'confirm');
 
 Review comment:
   `const`. Can you check everywhere to make sure `const` and `let` are used 
appropriately. Ideally we don't use `var`.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] garrensmith commented on a change in pull request #938: Refactor CORS tests to run with Jest and Enzyme

2017-07-31 Thread git
garrensmith commented on a change in pull request #938: Refactor CORS tests to 
run with Jest and Enzyme
URL: https://github.com/apache/couchdb-fauxton/pull/938#discussion_r130361381
 
 

 ##
 File path: app/addons/cors/__tests__/components.test.js
 ##
 @@ -0,0 +1,215 @@
+// 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 FauxtonAPI from "../../../core/api";
+import Views from "../components";
+import Actions from "../actions";
+import Resources from "../resources";
+import Stores from "../stores";
+import utils from "../../../../test/mocha/testUtils";
+import React from "react";
+import ReactDOM from "react-dom";
+import sinon from "sinon";
+import { shallow, mount } from 'enzyme';
+
+FauxtonAPI.router = new FauxtonAPI.Router([]);
+var assert = utils.assert;
+var corsStore = Stores.corsStore;
+
+describe('CORS Components', () => {
+
+  describe('CorsController', () => {
+
+beforeEach(() => {
+  corsStore._origins = ['http://hello.com'];
+  corsStore._node = 'node2@127.0.0.1';
+  corsStore._isEnabled = true;
+  corsStore._configChanged = true;
+});
+
+afterEach(() => {
+  utils.restore(window.confirm);
+});
+
+it('confirms user change from restricted origin to disabled cors', () => {
+  var spy = sinon.stub(window, 'confirm');
 
 Review comment:
   const
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] garrensmith commented on a change in pull request #938: Refactor CORS tests to run with Jest and Enzyme

2017-07-31 Thread git
garrensmith commented on a change in pull request #938: Refactor CORS tests to 
run with Jest and Enzyme
URL: https://github.com/apache/couchdb-fauxton/pull/938#discussion_r130361730
 
 

 ##
 File path: app/addons/cors/__tests__/components.test.js
 ##
 @@ -0,0 +1,215 @@
+// 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 FauxtonAPI from "../../../core/api";
+import Views from "../components";
+import Actions from "../actions";
+import Resources from "../resources";
+import Stores from "../stores";
+import utils from "../../../../test/mocha/testUtils";
+import React from "react";
+import ReactDOM from "react-dom";
+import sinon from "sinon";
+import { shallow, mount } from 'enzyme';
+
+FauxtonAPI.router = new FauxtonAPI.Router([]);
+var assert = utils.assert;
+var corsStore = Stores.corsStore;
+
+describe('CORS Components', () => {
+
+  describe('CorsController', () => {
+
+beforeEach(() => {
+  corsStore._origins = ['http://hello.com'];
+  corsStore._node = 'node2@127.0.0.1';
+  corsStore._isEnabled = true;
+  corsStore._configChanged = true;
+});
+
+afterEach(() => {
+  utils.restore(window.confirm);
+});
+
+it('confirms user change from restricted origin to disabled cors', () => {
+  var spy = sinon.stub(window, 'confirm');
+  spy.returns(false);
+
+  const wrapper = shallow();
+  wrapper.find('#bt-enable-disable-cors').simulate('click');
+  assert.ok(spy.calledOnce);
+});
+
+it('does not confirm user change to disable cors when restricted origins 
are empty', () => {
+  let spy = sinon.stub(window, 'confirm');
+  spy.returns(false);
+
+  // Set selected origins to empty
+  corsStore._origins = [];
+
+  const wrapper = shallow();
+  wrapper.find('#bt-enable-disable-cors').simulate('click');
+  assert.ok(spy.notCalled);
+});
+
+it('confirms user change when moving from selected origins to all 
origins', () => {
+  const spy = sinon.stub(window, 'confirm');
+  spy.returns(false);
+
+  const wrapper = mount();
+  wrapper.find('input').at(0).simulate('change', {target: {checked: true, 
value: 'all'}});
+  assert.ok(spy.calledOnce);
+});
+
+it('does not confirm all origins change if selected origins are emtpy', () 
=> {
+  var spy = sinon.stub(window, 'confirm');
+  // sinon.stub(Actions, 'toggleLoadingBarsToEnabled');
 
 Review comment:
   Delete if you don't need it.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] garrensmith commented on a change in pull request #938: Refactor CORS tests to run with Jest and Enzyme

2017-07-31 Thread git
garrensmith commented on a change in pull request #938: Refactor CORS tests to 
run with Jest and Enzyme
URL: https://github.com/apache/couchdb-fauxton/pull/938#discussion_r130361313
 
 

 ##
 File path: app/addons/cors/__tests__/components.test.js
 ##
 @@ -0,0 +1,215 @@
+// 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 FauxtonAPI from "../../../core/api";
+import Views from "../components";
+import Actions from "../actions";
+import Resources from "../resources";
+import Stores from "../stores";
+import utils from "../../../../test/mocha/testUtils";
+import React from "react";
+import ReactDOM from "react-dom";
+import sinon from "sinon";
+import { shallow, mount } from 'enzyme';
+
+FauxtonAPI.router = new FauxtonAPI.Router([]);
+var assert = utils.assert;
 
 Review comment:
   minor but could you make these `const`. Also you can do something like this:
   
   ```js
   const {assert, restore} = utils;
   ```
   
   Then you don't have to do `utils.restore` in the afterEach
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] garrensmith commented on a change in pull request #938: Refactor CORS tests to run with Jest and Enzyme

2017-07-31 Thread git
garrensmith commented on a change in pull request #938: Refactor CORS tests to 
run with Jest and Enzyme
URL: https://github.com/apache/couchdb-fauxton/pull/938#discussion_r130362276
 
 

 ##
 File path: app/addons/cors/__tests__/stores.test.js
 ##
 @@ -14,30 +14,30 @@ import Stores from "../stores";
 var assert = testUtils.assert;
 
 Review comment:
   const
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services