import { NavbarLink } from '../';
import v from '../../config/variables';
describe('<NavbarLink />', () => {
  let wrapper, props;
  beforeEach(() => {
    props = {
      active: false,
      children: 'Hello',
      onPress: jest.fn()
    };
    wrapper = shallow(React.createElement(NavbarLink, props));
  });
  it('should render correctly', () => {
    expect(wrapper).toHaveLength(1);
    expect(wrapper).toMatchSnapshot();
  });
  it('should render the link label', () => {
    expect(wrapper.children().children().text()).toBe(props.children);
  });
  it('should render the UI correcly when not active', () => {
    expect(wrapper.children()).toHaveStyleRule('border-bottom', v.navbarLink.border);
  });
  it('should have a void function in the href when its undefined or null', () => {
    expect(wrapper.props().href).toBe('javascript:void(0);');
  });
  it('should call on press', () => {
    expect(props.onPress).not.toHaveBeenCalled();
    wrapper.simulate('click');
    expect(props.onPress).toHaveBeenCalledTimes(1);
  });
  describe('<NavbarLink active />', () => {
    beforeEach(() => {
      props = {
        children: 'Hello',
        active: true,
        to: '/teste',
        onPress: jest.fn()
      };
      wrapper = shallow(React.createElement(NavbarLink, props));
    });
    it('should render the UI correcly when not active', () => {
      expect(wrapper.children()).toHaveStyleRule('border-bottom', v.navbarLink.active.border);
    });
    it('should have a href', () => {
      expect(wrapper.props().href).toBe(props.to);
    });
    it('should have a undefined onPress value', () => {
      expect(wrapper.props().onClick).toBeUndefined();
    });
  });
});