import React from 'react';
import TestUtils from 'react/lib/ReactTestUtils';
import Icon from './icon';
import Tooltip from 'components/tooltip'

describe('Icon', () => {
  let instance, span, svg;

  describe('renderIcon', () => {
    it('calls the render warning icon method', () => {
      instance = TestUtils.renderIntoDocument(<Icon type='warning' />);
      instance.renderIcon;
      span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
      svg = span.children[0];
      expect(svg.getAttribute('class')).toEqual("ui-icon__svg ui-icon__svg--warning");
    });

    it('calls the render new icon method', () => {
      instance = TestUtils.renderIntoDocument(<Icon type='new' />);
      instance.renderIcon;
      span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
      svg = span.children[0];
      expect(svg.getAttribute('class')).toEqual("ui-icon__svg ui-icon__svg--new");
    });

    it('calls the render maintenance icon method', () => {
      instance = TestUtils.renderIntoDocument(<Icon type='maintenance' />);
      instance.renderIcon;
      span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
      svg = span.children[0];
      expect(svg.getAttribute('class')).toEqual("ui-icon__svg ui-icon__svg--maintenance");
    });

    it('calls the render sort down icon method', () => {
      instance = TestUtils.renderIntoDocument(<Icon type='sort-down' />);
      instance.renderIcon;
      span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
      svg = span.children[0];
      expect(svg.getAttribute('class')).toEqual("ui-icon__svg ui-icon__svg--sort-down");
    });

    it('calls the render sort up icon method', () => {
      instance = TestUtils.renderIntoDocument(<Icon type='sort-up' />);
      instance.renderIcon;
      span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
      svg = span.children[0];
      expect(svg.getAttribute('class')).toEqual("ui-icon__svg ui-icon__svg--sort-up");
    });

    it('calls the render refresh icon method', () => {
      instance = TestUtils.renderIntoDocument(<Icon type='refresh' />);
      instance.renderIcon;
      span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
      svg = span.children[0];
      expect(svg.getAttribute('class')).toEqual("ui-icon__svg ui-icon__svg--refresh");
    });

    it('calls the render bin icon method', () => {
      instance = TestUtils.renderIntoDocument(<Icon type='bin' />);
      instance.renderIcon;
      span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
      svg = span.children[0];
      expect(svg.getAttribute('class')).toEqual("ui-icon__svg ui-icon__svg--bin");
    });

    it('calls the render basket icon method', () => {
      instance = TestUtils.renderIntoDocument(<Icon type='basket' />);
      instance.renderIcon;
      span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
      svg = span.children[0];
      expect(svg.getAttribute('class')).toEqual("ui-icon__svg ui-icon__svg--basket");
    });

    it('calls the render phone icon method', () => {
      instance = TestUtils.renderIntoDocument(<Icon type='phone' />);
      instance.renderIcon;
      span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
      svg = span.children[0];
      expect(svg.getAttribute('class')).toEqual("ui-icon__svg ui-icon__svg--phone");
    });

    it('calls the render mobile icon method', () => {
      instance = TestUtils.renderIntoDocument(<Icon type='mobile' />);
      instance.renderIcon;
      span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
      svg = span.children[0];
      expect(svg.getAttribute('class')).toEqual("ui-icon__svg ui-icon__svg--mobile");
    });

    it('calls the render location icon method', () => {
      instance = TestUtils.renderIntoDocument(<Icon type='location' />);
      instance.renderIcon;
      span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
      svg = span.children[0];
      expect(svg.getAttribute('class')).toEqual("ui-icon__svg ui-icon__svg--location");
    });

    it('calls the render email icon method', () => {
      instance = TestUtils.renderIntoDocument(<Icon type='email' />);
      instance.renderIcon;
      span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
      svg = span.children[0];
      expect(svg.getAttribute('class')).toEqual("ui-icon__svg ui-icon__svg--email");
    });

    it('calls the render minus icon method', () => {
      instance = TestUtils.renderIntoDocument(<Icon type='minus' />);
      instance.renderIcon;
      span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
      svg = span.children[0];
      expect(svg.getAttribute('class')).toEqual("ui-icon__svg ui-icon__svg--minus");
    });

    it('calls the render minus icon method', () => {
      instance = TestUtils.renderIntoDocument(<Icon type='plus' />);
      instance.renderIcon;
      span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
      svg = span.children[0];
      expect(svg.getAttribute('class')).toEqual("ui-icon__svg ui-icon__svg--plus");
    
    it('calls the render business icon method', () => {
      instance = TestUtils.renderIntoDocument(<Icon type='business' />);
      instance.renderIcon;
      span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
      svg = span.children[0];
      expect(svg.getAttribute('class')).toEqual("ui-icon__svg ui-icon__svg--business");
    });

    it('calls the render individual icon method', () => {
      instance = TestUtils.renderIntoDocument(<Icon type='individual' />);
      instance.renderIcon;
      span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
      svg = span.children[0];
      expect(svg.getAttribute('class')).toEqual("ui-icon__svg ui-icon__svg--individual");
    });
  });

  describe('success', () => {
    it('renders with an icon of tick', () => {
      instance = TestUtils.renderIntoDocument(<Icon type='success' />);
      span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
      expect(span.className).toEqual('ui-icon icon-tick');
    });
  });

  describe('with no additional options', () => {
    beforeEach(() => {
      instance = TestUtils.renderIntoDocument(<Icon type='foo' />);
      span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
    });

    it('renders with a class of icon-settings', () => {
      expect(span.className).toEqual('ui-icon icon-foo');
    });
  });

  describe ('mainClasses', () => {
    describe('with custom class name', () => {
      beforeEach(() => {
        instance = TestUtils.renderIntoDocument(<Icon type='foo' className='custom' />);
        span = TestUtils.findRenderedDOMComponentWithTag(instance, 'span');
      });

      it('renders with a class of icon-settings and test', () => {
        expect(span.className).toEqual('ui-icon custom icon-foo');
      });
    });
  });

  describe('when passed a tooltipMessage', () => {
    it('renders a tooltip', () => {
      let helpInstance = TestUtils.renderIntoDocument(<Icon type='info' tooltipMessage='Helpful content' />);
      let tooltip = TestUtils.findRenderedComponentWithType(helpInstance, Tooltip);
      expect(tooltip).toBeDefined();
    });
  });
});

@@ -5133,24 +5133,32 @@
 vg--plus%22);%0A
+    %7D);%0A
     %0A    it(

fix build for contact-icons update