Github user millayr commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/826#discussion_r93670918
  
    --- Diff: app/addons/fauxton/navigation/__tests__/login-logout-test.js ---
    @@ -0,0 +1,80 @@
    +// 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 React from 'react';
    +import { mount } from 'enzyme';
    +
    +import NavBar from '../components/NavBar';
    +
    +describe('Navigation Bar', () => {
    +
    +  it('renders with login button when logged out', () => {
    +    const props = {
    +      activeLink: '',
    +      isMinimized: false,
    +      version: '42',
    +      navLinks: [],
    +      bottomNavLinks: [],
    +      footerNavLinks: [],
    +
    +      isLoginSectionVisible: true,
    +      isLoginVisibleInsteadOfLogout: true
    +    };
    +
    +    const navBar = mount(<NavBar {...props} />);
    +
    +    const button = navBar.find('[href="#/login"]');
    +    expect(button.text()).toContain('Login');
    +  });
    +
    +  it('renders with logout button when logged in', () => {
    +    const props = {
    +      activeLink: '',
    +      isMinimized: false,
    +      version: '42',
    +      navLinks: [],
    +      bottomNavLinks: [],
    +      footerNavLinks: [],
    +      username: 'Rocko',
    +
    +      isLoginSectionVisible: true,
    +      isLoginVisibleInsteadOfLogout: false
    +    };
    +
    +    const navBar = mount(<NavBar {...props} />);
    +
    +    const button = navBar.find('[href="#/logout"]');
    +    expect(button.text()).toContain('Log Out');
    +  });
    +
    +  it('Admin Party has no Logout button and no Login button', () => {
    +    const props = {
    +      activeLink: '',
    +      isMinimized: false,
    +      version: '42',
    +      navLinks: [],
    +      bottomNavLinks: [],
    +      footerNavLinks: [],
    +      username: 'Rocko',
    +
    +      isLoginSectionVisible: false,
    +      isLoginVisibleInsteadOfLogout: false
    +    };
    +
    +    const navBar = mount(<NavBar {...props} />);
    +
    +    expect(/Login/.test(navBar.text())).toBe(false);
    +    expect(/Log Out/.test(navBar.text())).toBe(false);
    --- End diff --
    
    Consider using Jest's `toMatch()` API for this.  It's a little cleaner for 
regex in my opinion.


---
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.
---

Reply via email to