/* eslint-env mocha, jest */

import getDefault from '../../shared/testUtils';
import Idea from '../Idea';

const defaultProps = {
  index: 0,
  onRequestEditDialogOpen() {},
  onRequestConvertDialogOpen() {},
  onRequestDelete() {},
};
const getActualIdea = getDefault(Idea, defaultProps);

jest.useFakeTimers();

it('should render', () => {
  getActualIdea();
});
it('should be a <div />', () => {
  const wrapper = getActualIdea();
  expect(wrapper.is('div.Idea')).toBe(true);
});
it('should have a <p />', () => {
  const wrapper = getActualIdea();
  expect(wrapper.find('p').length).toBe(1);
});
it('should have an <Actions />', () => {
  const wrapper = getActualIdea();
  expect(wrapper.find('Actions').length).toBe(1);
});
it('should set actions onRequestEditDialogOpen based on props', (done) => {
  const wrapper = getActualIdea({
    onRequestEditDialogOpen() {
      done();
    },
  });
  wrapper.find('Actions').prop('onRequestEditDialogOpen')();
});
it('should set actions onRequestConvertDialogOpen based on props', (done) => {
  const wrapper = getActualIdea({
    onRequestConvertDialogOpen() {
      done();
    },
  });
  wrapper.find('Actions').prop('onRequestConvertDialogOpen')();
});
it('should pass props.index when editing idea', () => {
  const wrapper = getActualIdea({
    index: 5,
    onRequestEditDialogOpen(index) {
      expect(index).toBe(5);
    },
  });
  wrapper.find('Actions').prop('onRequestEditDialogOpen')();
});
it('should pass props.index when converting idea', () => {
  const wrapper = getActualIdea({
    index: 5,
    onRequestConvertDialogOpen(index) {
      expect(index).toBe(5);
    },
  });
  wrapper.find('Actions').prop('onRequestConvertDialogOpen')();
});
it('should call onRequestDelete in handling delete request', (done) => {
  const wrapper = getActualIdea({
    onRequestDelete() {
      done();
    },
  });
  wrapper.instance().handleRequestDelete();
  jest.runAllTimers();
});

@@ -1927,16 +1927,235 @@
 llTimers();%0A%7D);%0A
+%0Ait('should set its class based on state', () =%3E %7B%0A  const wrapper = getActualIdea();%0A  wrapper.find('Actions').props().onRequestDelete();%0A  expect(wrapper.props().className.includes('will-be-deleted')).toBe(true);%0A%7D);%0A

Add Idea state unit test