import React from 'react';
import { shallow, mount } from 'enzyme';
import FooterSecondary from './footer-secondary';

describe('<FooterSecondary />', () => {
  const footer = shallow(<FooterSecondary />);

  it('should have the correct number of footer link lists', () => {
    const footerListCount = 2;
    expect(footer.find('FooterList')).toHaveLength(footerListCount);
  });

  it('should display the copyright section', () => {
    expect(
      footer
        .find('p')
        .last()
        .text(),
    ).toContain('Copyright © The Economist Newspaper');
  });

  it('should have default subscribe link', () => {
    const footerSecondary = mount(<FooterSecondary />);

    expect(
      footerSecondary
        .find('.ds-footer__link-list .ds-navigation-link')
        .first()
        .prop('href'),
    ).toBe('https://subscribenow.economist.com');
  });
  it('should override subscribe link', () => {
    const footerSecondary = mount(
      <FooterSecondary
        overrideUrls={{
          subscribeFooter: 'https://www.economist.com/api/auth/subscribe',
        }}
      />,
    );

    expect(
      footerSecondary
        .find('.ds-footer__link-list .ds-navigation-link')
        .first()
        .prop('href'),
    ).toBe('https://www.economist.com/api/auth/subscribe');
  });

  it('should display the cookie notice section', () => {
    const footerSecondary = mount(<FooterSecondary />);
    expect(footerSecondary.find('FooterCookieNotice')).toHaveLength(1);
  });
});
