import React from 'react';
import chai, { expect } from 'chai';
import chaiEnzyme from 'chai-enzyme';
import { mount, shallow } from 'enzyme';

import Select from '../select';
import styles from '../select.css';

chai.use(chaiEnzyme());

describe('<Select />', () => {
  const baseProps = {
    labelKey: 'name',
    onChange() {},
    options: [{ name: 'Seattle' }, { name: 'Portland' }],
    valueKey: 'name',
  };

  it('applies single-select classname', () => {
    const wrapper = shallow(
      <Select
        {...baseProps}
        value={null}
      />
    );

    expect(wrapper.hasClass(styles['single-select'])).to.equal(true);
  });

  it('uses placeholder text in div element for single select', () => {
    const wrapper = mount(
      <Select
        {...baseProps}
        value={null}
      />
    );

    expect(wrapper.find('.Select-placeholder')).to.have.length(1);
    expect(wrapper.find('.Select-placeholder')
      .at(0).html()).to.equal('<div class="Select-placeholder">Add/Remove...</div>');
  });

  it('applies multi-select classname', () => {
    const wrapper = shallow(
      <Select
        {...baseProps}
        value={[]}
        multi
      />
    );

    expect(wrapper).to.have.className(styles['multi-select']);
  });

  it('uses placeholder text in input element for multi select', () => {
    const wrapper = mount(
      <Select
        {...baseProps}
        value={[]}
        multi
      />
    );

    expect(wrapper.find('input')).to.have.length(1);
    expect(wrapper.find('input').at(0).props().placeholder).to.equal('Add/Remove... (0)');
  });
});

@@ -113,17 +113,8 @@
 ount
-, shallow
  %7D f
@@ -408,65 +408,205 @@
 %0A%0A  
-it('applies
+let singleSelectWrapper;%0A  let multiSelectWrapper;%0A%0A  beforeEach(() =%3E %7B%0A   
  single
--s
+S
 elect
- classname', () =%3E %7B%0A    const w
+Wrapper = mount(%0A      %3CSelect%0A        %7B...baseProps%7D%0A        value=%7Bnull%7D%0A      /%3E%0A    );%0A%0A    multiSelectW
 rapp
@@ -602,39 +602,37 @@
 SelectWrapper = 
-shallow
+mount
 (%0A      %3CSelect%0A
@@ -673,58 +673,146 @@
 ue=%7B
-null%7D%0A      /%3E%0A    );%0A%0A    expect(wrapper.hasClass
+%5B%5D%7D%0A        multi%0A      /%3E%0A    );%0A  %7D);%0A%0A  it('applies single-select classname', () =%3E %7B%0A    expect(singleSelectWrapper).to.have.className
 (sty
@@ -836,24 +836,8 @@
 t'%5D)
-).to.equal(true)
 ;%0A  
@@ -920,118 +920,28 @@
     
-const wrapper = mount(%0A      %3CSelect%0A        %7B...baseProps%7D%0A        value=%7Bnull%7D%0A      /%3E%0A    );%0A%0A    expect(w
+expect(singleSelectW
 rapp
@@ -994,33 +994,45 @@
 (1);%0A    expect(
-w
+singleSelectW
 rapper.find('.Se
@@ -1198,132 +1198,27 @@
     
-const wrapper = shallow(%0A      %3CSelect%0A        %7B...baseProps%7D%0A        value=%7B%5B%5D%7D%0A        multi%0A      /%3E%0A    );%0A%0A    expect(w
+expect(multiSelectW
 rapp
@@ -1351,130 +1351,27 @@
     
-const wrapper = mount(%0A      %3CSelect%0A        %7B...baseProps%7D%0A        value=%7B%5B%5D%7D%0A        multi%0A      /%3E%0A    );%0A%0A    expect(w
+expect(multiSelectW
 rapp
@@ -1422,9 +1422,20 @@
 ect(
-w
+multiSelectW
 rapp
@@ -1450,16 +1450,23 @@
 'input')
+%0A      
 .at(0).p

edit test