import React from 'react';
import { shallow, mount } from 'enzyme'
import toJson from 'enzyme-to-json';
import AuthButtons from '../../AuthButtons/AuthButtons';
import SignUpLink from '../../SignUpLink/SignUpLink';
import SignInLink from '../../SignInLink/SignInLink';
import SignOutButton from '../../SignOutButton/SignOutButton';

describe('<AuthButtons />', () => {
  let sIL = <SignInLink />,
      sUL = <SignUpLink />,
      sOB = <SignOutButton />;

  it('should render sign in and sign up buttons when logged out', () => {
    let isLoggedIn = false;
    let wrapper = shallow(<AuthButtons isLoggedIn={isLoggedIn}/>);

    expect(wrapper.containsMatchingElement(sIL)).toBe(true);
    expect(wrapper.containsMatchingElement(sUL)).toBe(true);
    expect(wrapper.containsMatchingElement(sOB)).not.toBe(true);
    expect(toJson(wrapper)).toMatchSnapshot();
  });
  
  it('should render sign out button when logged in', () => {
    let isLoggedIn = true;
    let wrapper = shallow(<AuthButtons isLoggedIn={isLoggedIn} />);

    expect(wrapper.containsMatchingElement(sOB)).toBe(true);
    expect(wrapper.containsMatchingElement(sIL)).not.toBe(true);
    expect(wrapper.containsMatchingElement(sUL)).not.toBe(true);
    expect(toJson(wrapper)).toMatchSnapshot();
  });
});