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 = '[email protected]'; + 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(<Views.CORSController />); + 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: [email protected] With regards, Apache Git Services
