/* global describe, it, expect */

import React from 'react';
import { shallow, mount } from 'enzyme';

import Input from '../src/Input';
import Icon from '../src/Icon';

describe('<Input />', () => {
  let wrapper = shallow(<Input />);

  it('renders a text field by default', () => {
    expect(wrapper.find('.input-field')).to.have.length(1);
  });

  it('renders a textarea when type is textarea', () => {
    wrapper = shallow(<Input type='textarea' />);
    expect(wrapper.find('textarea')).to.have.length(1);
  });

  it('renders a select element when type is select', () => {
    wrapper = mount(
      <Input type='select' defaultValue='v'>
        <option value='v' />
        <option value='w' />
      </Input>);
    expect(wrapper.find('select')).to.have.length(1);
  });

  it('renders an icon with prefix class name when icon prefix is used', () => {
    wrapper = mount(
      <Input type='text'><Icon>account_circle</Icon></Input>
    );
    expect(wrapper.find('i.prefix')).to.have.length(1);
  });

  it('renders placeholder as the default disabled option for select', () => {
    let defaultOption = 'Choose your option';
    wrapper = mount(
      <Input type='select' placeholder={defaultOption}>
        <option value='1'>Option 1</option>
        <option value='2'>Option 2</option>
        <option value='3'>Option 3</option>
      </Input>);
    expect(wrapper.find('option')).to.have.length(4);
  });

  it('renders a select with multiple', () => {
    let defaultOption = 'Choose your option';
    wrapper = mount(
      <Input type='select' multiple placeholder={defaultOption}>
        <option value='1'>Option 1</option>
        <option value='2'>Option 2</option>
        <option value='3'>Option 3</option>
      </Input>);
    expect(wrapper.find('select[multiple]')).to.have.length(1);
  });

  it('renders a switch with custom labels',  function() {
    let instance = TestUtils.renderIntoDocument(
        <Input type='switch'/>
      );

    let input = TestUtils.findRenderedDOMComponentWithTag(instance, 'input');
    assert.include(ReactDOM.findDOMNode(input).type, 'checkbox');
  });
});

@@ -1865,257 +1865,214 @@
 abel
-s
 ', 
- function() %7B%0A    let instance = TestUtils.renderIntoDocument(%0A        %3CInput type='switch'
+() =%3E %7B%0A    const offLabel = 'No';%0A    wrapper = shallow(%0A      %3CInput type='switch' onLabel='Yes' offLabel=%7BoffLabel%7D 
 /%3E%0A
-  
     );%0A
-%0A
     
-let input = TestUtils.findRenderedDOMComponentWithTag(instance, 'input');%0A    assert.include(ReactDOM.findDOMNode(input).type, 'checkbox'
+expect(wrapper.childAt(0).childAt(0).contains(offLabel)).to.equal(true
 );%0A 

Fix input spec