content: /* eslint-env mocha */
  
  import React from 'react';
  import { expect } from 'chai';
  import { shallow } from 'enzyme';
  import sinon from 'sinon';
  import { ComicDetails } from '../../../src/js/components/comicDetails/index';
  
  describe('<ComicDetails />', () => {
    it('should render if no details', () => {
      const wrapper = shallow(
        <ComicDetails
          comicDetails={false}
          clearComicDetails={() => []}
          getComicDetails={() => []}
          params={{
            comicId: 0
          }}
        />
      );
      expect(wrapper.find('h1').length).to.equal(1);
    });
  
    it('should render if details present', (done) => {
      const wrapper = shallow(
        <ComicDetails
          comicDetails={{ title: 'foobar' }}
          clearComicDetails={() => []}
          getComicDetails={() => []}
          params={{
            comicId: 0
          }}
        />
      );
      expect(wrapper.find('.character-portrait').length).to.equal(1);
      done();
    });
  
    it('should render if details & description present', (done) => {
      const wrapper = shallow(
        <ComicDetails
          comicDetails={{ title: 'foobar', description: 'the great journey of foobar' }}
          clearComicDetails={() => []}
          getComicDetails={() => []}
          params={{
            comicId: 0
          }}
        />
      );
      expect(wrapper.find('p').length).to.equal(1);
      done();
    });
  
    describe('componentWillMount', () => {
      it('should call clearComicDetails & getComicDetails', (done) => {
        const clearComicDetails = sinon.spy();
        const getComicDetails = sinon.spy();
        const wrapper = shallow(
          <ComicDetails
            comicDetails={{ title: 'foobar', description: 'the great journey of foobar' }}
            clearComicDetails={clearComicDetails}
            getComicDetails={getComicDetails}
            params={{
              comicId: 0
            }}
          />
        );
        const instance = wrapper.instance();
        instance.componentWillMount();
        expect(clearComicDetails.called).to.equal(true);
        expect(getComicDetails.called).to.equal(true);
        done();
      });
    });
  });
  