import * as React from 'react';
import {ProfileButton} from '../index';
import {render} from '../../test-utils';



describe('ProfileButton', () => {

  it('should render', () => {
    const wrapper = render(<ProfileButton onClick={jest.fn()} initials={'initials'}/>);

    expect(wrapper.queryByText('initials')).toBeInTheDocument();
  });

  it('should render image if portraitSrc is provided', () => {
    const wrapper = render(<ProfileButton portraitSrc={'#'} onClick={jest.fn()}/>);


    expect(wrapper.container.querySelector(`img`)).toBeInTheDocument();
    expect(wrapper.queryByText('initials')).not.toBeInTheDocument();
  });

  it('should render initials if portraitSrc is not provided and initials are', () => {
    const wrapper = render(<ProfileButton initials={'initials'} onClick={jest.fn()}/>);


    expect(wrapper.container.querySelector(`img`)).not.toBeInTheDocument();
    expect(wrapper.queryByText('initials')).toBeInTheDocument();
  });

});
