import React from 'react';
import { shallow } from 'enzyme';
import IdentNewsletters from './ident-newsletters';

describe('<IdentNewsletters />', () => {
  it('should render the correct default props', () => {
    const component = shallow(<IdentNewsletters ident='cover-story' />);
    expect(component.props().className).toEqual(
      'ds-ident-newsletters ds-ident-newsletters--cover-story',
    );
  });

  it('should render the inline SVG component', () => {
    const component = shallow(<IdentNewsletters ident='cover-story' />);
    expect(component.find('.ds-ident-newsletters__svg').exists()).toBe(true);
  });

  it('should render the Economist monogram if the ident is invalid', () => {
    const component = shallow(<IdentNewsletters ident='invalid-ident' />);
    expect(component.find('.ds-ident-newsletters--fallback').exists()).toBe(
      true,
    );
  });

  it('should render the className prop if passed in', () => {
    const component = shallow(
      <IdentNewsletters ident='cover-story' className='test-classname' />,
    );
    expect(component.props().className).toContain('test-classname');
  });
});
